Source: gnu-efi
Version: 3.0.18-1
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: cross-satisfiability ftcbfs

Hi,

gnu-efi can be cross built for arm architectures. Thank you for taking
care of that. Building it for x86 architectures does not work and the
immediate issue is the reliance on gcc-multilib. The support for
multilib in cross toolchains is near absent, so only real solution I can
offer here is not using multilib. The alternative to multilib is using a
cross toolchain and that happens to just work even in native builds. In
effect, a multilib build kinda is a crippled cross build and we can
expand it into a regular cross build without much effort.

I've turned this idea into a patch that you find attached. It
significantly changes debian/rules as I also encountered build/host
confusion. You already noticed that upstream uses these terms with a
meaning that differs from Debian's and still some occasions were using
it wrongly. I performed the following test builds with success:
 * native amd64
 * amd64 -> i386 cross build
 * amd64 -> arm64 cross build

The first two exercise previously used multilib and now work without.

Hope you find the proposed changes acceptable. Let me know if you have
any questions.

Helmut
diff --minimal -Nru gnu-efi-3.0.18/debian/changelog 
gnu-efi-3.0.18/debian/changelog
--- gnu-efi-3.0.18/debian/changelog     2024-03-25 20:50:29.000000000 +0100
+++ gnu-efi-3.0.18/debian/changelog     2024-12-21 11:26:48.000000000 +0100
@@ -1,3 +1,14 @@
+gnu-efi (3.0.18-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Use cross toolchains instead of gcc-multilib.
+    + Fix build/host confusion.
+    + Use dpkg's architecture.mk and buildtools.mk.
+    + Pass more overrides to make.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 21 Dec 2024 11:26:48 +0100
+
 gnu-efi (3.0.18-1) unstable; urgency=medium
 
   * Strip LDFLAGS before passing to the build
diff --minimal -Nru gnu-efi-3.0.18/debian/control gnu-efi-3.0.18/debian/control
--- gnu-efi-3.0.18/debian/control       2024-03-25 20:50:29.000000000 +0100
+++ gnu-efi-3.0.18/debian/control       2024-12-21 11:26:48.000000000 +0100
@@ -5,7 +5,9 @@
 Uploaders: Julian Andres Klode <j...@debian.org>, Mario Limonciello 
<supe...@gmail.com>
 Build-Depends:
  debhelper-compat (= 12),
- gcc-multilib [any-amd64 i386],
+ gcc-i686-linux-gnu [any-linux-amd64],
+ gcc-i686-gnu [any-hurd-amd64],
+ gcc-x86-64-linux-gnu [i386],
 Standards-Version: 4.1.1
 Vcs-Git: https://salsa.debian.org/efi-team/gnu-efi.git
 Vcs-Browser: https://salsa.debian.org/efi-team/gnu-efi
diff --minimal -Nru gnu-efi-3.0.18/debian/rules gnu-efi-3.0.18/debian/rules
--- gnu-efi-3.0.18/debian/rules 2024-03-25 20:50:29.000000000 +0100
+++ gnu-efi-3.0.18/debian/rules 2024-12-21 11:26:48.000000000 +0100
@@ -1,11 +1,7 @@
 #!/usr/bin/make -f
 
 include /usr/share/dpkg/architecture.mk
-
-# Cross building support
-ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
-export CROSS_COMPILE = $(DEB_HOST_GNU_TYPE)-
-endif
+include /usr/share/dpkg/buildtools.mk
 
 # The architecture we are building on
 ifeq (i386,$(DEB_BUILD_ARCH_CPU))
@@ -16,42 +12,63 @@
        BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
 endif
 
+MAKE_OVERRIDES := \
+       PREFIX=/usr \
+       'HOSTCC=$(CC_FOR_BUILD)' \
+       'HOSTARCH=$(BUILD_ARCH)' \
+       'INSTALLROOT=$(CURDIR)/debian/gnu-efi' \
+
+MAKE_OVERRIDES_MAIN := \
+       LIBDIR=/usr/lib \
+       'CC=$(CC)'
+MAKE_OVERRIDES_COMPAT :=
+
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+       MAKE_OVERRIDES_MAIN += 'CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-'
+endif
+
 # The architecture we are building for
-ifeq (i386,$(DEB_BUILD_ARCH_CPU))
-       HOST_ARCH := ia32
-       ifeq (linux,$(DEB_BUILD_ARCH_OS))
-               COMPAT_ARCH := x86_64
-               COMPAT_APPEND := 64
+ifeq (i386,$(DEB_HOST_ARCH_CPU))
+       MAKE_OVERRIDES_MAIN += HOST_ARCH=ia32
+       ifeq (linux,$(DEB_HOST_ARCH_OS))
+               MAKE_OVERRIDES_COMPAT += HOST_ARCH=x86_64
+               MAKE_OVERRIDES_COMPAT += LIBDIR=/usr/lib64
+               MAKE_OVERRIDES_COMPAT += 
'CROSS_COMPILE=x86_64-linux-$(DEB_HOST_ARCH_LIBC)-'
+       endif
+else ifeq (amd64,$(DEB_HOST_ARCH_CPU))
+       MAKE_OVERRIDES_MAIN += HOST_ARCH=x86_64
+       MAKE_OVERRIDES_COMPAT += HOST_ARCH=ia32
+       MAKE_OVERRIDES_COMPAT += LIBDIR=/usr/lib32
+       ifeq (hurd,$(DEB_HOST_ARCH_OS))
+               MAKE_OVERRIDES_COMPAT += 
'CROSS_COMPILE=i686-$(DEB_HOST_ARCH_LIBC)-'
+       else
+               MAKE_OVERRIDES_COMPAT += 
'CROSS_COMPILE=i686-$(DEB_HOST_ARCH_OS)-$(DEB_HOST_ARCH_LIBC)-'
        endif
-else ifeq (amd64,$(DEB_BUILD_ARCH_CPU))
-       HOST_ARCH := x86_64
-       COMPAT_ARCH := ia32
-       COMPAT_APPEND := 32
 else
        # ARM CPUs
-       HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
+       MAKE_OVERRIDES_MAIN += 'HOST_ARCH=$(DEB_HOST_GNU_CPU)'
 endif
 
 %:
        dh $@
 
 override_dh_auto_clean:
-       $(MAKE) clean ARCH=$(HOST_ARCH)
-ifneq (,$(COMPAT_ARCH))
-               $(MAKE) clean ARCH=$(COMPAT_ARCH) HOSTARCH=$(BUILD_ARCH)
+       $(MAKE) clean $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_MAIN)
+ifneq (,$(MAKE_OVERRIDES_COMPAT))
+               $(MAKE) clean $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_COMPAT)
 endif
 
 override_dh_auto_build:
        LDFLAGS="${LDFLAGS//-Wl/}" && LDFLAGS="${LDFLAGS//,/ }" && \
-       $(MAKE) ARCH=$(HOST_ARCH) PREFIX=/usr
-ifneq (,$(COMPAT_ARCH))
+       $(MAKE) $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_MAIN)
+ifneq (,$(MAKE_OVERRIDES_COMPAT))
                LDFLAGS="${LDFLAGS//-Wl/}" && LDFLAGS="${LDFLAGS//,/ }" && \
-               $(MAKE) ARCH=$(COMPAT_ARCH) HOSTARCH=$(BUILD_ARCH) PREFIX=/usr
+               $(MAKE) $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_COMPAT)
 endif
 
 # Fixme: This somehow rebuilds some parts
 override_dh_auto_install:
-       $(MAKE) install ARCH=$(HOST_ARCH) INSTALLROOT=$(CURDIR)/debian/gnu-efi 
PREFIX=/usr LIBDIR=/usr/lib
-ifneq (,$(COMPAT_ARCH))
-       $(MAKE) install ARCH=$(COMPAT_ARCH) HOSTARCH=$(BUILD_ARCH) 
INSTALLROOT=$(CURDIR)/debian/gnu-efi PREFIX=/usr LIBDIR=/usr/lib$(COMPAT_APPEND)
+       $(MAKE) install $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_MAIN)
+ifneq (,$(MAKE_OVERRIDES_COMPAT))
+       $(MAKE) install $(MAKE_OVERRIDES) $(MAKE_OVERRIDES_COMPAT)
 endif

Reply via email to