Preprocess asm on all platforms with delocate.

Since 31dcfcd080, delocate can drive cpp
itself to preprocess assembly inputs. This change switches the CMake
build to doing that and does it on all platforms in order to be more
uniform.

Change-Id: Ie28228fb1a4c63a2d43ab8a97f09cfe890ef39a1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55326
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
fips-20230428
Adam Langley 2 years ago committed by Boringssl LUCI CQ
parent d94d41ca39
commit 87cbe22b59
  1. 48
      crypto/fipsmodule/CMakeLists.txt

@ -128,22 +128,6 @@ perlasm(x86_64-mont5.${ASM_EXT} bn/asm/x86_64-mont5.pl)
perlasm(x86_64-mont.${ASM_EXT} bn/asm/x86_64-mont.pl) perlasm(x86_64-mont.${ASM_EXT} bn/asm/x86_64-mont.pl)
perlasm(x86-mont.${ASM_EXT} bn/asm/x86-mont.pl) perlasm(x86-mont.${ASM_EXT} bn/asm/x86-mont.pl)
function(cpreprocess dest src)
set(TARGET "")
if(CMAKE_ASM_COMPILER_TARGET)
set(TARGET "--target=${CMAKE_ASM_COMPILER_TARGET}")
endif()
add_custom_command(
OUTPUT ${dest}
COMMAND ${CMAKE_ASM_COMPILER} ${TARGET} $CMAKE_ASM_FLAGS -E ${src} -I${PROJECT_SOURCE_DIR}/include > ${dest}
DEPENDS
${src}
${PROJECT_SOURCE_DIR}/include/openssl/arm_arch.h
WORKING_DIRECTORY .
)
endfunction()
if(FIPS_DELOCATE) if(FIPS_DELOCATE)
if(FIPS_SHARED) if(FIPS_SHARED)
error("Can't set both delocate and shared mode for FIPS build") error("Can't set both delocate and shared mode for FIPS build")
@ -164,28 +148,32 @@ if(FIPS_DELOCATE)
bcm.c bcm.c
) )
if(ARCH STREQUAL "aarch64")
# Perlasm output on Aarch64 needs to pass through the C preprocessor before
# it can be parsed by delocate.
foreach(asm ${BCM_ASM_SOURCES})
cpreprocess(${asm}.s ${asm})
list(APPEND BCM_ASM_PROCESSED_SOURCES "${asm}.s")
endforeach()
else()
# No preprocessing is required on other platforms.
set(BCM_ASM_PROCESSED_SOURCES ${BCM_ASM_SOURCES})
endif()
add_dependencies(bcm_c_generated_asm global_target) add_dependencies(bcm_c_generated_asm global_target)
set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S") set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S")
set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON)
set(TARGET "")
if(CMAKE_ASM_COMPILER_TARGET)
set(TARGET "--target=${CMAKE_ASM_COMPILER_TARGET}")
endif()
go_executable(delocate boringssl.googlesource.com/boringssl/util/fipstools/delocate) go_executable(delocate boringssl.googlesource.com/boringssl/util/fipstools/delocate)
add_custom_command( add_custom_command(
OUTPUT bcm-delocated.S OUTPUT bcm-delocated.S
COMMAND ./delocate -a $<TARGET_FILE:bcm_c_generated_asm> -o bcm-delocated.S ${BCM_ASM_PROCESSED_SOURCES} COMMAND
DEPENDS bcm_c_generated_asm delocate ${BCM_ASM_PROCESSED_SOURCES} ./delocate
-a $<TARGET_FILE:bcm_c_generated_asm>
-o bcm-delocated.S
-cc ${CMAKE_ASM_COMPILER}
-cc-flags "${TARGET} $CMAKE_ASM_FLAGS"
${PROJECT_SOURCE_DIR}/include/openssl/arm_arch.h
${BCM_ASM_SOURCES}
DEPENDS
bcm_c_generated_asm
delocate
${BCM_ASM_SOURCES}
${PROJECT_SOURCE_DIR}/include/openssl/arm_arch.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) )

Loading…
Cancel
Save