Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31337: build: Fix coverage builds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fanquake committed Nov 27, 2024
2 parents efdb49a + 01a7298 commit 144f98d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,16 @@ configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPY
# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK)

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

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

0 comments on commit 144f98d

Please sign in to comment.