Source: gdb-mingw-w64
Version: 13
Severity: serious
Justification: fails to build from source (but built successfully in the past)
Tags: sid trixie ftbfs patch
User: debian-...@lists.debian.org
Usertags: arm64

Hi,

arm64 now has an architecture-specific flag among the default build
flags: -mbranch-protection=standard.

gdb-mingw-w64 calls dpkg-buildflags on the build system, which on arm64
looks like this:

$ dpkg-buildflags --get CFLAGS
-g -O2 -ffile-prefix-map=/tmp/gdb-mingw-w64-13=. -fstack-protector-strong 
-fstack-clash-protection -Wformat -Werror=format-security 
-mbranch-protection=standard

The output of the above command is then passed to the configure script
of the various targets (i686-w64-mingw32 and x86_64-w64-mingw32),
resulting in the following FTBFS on arm64:

 checking for i686-w64-mingw32-gcc... i686-w64-mingw32-gcc-posix
 checking whether the C compiler works... no
 configure: error: in 
`/tmp/gdb-mingw-w64-13/build-gdbserver/i686-w64-mingw32/gnulib':
 configure: error: C compiler cannot create executables
 See `config.log' for more details

And indeed config.log points out the issue:

 i686-w64-mingw32-gcc-posix: error: unrecognized command-line option 
'-mbranch-protection=standard'

I propose in the attached patch to use DEB_HOST_ARCH and ensure that
i686-specific flags are used when building for i686, ditto for amd64.

  Emanuele
diff -Nru gdb-mingw-w64-13/debian/changelog gdb-mingw-w64-13+nmu1/debian/changelog
--- gdb-mingw-w64-13/debian/changelog	2023-09-29 17:54:37.000000000 +0200
+++ gdb-mingw-w64-13+nmu1/debian/changelog	2024-02-06 20:23:38.000000000 +0100
@@ -1,3 +1,11 @@
+gdb-mingw-w64 (13+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Use DEB_HOST_ARCH to avoid setting potentially arch-specific build flags.
+    Closes: -1.
+
+ -- Emanuele Rocca <e...@debian.org>  Tue, 06 Feb 2024 20:23:38 +0100
+
 gdb-mingw-w64 (13) unstable; urgency=medium
 
   * Switch from the obsolete libncurses5-dev build-dependency to
diff -Nru gdb-mingw-w64-13/debian/rules gdb-mingw-w64-13+nmu1/debian/rules
--- gdb-mingw-w64-13/debian/rules	2023-09-29 13:47:46.000000000 +0200
+++ gdb-mingw-w64-13+nmu1/debian/rules	2024-02-06 20:23:38.000000000 +0100
@@ -69,6 +69,7 @@
 override_dh_auto_configure-arch: unpack-stamp
 	set -e; \
 	for target in $(targets); do \
+		host_arch=$(shell echo $target | grep -q ^i686 && echo i686 || echo amd64); \
 		mkdir -p $(build_gdb_dir)/$$target; \
 		cd $(build_gdb_dir)/$$target; \
 		$(upstream_dir)/configure \
@@ -77,7 +78,7 @@
 			--with-system-readline --with-system-zlib \
 			--enable-tui --with-expat --with-python=python3 \
 			--target=$$target --disable-werror \
-			$(shell $(dpkg_buildflags_arch) --export=cmdline); \
+			$(shell DEB_HOST_ARCH=$host_arch $(dpkg_buildflags_arch) --export=cmdline); \
 	done
 
 # We're only interested in gdbserver; that also requires gnulib, libiberty, and gdbsupport
@@ -85,6 +86,7 @@
 override_dh_auto_configure-indep: unpack-stamp
 	set -e; \
 	for target in $(targets); do \
+		host_arch=$(shell echo $target | grep -q ^i686 && echo i686 || echo amd64); \
 		for project in $(gdbserver_projects); do \
 			mkdir -p $(build_gdbserver_dir)/$$target/$$project; \
 			cd $(build_gdbserver_dir)/$$target/$$project; \
@@ -93,22 +95,24 @@
 				--host=$$target --target=$$target \
 				CC=$$target-gcc-posix CXX=$$target-g++-posix \
 				--disable-werror \
-				$(shell $(dpkg_buildflags_indep) --export=cmdline); \
+				$(shell DEB_HOST_ARCH=$host_arch $(dpkg_buildflags_indep) --export=cmdline); \
 		done; \
 	done
 
 override_dh_auto_build-arch:
 	set -e; \
 	for target in $(targets); do \
-		$(shell $(dpkg_buildflags_arch) --export=sh); \
+		host_arch=$(shell echo $target | grep -q ^i686 && echo i686 || echo amd64); \
+		$(shell DEB_HOST_ARCH=$host_arch $(dpkg_buildflags_arch) --export=sh); \
 		dh_auto_build --parallel -B$(build_gdb_dir)/$$target -- V=1; \
 	done
 
 override_dh_auto_build-indep:
 	set -e; \
 	for target in $(targets); do \
+		host_arch=$(shell echo $target | grep -q ^i686 && echo i686 || echo amd64); \
 		for project in $(gdbserver_projects); do \
-			$(shell $(dpkg_buildflags_indep) --export=sh); \
+			$(shell DEB_HOST_ARCH=$host_arch $(dpkg_buildflags_indep) --export=sh); \
 			dh_auto_build --parallel -B$(build_gdbserver_dir)/$$target/$$project -- V=1; \
 		done; \
 	done

Reply via email to