From 01a7298818d7bd66bb8c800d7cd30ae0a4d3b1d1 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:56:47 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 767ccc57749..7193f16bd26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -436,8 +436,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