Skip to content

Commit

Permalink
[FIXUP] cmake: Do not apply hardening flags to libsecp256k1 C code
Browse files Browse the repository at this point in the history
This change mirrors the master branch behavior.
  • Loading branch information
hebasto committed May 26, 2024
1 parent 6230d47 commit b18aefe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,11 @@ endif()
include(AddThreadsIfNeeded)
add_threads_if_needed()

add_library(sanitizing_interface INTERFACE)
target_link_libraries(core_base_interface INTERFACE sanitizing_interface)
if(SANITIZERS)
# First check if the compiler accepts flags. If an incompatible pair like
# -fsanitize=address,thread is used here, this check will fail. This will also
# fail if a bad argument is passed, e.g. -fsanitize=undfeined
try_append_cxx_flags("-fsanitize=${SANITIZERS}" TARGET sanitizing_interface
try_append_cxx_flags("-fsanitize=${SANITIZERS}" TARGET core_base_interface
RESULT_VAR cxx_supports_sanitizers
SKIP_LINK
)
Expand All @@ -354,7 +352,7 @@ if(SANITIZERS)
message(FATAL_ERROR "Linker did not accept requested flags, you are missing required libraries.")
endif()
endif()
target_link_options(sanitizing_interface INTERFACE ${SANITIZER_LDFLAGS})
target_link_options(core_base_interface INTERFACE ${SANITIZER_LDFLAGS})

include(AddBoostIfNeeded)
add_boost_if_needed()
Expand Down Expand Up @@ -497,7 +495,7 @@ try_append_cxx_flags("-fstack-reuse=none" TARGET core_base_interface)

if(ENABLE_HARDENING)
add_library(hardening_interface INTERFACE)
target_link_libraries(core_base_interface INTERFACE hardening_interface)
target_link_libraries(core_interface INTERFACE hardening_interface)
if(MSVC)
try_append_linker_flag("/DYNAMICBASE" TARGET hardening_interface)
try_append_linker_flag("/HIGHENTROPYVA" TARGET hardening_interface)
Expand Down
5 changes: 4 additions & 1 deletion cmake/crc32c.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ target_compile_definitions(crc32c_common INTERFACE
HAVE_STRONG_GETAUXVAL=$<BOOL:${HAVE_STRONG_GETAUXVAL}>
BYTE_ORDER_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>
)
target_link_libraries(crc32c_common INTERFACE core_base_interface)
target_link_libraries(crc32c_common INTERFACE
core_base_interface
hardening_interface
)

add_library(crc32c STATIC EXCLUDE_FROM_ALL
${PROJECT_SOURCE_DIR}/src/crc32c/src/crc32c.cc
Expand Down
1 change: 1 addition & 0 deletions cmake/leveldb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ endif()

target_link_libraries(leveldb PRIVATE
core_base_interface
hardening_interface
nowarn_leveldb_interface
crc32c
)
Expand Down
2 changes: 2 additions & 0 deletions cmake/minisketch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ if(HAVE_CLMUL)
target_link_libraries(minisketch_clmul
PRIVATE
core_base_interface
hardening_interface
minisketch_common
)
set_target_properties(minisketch_clmul PROPERTIES
Expand Down Expand Up @@ -82,6 +83,7 @@ target_include_directories(minisketch
target_link_libraries(minisketch
PRIVATE
core_base_interface
hardening_interface
minisketch_common
$<TARGET_NAME_IF_EXISTS:minisketch_clmul>
)
Expand Down

0 comments on commit b18aefe

Please sign in to comment.