From mboxrd@z Thu Jan 1 00:00:00 1970 From: Atharva Lele Date: Fri, 16 Aug 2019 22:33:45 +0530 Subject: [Buildroot] [PATCH] toolchain/toolchain-wrapper: explicitly set Build ID to none if BR2_REPRODUCIBLE Message-ID: <20190816170345.19480-1-itsatharva@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Build ID is added to binaries at link time. Building in different output directories causes some packages to have different Build IDs, thus resulting in non-reproducibility. Adding "-Wl,--build-id=none" fixes this issue by disabling setting of Build ID. Diffoscope output for Build ID issue: https://gitlab.com/snippets/1886180/raw After this patch, build is reproducible - i.e. diffoscope does not produce any output. Signed-off-by: Atharva Lele --- toolchain/toolchain-wrapper.c | 3 +++ toolchain/toolchain-wrapper.mk | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c index 7a4b9c4007..f7f2a9ec97 100644 --- a/toolchain/toolchain-wrapper.c +++ b/toolchain/toolchain-wrapper.c @@ -98,6 +98,9 @@ static char *predef_args[] = { #if defined(BR_MIPS_TARGET_BIG_ENDIAN) || defined(BR_ARC_TARGET_BIG_ENDIAN) "-EB", #endif +#ifdef BR2_REPRODUCIBLE + "-Wl,--build-id=none", +#endif #ifdef BR_ADDITIONAL_CFLAGS BR_ADDITIONAL_CFLAGS #endif diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk index 970bde76a0..21fc08f3ee 100644 --- a/toolchain/toolchain-wrapper.mk +++ b/toolchain/toolchain-wrapper.mk @@ -59,6 +59,10 @@ else ifeq ($(BR2_RELRO_FULL),y) TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL endif +ifeq ($(BR2_REPRODUCIBLE),y) +TOOLCHAIN_WRAPPER_ARGS += -DBR2_REPRODUCIBLE +endif + define TOOLCHAIN_WRAPPER_BUILD $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \ -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \ -- 2.22.0