Skip to content

Commit 144f98d

Browse files
committed
Merge bitcoin/bitcoin#31337: build: Fix coverage builds
01a7298 build: Avoid using the `-ffile-prefix-map` compiler option (Hennadii Stepanov) Pull request description: This PR follows up on bitcoin/bitcoin#30811, which inadvertently broke coverage builds: 1. For GCC. See bitcoin/bitcoin#31337 (comment). 2. For [Clang's source-based code coverage](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html) in the OSS-Fuzz environment due to its use of other options and a third party script. See https://issues.oss-fuzz.com/issues/379122777. The root cause of this regression is that the `-ffile-prefix-map` option implicitly applies: - [`-fprofile-prefix-map`](https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fprofile-prefix-map) when using GCC. - [`-fcoverage-prefix-map`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fcoverage-prefix-map) when using Clang. ~This behaviour is not explicitly documented~ See llvm/llvm-project@994c544. With this PR, only the `-fdebug-prefix-map` and `-fmacro-prefix-map` options are applied. **Note for reviewers:** Please ensure that bitcoin/bitcoin#30799 is not reintroduced. ACKs for top commit: maflcko: review ACK 01a7298 dergoegge: tACK 01a7298 Tree-SHA512: 70b11d769d2653c1528ffe1d430b79f20b061037bcb1db6addb261aa2c7be20c4bc4328ccff919adb72e81aa2e65b885c970cce3837aeeb3ca0a98b32b83d2e3
2 parents efdb49a + 01a7298 commit 144f98d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,16 @@ configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPY
438438
# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
439439
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK)
440440

441-
try_append_cxx_flags("-ffile-prefix-map=A=B" TARGET core_interface SKIP_LINK
442-
IF_CHECK_PASSED "-ffile-prefix-map=${PROJECT_SOURCE_DIR}/src=."
441+
# Avoiding the `-ffile-prefix-map` compiler option because it implies
442+
# `-fcoverage-prefix-map` on Clang or `-fprofile-prefix-map` on GCC,
443+
# which can cause issues with coverage builds, particularly when using
444+
# Clang in the OSS-Fuzz environment due to its use of other options
445+
# and a third party script, or with GCC.
446+
try_append_cxx_flags("-fdebug-prefix-map=A=B" TARGET core_interface SKIP_LINK
447+
IF_CHECK_PASSED "-fdebug-prefix-map=${PROJECT_SOURCE_DIR}/src=."
448+
)
449+
try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK
450+
IF_CHECK_PASSED "-fmacro-prefix-map=${PROJECT_SOURCE_DIR}/src=."
443451
)
444452

445453
# Currently all versions of gcc are subject to a class of bugs, see the

0 commit comments

Comments
 (0)