Skip to content

Commit 01a7298

Browse files
committed
build: Avoid using the -ffile-prefix-map compiler option
The `-ffile-prefix-map` compiler option implies `-fprofile-prefix-map` on GCC or `-fcoverage-prefix-map` on Clang, which can lead to issues with coverage builds. This change applies only the options necessary for build reproducibility and accurate source location messages.
1 parent 22ef95d commit 01a7298

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
@@ -436,8 +436,16 @@ configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPY
436436
# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
437437
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK)
438438

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

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

0 commit comments

Comments
 (0)