From 93a0c2da34b45aaf0aab23c5f1b66cb32df06507 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 4 Sep 2024 07:52:02 +0100 Subject: [PATCH] build: Unify `-logsourcelocations` format --- CMakeLists.txt | 8 ++++++++ cmake/ccache.cmake | 8 -------- contrib/guix/libexec/build.sh | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ef80ffc6f956..334fa8142e4de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -466,6 +466,14 @@ configure_file(contrib/filter-lcov.py filter-lcov.py COPYONLY) # 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) +# Make builds location independent. This helps to: +# 1. Unify the -logsourcelocations format. +# 2. Improve ccache efficiency across different directories. +# 3. Achive reproducibility for release binaries. +try_append_cxx_flags("-ffile-prefix-map=A=B" TARGET core_interface SKIP_LINK + IF_CHECK_PASSED "-ffile-prefix-map=${PROJECT_SOURCE_DIR}/src=." +) + # Currently all versions of gcc are subject to a class of bugs, see the # gccbug_90348 test case (only reproduces on GCC 11 and earlier) and # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111843. To work around that, set diff --git a/cmake/ccache.cmake b/cmake/ccache.cmake index 099aa66411fb6..d1cc204c8e463 100644 --- a/cmake/ccache.cmake +++ b/cmake/ccache.cmake @@ -23,14 +23,6 @@ if(NOT MSVC) else() set(WITH_CCACHE OFF) endif() - if(WITH_CCACHE) - try_append_cxx_flags("-fdebug-prefix-map=A=B" TARGET core_interface SKIP_LINK - IF_CHECK_PASSED "-fdebug-prefix-map=${PROJECT_SOURCE_DIR}=." - ) - try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK - IF_CHECK_PASSED "-fmacro-prefix-map=${PROJECT_SOURCE_DIR}=." - ) - endif() endif() mark_as_advanced(CCACHE_EXECUTABLE) diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 1ffc22a76bce1..fd9df4f67ef2d 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -212,7 +212,6 @@ CONFIGFLAGS="-DREDUCE_EXPORTS=ON -DBUILD_BENCH=OFF -DBUILD_GUI_TESTS=OFF -DBUILD HOST_CFLAGS="-O2 -g" HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) case "$HOST" in - *linux*) HOST_CFLAGS+=" -ffile-prefix-map=${DISTSRC}/src=." ;; *mingw*) HOST_CFLAGS+=" -fno-ident" ;; *darwin*) unset HOST_CFLAGS ;; esac