[Buildroot] [PATCH v2 2/2] toolchain/toolchain-wrapper: handle __FILE__ macro for reproducibility
Atharva Lele
itsatharva at gmail.com
Sat Aug 31 18:01:13 UTC 2019
Many tools use __FILE__ for debugging and __FILE__ captures the build path.
This results in non-reproducible images when building in different directories.
If the config uses GCC 8 or above, we use -ffile-prefix-map=old=new and let gcc
take care of the path remapping in __FILE__. Since GCC versions before v8 did
not have this feature, we use a dummy string in that case.
Signed-off-by: Atharva Lele <itsatharva at gmail.com>
---
Changes v2:
- New patch
---
toolchain/toolchain-wrapper.mk | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk
index 88695a5b2d..6d0ae2c85b 100644
--- a/toolchain/toolchain-wrapper.mk
+++ b/toolchain/toolchain-wrapper.mk
@@ -23,6 +23,11 @@ TOOLCHAIN_WRAPPER_OPTS = \
ifeq ($(BR2_REPRODUCIBLE),y)
TOOLCHAIN_WRAPPER_OPTS += -Wl,--build-id=none
+ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
+TOOLCHAIN_WRAPPER_OPTS += -ffile-prefix-map=$(BASE_DIR)=buildroot
+else
+TOOLCHAIN_WRAPPER_OPTS += -D__FILE__=\"file-path-replaced-by-buildroot-for-reproducibility\"
+endif
endif
# We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
--
2.22.0
More information about the buildroot
mailing list