Source: gmp
Severity: normal
Tags: patch
User: [email protected]
Usertags: buildpath
X-Debbugs-Cc: [email protected]

The build path is embedded in various files:

  
https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/diffoscope-results/gmp.html

  /usr/include/x86_64-linux-gnu/gmp.h

  
#define·__GMP_CFLAGS·"-g·-O2·-ffile-prefix-map=/build/1st/gmp-6.2.1+dfsg=.·-fstack-..."
  vs.
  
#define·__GMP_CFLAGS·"-g·-O2·-ffile-prefix-map=/build/2/gmp-6.2.1+dfsg/2nd=.·-fstack-..."

  /usr/lib/x86_64-linux-gnu/libgmp.so.10.4.1

  /build/1st/gmp-6.2.1+dfsg/build/mpn/tmp-add_n.s:97
  vs.
  /build/2/gmp-6.2.1+dfsg/2nd/build/mpn/tmp-add_n.s:97

The attached patches fix this by replacing the build path with
"BUILDPATH" from in debian/rules, and passing a --debug-prefix-map
argument to use relative paths via ASMFLAGS in configure.


With these patches applied gmp should build reproducibly on
tests.reproducible-builds.org!


Thanks for maintaining gmp!


live well,
  vagrant
From df942b2fed320e95465625870e8832574a37ab5e Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Wed, 20 Apr 2022 21:33:25 +0000
Subject: [PATCH 1/2] debian/rules: Pass ASMFLAGS with debug-prefix-map to
 configure.

The absolute build path can be embedded in generated assembly
code. Instead, passing --debug-prefix-map is used to adjust the
absolute paths to relative paths within the source code.

https://tests.reproducible-builds.org/debian/issues/build_path_captured_in_assembly_objects_issue.html
---
 debian/rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index 164d9e3..905d95b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -89,7 +89,7 @@ configure-stamp:
 	mkdir -p build
 	cd build && ../configure $(confflags_ma) \
 	    AR=$(AR) CC="$(CC)" CFLAGS="$(CFLAGS)" \
-	    CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)"
+	    CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" ASMFLAGS="--debug-prefix-map=$(CURDIR)=."
 	touch $@
 
 build: build-stamp
-- 
2.35.2

From df301d96468c6248f103b6c16270aeb379e3b3fd Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Wed, 20 Apr 2022 21:38:46 +0000
Subject: [PATCH 2/2] debian/rules: Replace embedded build path in gmp.h with a
 placeholder string.

Frequently builds of debian packages are done in a randomized
directory path which is unlikely to be present on the end-user
system.

https://reproducible-builds.org/docs/build-path/
---
 debian/rules | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/debian/rules b/debian/rules
index 905d95b..9304487 100755
--- a/debian/rules
+++ b/debian/rules
@@ -117,6 +117,9 @@ install: build-stamp install-prep
 	# so override it at install.
 	$(MAKE) DESTDIR=`pwd`/debian/tmp includeexecdir=/usr/include/$(DEB_HOST_MULTIARCH) -C build install
 
+	# Replace embedded build path with a placeholder string
+	sed -i -e "s,$(CURDIR),BUILDPATH,g" debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/gmp.h
+
 	dh_install -plibgmp10 usr/lib/*/libgmp.so.*
 	dh_install -plibgmpxx4ldbl usr/lib/*/libgmpxx.so.*
 
-- 
2.35.2

Attachment: signature.asc
Description: PGP signature

Reply via email to