Skip to content

Commit 9cb9651

Browse files
committed
Merge bitcoin/bitcoin#30778: build: Fix linking for fuzz target when building with MSan
787dfaf ci: Do not override `-g -O1` set in `MSAN_FLAGS` (Hennadii Stepanov) 26c460a build: Fix linking for `fuzz` target when building with MSan (Hennadii Stepanov) Pull request description: The first commit fixes bitcoin/bitcoin#30760. The second commit: 1. Preserves `-g -O1` set in `MSAN_FLAGS`. Since configuration-specific flags override general flags, these are set to empty strings. A similar approach is used in the OSS-Fuzz repository. 2. Sets the "Debug" build configuration when depends are built with `DEBUG=1`, ensuring that `linux_debug_CPPFLAGS` from depends are passed to the main build system. ACKs for top commit: maflcko: review-only ACK 787dfaf fanquake: ACK 787dfaf - as a follow up it would be good to: Tree-SHA512: c324390d1dbda30f82025d8482ddb0cfa0395f9ba225a2ddce05a123c65e0622a6a1d5f0fa03f09e21d62792431cf3da5c49e41a3ac7f7a958d0392a0430f29c
2 parents 4c526f5 + 787dfaf commit 9cb9651

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ci/test/00_setup_env_native_fuzz_with_msan.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ export PACKAGES="ninja-build"
1717
# BDB generates false-positives and will be removed in future
1818
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
1919
export GOAL="install"
20+
# Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered.
2021
# _FORTIFY_SOURCE is not compatible with MSAN.
2122
export BITCOIN_CONFIG="\
23+
-DCMAKE_BUILD_TYPE=Debug \
24+
-DCMAKE_C_FLAGS_DEBUG='' \
25+
-DCMAKE_CXX_FLAGS_DEBUG='' \
2226
-DBUILD_FOR_FUZZING=ON \
2327
-DSANITIZERS=fuzzer,memory \
2428
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE' \

ci/test/00_setup_env_native_msan.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ export PACKAGES="ninja-build"
1717
# BDB generates false-positives and will be removed in future
1818
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
1919
export GOAL="install"
20+
# Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered.
2021
# _FORTIFY_SOURCE is not compatible with MSAN.
21-
export BITCOIN_CONFIG="-DSANITIZERS=memory -DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE'"
22+
export BITCOIN_CONFIG="\
23+
-DCMAKE_BUILD_TYPE=Debug \
24+
-DCMAKE_C_FLAGS_DEBUG='' \
25+
-DCMAKE_CXX_FLAGS_DEBUG='' \
26+
-DSANITIZERS=memory \
27+
-DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' \
28+
"
2229
export USE_MEMORY_SANITIZER="true"
2330
export RUN_FUNCTIONAL_TESTS="false"
2431
export CCACHE_MAXSIZE=250M

src/test/fuzz/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ target_link_libraries(fuzz
132132
test_fuzz
133133
bitcoin_cli
134134
bitcoin_common
135+
bitcoin_util
135136
minisketch
136137
leveldb
137138
univalue

0 commit comments

Comments
 (0)