[PATCH] Makefile: Use relative paths for debugging symbols.
authorVagrant Cascadian <vagrant@reproducible-builds.org>
Wed, 17 Aug 2022 02:00:04 +0000 (19:00 -0700)
committerVagrant Cascadian <vagrant@debian.org>
Thu, 2 Jan 2025 21:47:07 +0000 (13:47 -0800)
The KBUILD_CFLAGS and KBUILD_AFLAGS variables are adjusted to use
-ffile-prefix-map and --debug-prefix-map, respectively, to use
relative paths for occurrences of __FILE__ and debug paths.

This enables reproducible builds regardless of the absolute path to
the build directory:

  https://reproducible-builds.org/docs/build-path/

Series-to: u-boot
Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
Gbp-Pq: Name Makefile-Use-relative-paths-for-debugging-symbols.patch

Makefile

index ac84c59ac51f28795c64d6f449aed8420298ddcb..258137707ce69f472751271ec481bcace49351ba 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -769,14 +769,18 @@ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
 # Enabled with W=2, disabled by default as noisy
 KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
 
-# change __FILE__ to the relative path from the srctree
-KBUILD_CFLAGS  += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+# change __FILE__ and debugging symbols to the relative path from the
+# srctree
+KBUILD_CFLAGS  += $(call cc-option,-ffile-prefix-map=$(srctree)/=)
 
 KBUILD_CFLAGS  += -gdwarf-4
 # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
 # option to the assembler.
 KBUILD_AFLAGS  += -gdwarf-4
 
+# Use relative paths in debugging symbols
+KBUILD_AFLAGS   += --debug-prefix-map=$(srctree)/=
+
 # Report stack usage if supported
 # ARC tools based on GCC 7.1 has an issue with stack usage
 # with naked functions, see commit message for more details