From eb540a262953baf9ed920f98efc4044a353b278a Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 3 Dec 2024 20:52:37 +0000 Subject: [PATCH 1/2] cmake: Remove `core_sanitizer_{cxx,linker}_flags` helper variables This change make the code more concise and minimizes the diff in the subsequent commit. --- src/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 889c00c7832..9629dd70336 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,12 +51,10 @@ set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) include(GetTargetInterface) # -fsanitize and related flags apply to both C++ and C, # so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS. -get_target_interface(core_sanitizer_cxx_flags "" sanitize_interface COMPILE_OPTIONS) -set(SECP256K1_APPEND_CFLAGS ${core_sanitizer_cxx_flags} CACHE STRING "" FORCE) -unset(core_sanitizer_cxx_flags) -get_target_interface(core_sanitizer_linker_flags "" sanitize_interface LINK_OPTIONS) -set(SECP256K1_APPEND_LDFLAGS ${core_sanitizer_linker_flags} CACHE STRING "" FORCE) -unset(core_sanitizer_linker_flags) +get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS) +set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE) +get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS) +set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE) # We want to build libsecp256k1 with the most tested RelWithDebInfo configuration. enable_language(C) foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES) From c4c5cf174883cb53256e869f0d1673e29576a97c Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 3 Dec 2024 20:55:28 +0000 Subject: [PATCH 2/2] cmake: Fix passing `APPEND_*FLAGS` to `secp256k1` subtree --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9629dd70336..00a4954eb27 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,8 +52,11 @@ include(GetTargetInterface) # -fsanitize and related flags apply to both C++ and C, # so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS. get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS) +string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CPPFLAGS}" SECP256K1_APPEND_CFLAGS) +string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CFLAGS}" SECP256K1_APPEND_CFLAGS) set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE) get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS) +string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS) set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE) # We want to build libsecp256k1 with the most tested RelWithDebInfo configuration. enable_language(C) @@ -75,7 +78,6 @@ set_target_properties(secp256k1 PROPERTIES EXCLUDE_FROM_ALL TRUE ) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -string(APPEND CMAKE_C_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CFLAGS}") add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL arith_uint256.cpp