From d7bd98e719b88673cd59edb694153c1e34207a26 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 8 Mar 2026 14:09:41 -0700 Subject: [PATCH] Use -fmacro-prefix-map for utils The __FILE__ macro is used in the EXCEPTION macro to report the file name alongside error messages. This macro reports the file name exactly as it is passed to the compiler. For most source files in libgourou this is a nice relative path such as "src/libgourou.cpp". However, for EXCEPTION instances in libgourou_common.h, the compiler flag is "-I$(ROOT)/include", where $(ROOT) is an absolute path passed from the higher Makefile. This results in an absolute path to the build directory being hardcoded into the utils shared library and binaries, and reported in error messages. Besides being less readable than the more common relative paths, this triggers warnings from packaging tools that detect inadvertent references to temporary build directories that end up in compiled binaries and might indicate a bug. There is a GCC feature -fmacro-prefix-map which allows to perform substition on the values that are used for __FILE__. Use that option to strip out the absolute path component, without changing any functionality. The feature was added to GCC on 2018-01-18 and released in GCC 8.1.0. https://github.com/gcc-mirror/gcc/commit/7365279fca30371b07e49bfa83a23ddc44cc3860 --- utils/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Makefile b/utils/Makefile index ba85377..2b4bfda 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -6,7 +6,7 @@ TARGETS=$(TARGET_BINARIES) launcher MAN_PAGES=acsmdownloader adept_activate adept_remove adept_loan_mgt -CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -fdata-sections -ffunction-sections +CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -fmacro-prefix-map=$(ROOT)/= -fdata-sections -ffunction-sections STATIC_DEP= # LDFLAGS += -Wl,--gc-sections