Skip to content

Commit 58f15d4

Browse files
committed
Merge bitcoin/bitcoin#31379: cmake: Fix passing APPEND_*FLAGS to secp256k1 subtree
c4c5cf1 cmake: Fix passing `APPEND_*FLAGS` to `secp256k1` subtree (Hennadii Stepanov) eb540a2 cmake: Remove `core_sanitizer_{cxx,linker}_flags` helper variables (Hennadii Stepanov) Pull request description: On the master branch @ 70e20ea, the `APPEND_CPPFLAGS`, `APPEND_CFLAGS` and `APPEND_LDFLAGS` are not correctly applied when building C code in the `secp256k1` subtree, as intended. This behaviour occurs due to two issues: 1. The command here: https://github.com/bitcoin/bitcoin/blob/70e20ea024ce4f39abc4022e1ba19d5a6db2a207/src/CMakeLists.txt#L77 does not affect the code in `add_subdirectory(secp256k1)` above it. 2. `APPEND_LDFLAGS` is not passed to the subtree's build system at all. This PR fixes both issues. Additionally, the helper variables `core_sanitizer_cxx_flags` and `core_sanitizer_linker_flags` have been removed. ACKs for top commit: theuni: utACK c4c5cf1. TheCharlatan: ACK c4c5cf1 Tree-SHA512: 707acfa623f0436e34e9e6ba8ce2979e0fde5e196e2242fd1cde4c50f433938549781193d8a06419a0866bbe6d69d76f8383d973afbd87d944407963b318c5c9
2 parents e606c57 + c4c5cf1 commit 58f15d4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
5050
include(GetTargetInterface)
5151
# -fsanitize and related flags apply to both C++ and C,
5252
# so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS.
53-
get_target_interface(core_sanitizer_cxx_flags "" sanitize_interface COMPILE_OPTIONS)
54-
set(SECP256K1_APPEND_CFLAGS ${core_sanitizer_cxx_flags} CACHE STRING "" FORCE)
55-
unset(core_sanitizer_cxx_flags)
56-
get_target_interface(core_sanitizer_linker_flags "" sanitize_interface LINK_OPTIONS)
57-
set(SECP256K1_APPEND_LDFLAGS ${core_sanitizer_linker_flags} CACHE STRING "" FORCE)
58-
unset(core_sanitizer_linker_flags)
53+
get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS)
54+
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CPPFLAGS}" SECP256K1_APPEND_CFLAGS)
55+
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CFLAGS}" SECP256K1_APPEND_CFLAGS)
56+
set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE)
57+
get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS)
58+
string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS)
59+
set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE)
5960
# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration.
6061
enable_language(C)
6162
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)
@@ -76,7 +77,6 @@ set_target_properties(secp256k1 PROPERTIES
7677
EXCLUDE_FROM_ALL TRUE
7778
)
7879
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
79-
string(APPEND CMAKE_C_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CFLAGS}")
8080

8181
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
8282
arith_uint256.cpp

0 commit comments

Comments
 (0)