[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1086729: efivar FTCBFS: multiple reasons



Source: efivar
Version: 38-3.1
Tags: patch
User: debian-cross@lists.debian.org
Usertags: ftcbfs

efivar fails to cross build from source for multiple, subtle reasons. It
basically has cross compilation support, but its use of variables is
very much unlike what dh_auto_build passes:
 * The CC is expected to come without an architecture prefix as it wants
   to prepend $(CROSS_COMPILE).
 * What dpkg calls CC_FOR_BUILD is called HOSTCC.
 * What dpkg calls CFLAGS_FOR_BUILD is called HOST_CFLAGS.

Beyond this, the upstream attempts to link util.o into both build
architecture and host architecture binaries. That doesn't work. Thus I
propose to rename "host" (in efivars terms, "build" in Debian terms)
objects to %.host.o to distinguish them from "normal" (untermed in
efivars, "host" in Debian terms) objects.

I agree that this is all very confusing, but I'm offering a working
patch for your convenience.

Helmut
diff --minimal -Nru efivar-38/debian/changelog efivar-38/debian/changelog
--- efivar-38/debian/changelog	2024-02-28 03:57:40.000000000 +0100
+++ efivar-38/debian/changelog	2024-11-04 15:35:27.000000000 +0100
@@ -1,3 +1,12 @@
+efivar (38-3.2) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Pass the right variables to make.
+    + cross.patch: Use different names for build and host objects.
+
+ -- Helmut Grohne <helmut@subdivi.de>  Mon, 04 Nov 2024 15:35:27 +0100
+
 efivar (38-3.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --minimal -Nru efivar-38/debian/patches/cross.patch efivar-38/debian/patches/cross.patch
--- efivar-38/debian/patches/cross.patch	1970-01-01 01:00:00.000000000 +0100
+++ efivar-38/debian/patches/cross.patch	2024-11-04 15:35:27.000000000 +0100
@@ -0,0 +1,32 @@
+--- efivar-38.orig/src/Makefile
++++ efivar-38/src/Makefile
+@@ -29,7 +29,7 @@
+ EFISECDB_OBJECTS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(EFISECDB_SOURCES)))
+ GENERATED_SOURCES = include/efivar/efivar-guids.h guid-symbols.c
+ MAKEGUIDS_SOURCES = makeguids.c util.c
+-MAKEGUIDS_OBJECTS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(MAKEGUIDS_SOURCES)))
++MAKEGUIDS_OBJECTS = $(patsubst %.S,%.host.o,$(patsubst %.c,%.host.o,$(MAKEGUIDS_SOURCES)))
+ MAKEGUIDS_OUTPUT = $(GENERATED_SOURCES) guids.lds
+ 
+ ALL_SOURCES=$(LIBEFISEC_SOURCES) $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) \
+--- efivar-38.orig/src/include/rules.mk
++++ efivar-38/src/include/rules.mk
+@@ -58,12 +58,18 @@
+ %.static.o : %.c
+ 	$(CC) $(CFLAGS) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
+ 
++%.host.o : %.c
++	$(HOSTCC) $(HOST_CFLAGS) -fPIE $(HOST_CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
++
+ %.o : %.S
+ 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
+ 
+ %.static.o : %.S
+ 	$(CC) $(CFLAGS) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
+ 
++%.host.o : %.c
++	$(HOSTCC) $(HOST_CFLAGS) -fPIE $(HOST_CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
++
+ %.S: %.c
+ 	$(CC) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
+ 
diff --minimal -Nru efivar-38/debian/patches/series efivar-38/debian/patches/series
--- efivar-38/debian/patches/series	2023-11-29 15:23:32.000000000 +0100
+++ efivar-38/debian/patches/series	2024-11-04 15:35:27.000000000 +0100
@@ -1,2 +1,3 @@
 0001-linux-handle-non-ACPI-systems-in-device_get.patch
 0002_no_host_march.patch
+cross.patch
diff --minimal -Nru efivar-38/debian/rules efivar-38/debian/rules
--- efivar-38/debian/rules	2023-11-01 01:40:55.000000000 +0100
+++ efivar-38/debian/rules	2024-11-04 15:35:27.000000000 +0100
@@ -5,6 +5,7 @@
 #export DH_OPTIONS=-V
 
 include /usr/share/dpkg/default.mk
+include /usr/share/dpkg/buildtools.mk
 
 ifeq ($(DEB_HOST_ARCH),amd64)
 export DEB_CFLAGS_MAINT_APPEND+= -fcf-protection
@@ -14,11 +15,24 @@
 %:
 	dh $@
 
+BUILD_SETTINGS := 'LIBDIR=$${PREFIX}/lib/$(DEB_HOST_MULTIARCH)'
+ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+BUILD_SETTINGS += 'CC=$(CC)'
+else
+# Note that the build system overrides CC and prepends $(CROSS_COMPILE).
+BUILD_SETTINGS += \
+	'CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-' \
+	'CC=$(subst $(DEB_HOST_GNU_TYPE)-,,$(CC))'
+endif
+BUILD_SETTINGS += \
+	'HOSTCC=$(CC_FOR_BUILD)' \
+	'HOST_CFLAGS=$(CFLAGS_FOR_BUILD)'
+
 override_dh_auto_build:
-	dh_auto_build -- LIBDIR=\$${PREFIX}/lib/$(DEB_HOST_MULTIARCH) CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+	dh_auto_build -- $(BUILD_SETTINGS)
 
 override_dh_auto_install:
-	dh_auto_install -- LIBDIR=\$${PREFIX}/lib/$(DEB_HOST_MULTIARCH)
+	dh_auto_install -- $(BUILD_SETTINGS)
 
 override_dh_auto_test:
 	dh_auto_test -- GRUB_PREFIX=grub

Reply to: