Source: last-align
Severity: important
Tags: patch
User: [email protected]
Usertags: buildpath
X-Debbugs-Cc: [email protected]

Both CFLAGS and CXXFLAGS were not actually getting passed to the builds
in all cases, resulting in two issues, the "optimized variants" of
various commands were actually identical:

  $ sha256sum lastdb5-*
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  lastdb5-avx
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  lastdb5-avx2
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  
lastdb5-plain
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  lastdb5-sse2
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  lastdb5-sse3
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  
lastdb5-sse4.1
  a902143d8f91b11bc2bd1d45ed2798b62d3e9c6763785464ada2f2df99410723  
lastdb5-ssse3

Generally, I love it when binaries come out bit-for-bit identical, but
in this case, it actually is a bug!

The only command that built differently were the last-merge-batches-*
variants. I'm not sure why, possibly something in the ordering of which
packages get built somehow resulting in the *FLAGS being applied only
once?


The other issue is that the buildpath is embedded in the binaries and
debugging symbols, as -ffile-prefix-map=BUILDPATH=. was not passed via
CFLAGS/CXXFLAGS.

The attached patch to debian/rules fixes this by passing CFLAGS and
CXXFLAGS via dh_auto_build, rather than relying on the exported
variables.


With this patch applied, last-align should build reproducibly on
tests.reproducible-builds.org (and probably salsa-ci too!), not to
mention that the optimized binaries will actually be optimized!


Thanks for maintaining last-align!


live well,
  vagrant
From 743aed1d0f6d033fe221ac2d7332a58c4665489d Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Tue, 11 Jan 2022 00:15:48 +0000
Subject: [PATCH 1/2] debian/rules: Pass CFLAGS and CXXFLAGS directly to
 dh_auto_build rather than exporting.

The makefiles were not inheriting the exported *FLAGS variables,
resulting in the optimized variants lacking the optimizations, as well
as missing the default flags set via dpkg-buildflags.
---
 debian/rules | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/debian/rules b/debian/rules
index 73bfc74..f89ac6e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,22 +36,20 @@ ifeq (amd64,$(DEB_HOST_ARCH))
 	mkdir -p $(prefix)
 	mkdir -p $(libexecdir)
 	for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 ; do \
-		export CXXFLAGS="$(CXXFLAGS) -m$${SIMD}" && export CFLAGS="$(CFLAGS) -m$${SIMD}" && \
-		dh_auto_build -- all SFX=-$${SIMD}  ; \
+		dh_auto_build -- all SFX=-$${SIMD} CFLAGS="$(CFLAGS) -m$${SIMD}" CXXFLAGS="$(CXXFLAGS) -m$${SIMD}" ; \
 		find . -name '*.o' -delete ; \
 		find . -name '*.o5' -delete ; \
 	done
-	export CXXFLAGS="$(CXXFLAGS)" && export CFLAGS="$(CFLAGS)" && dh_auto_build -- all SFX=-plain
+	dh_auto_build -- all SFX=-plain CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)"
 else ifeq (i386,$(DEB_HOST_ARCH))
 	mkdir -p $(prefix)
 	mkdir -p $(libexecdir)
 	for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 sse; do \
-		export CXXFLAGS="$(CXXFLAGS) -m$${SIMD}" && export CFLAGS="$(CFLAGS) -m$${SIMD}" && \
-		dh_auto_build -- all SFX=-$${SIMD}  ; \
+		dh_auto_build -- all SFX=-$${SIMD} CFLAGS="$(CFLAGS) -m$${SIMD}" CXXFLAGS="$(CXXFLAGS) -m$${SIMD}" ; \
 		find . -name '*.o' -delete ; \
 		find . -name '*.o5' -delete ; \
 	done
-	export CXXFLAGS="$(CXXFLAGS)" && export CFLAGS="$(CFLAGS)" && dh_auto_build -- all SFX=-plain
+	dh_auto_build -- all SFX=-plain CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)"
 else
 	dh_auto_build
 endif
-- 
2.34.1

Attachment: signature.asc
Description: PGP signature

Reply via email to