Source: vboot-utils
Severity: normal
Tags: patch
User: [email protected]
Usertags: cpu
X-Debbugs-Cc: [email protected]

When building for i386 and running an amd64 kernel, the Makefile uses
"uname -m" to determine the architecture, but this introduces variations
depending on the kernel used to perform the build:

  44277         ./host/arch/x86/lib/crossystem_arch.c:161       44277   
./host/arch/x86_64/lib/crossystem_arch.c:161

See also:

  
https://tests.reproducible-builds.org/debian/rb-pkg/bullseye/i386/diffoscope-results/vboot-utils.html
  
https://tests.reproducible-builds.org/debian/issues/unstable/captures_build_arch_issue.html

While this is often worked around in chroots by running with a "linux32"
personality, using the running kernel is not the correct way to
determine the architecture.

The attached patch fixes this by passing the debian architecture via
debian/rules, and patching the Makefile to treat i386 as x86.

An alternate fix might be to determine the architecture from the
compiler or other userspace utility that is independent from the kernel,
which might be more appropriate to submit upstream.

Thanks for maintaining vboot-utils!

live well,
  vagrant
From 1ab1bb1754501761cbe89196f55a7c557ab6c937 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Sun, 15 Nov 2020 18:32:37 +0000
Subject: [PATCH] debian/rules: Pass the Debian architecture as _machname from
 debian rules, and patch the Makefile to treat i386 as x86.

This is needed to ensure reproducible builds when the running kernel
and Debian architecture do not match, as uname may be misleading:

  https://tests.reproducible-builds.org/debian/issues/unstable/captures_build_arch_issue.html
---
 debian/patches/series            |  1 +
 debian/patches/treat-i386-as-x86 | 14 ++++++++++++++
 debian/rules                     |  1 +
 3 files changed, 16 insertions(+)
 create mode 100644 debian/patches/treat-i386-as-x86

diff --git a/debian/patches/series b/debian/patches/series
index c24a3d3..a5035b4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@
 dont-build-with-werror.patch
 add-missing-flags-pie.patch
 do-not-embed-user-and-time-in-version.patch
+treat-i386-as-x86
diff --git a/debian/patches/treat-i386-as-x86 b/debian/patches/treat-i386-as-x86
new file mode 100644
index 0000000..84c5c7f
--- /dev/null
+++ b/debian/patches/treat-i386-as-x86
@@ -0,0 +1,14 @@
+Index: vboot-utils/Makefile
+===================================================================
+--- vboot-utils.orig/Makefile
++++ vboot-utils/Makefile
+@@ -93,6 +93,9 @@ endif
+ ifneq (,$(findstring i686,${_machname}))
+ 	override _machname := x86
+ endif
++ifneq (,$(findstring i386,${_machname}))
++	override _machname := x86
++endif
+ HOST_ARCH ?= ${_machname}
+ 
+ # ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
diff --git a/debian/rules b/debian/rules
index dce9471..0e92bd6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,6 +2,7 @@
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 export CC = clang-10
+export _machname = $(DEB_HOST_ARCH)
 
 override_dh_auto_build:
 	dh_auto_build -- V=1
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

Reply via email to