Source: glibc
Version: 2.31-12
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

Hi Aurelien et al,

while we do cross build glibc stage2 during architecture bootstrap with
some hacks, I've never really attempted cross building it in a pristine
build environment. Now the need has arisen and I've figured that it
doesn't work. There are three distinct problems.

The binutils dependency is interpreted as a host architecture
dependency. Unfortunately, host binutils are neither runnable nor
coinstallable with build-essential. What you really want here is
binutils for the host architecture. This problem is known as "toolchain
dependency translation". We devised a number of possible solution and
ultimately settled on my crazy one back then in 2014 in Paris. The rough
idea is to suffix build tools with -for-build or -for-host and let those
packages magically do the right thing. Fortunately, this actually works
for binutils already.

Nextup is g++-10. The problem is equal to binutils. Unfortunately, we've
not fully implemented the devised solution here yet. We've got patches
for gcc-N and for gcc-defaults, but more review and testing is needed
before those can be uploaded to unstable. In the mean time, the linux
maintainers figured a clever workaround. Instead of $tool, they write
something slightly longer:

    $tool <!cross>,
    $tool-$gnutriplet1 [arch1] <cross>,
    $tool-$gnutriplet2 [arch2] <cross>,
    $tool-gnutriplet3 [arch3] <cross>,
    ...

Yes, this is slightly longish and a little bit ugly. The upshot is that
it works today. Can you bear this temporarily?

Nextup, malloc/Makefile says that the check for libgd does not work for
cross compilation and skips building memusageat. debhelper then
complains when it is missing. In fact, the libgd check does work just
fine during cross builds and the hack can be removed.

So here you have a patch that makes glibc cross buildable to arm64
without any fuss.

Do note that I did not touch the multilib dependency. Cross building for
e.g. amd64 requires adding the nobiarch profile. I think this is a fair
compromise for now.

Helmut
diff --minimal -Nru glibc-2.31/debian/changelog glibc-2.31/debian/changelog
--- glibc-2.31/debian/changelog 2021-05-01 22:56:06.000000000 +0200
+++ glibc-2.31/debian/changelog 2021-06-18 14:40:52.000000000 +0200
@@ -1,3 +1,13 @@
+glibc (2.31-12.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Annotate binutils dependency with -for-host.
+    + Use suffixed cross compilers until there is -for-host.
+    + cross.patch: LIBGD detection actually works.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 18 Jun 2021 14:40:52 +0200
+
 glibc (2.31-12) unstable; urgency=medium
 
   * debian/po/de.po: fix encoding declaration.  Closes: #986450.
diff --minimal -Nru glibc-2.31/debian/control glibc-2.31/debian/control
--- glibc-2.31/debian/control   2021-01-05 06:41:20.000000000 +0100
+++ glibc-2.31/debian/control   2021-06-18 14:30:58.000000000 +0200
@@ -8,10 +8,11 @@
  mig-for-host (>= 1.5-3) [hurd-i386], gnumach-dev (>= 2:1.8+git20200710-2~) 
[hurd-i386],
  hurd-dev (>= 1:0.9.git20201127-4~) [hurd-i386] | hurd-headers-dev [hurd-i386],
  kfreebsd-kernel-headers [kfreebsd-any],
- binutils (>= 2.29),
- g++-10, g++-10-multilib [amd64 i386 kfreebsd-amd64 mips mipsel mipsn32 
mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 
mips64r6el powerpc ppc64 s390x sparc sparc64 x32] <!nobiarch>,
- gcc-10 (>= 10-20200431) [arm64],
- gcc-10 (>= 10.1.0-3) [hurd-i386],
+ binutils-for-host (>= 2.29),
+ g++-10 <!cross>, g++-10-multilib [amd64 i386 kfreebsd-amd64 mips mipsel 
mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el 
mips64r6 mips64r6el powerpc ppc64 s390x sparc sparc64 x32] <!nobiarch>,
+ g++-10-x86-64-kfreebsd-gnu [kfreebsd-amd64] <cross>, g++-10-i686-kfreebsd-gnu 
[kfreebsd-i386] <cross>, g++-10-x86-64-kfreebsd-gnu [kfreebsd-amd64] <cross>, 
g++-10-i686-kfreebsd-gnu [kfreebsd-i386] <cross>, g++-10-x86-64-linux-gnu 
[amd64] <cross>, g++-10-aarch64-linux-gnu [arm64] <cross>, 
g++-10-arm-linux-gnueabi [armel] <cross>, g++-10-arm-linux-gnueabihf [armhf] 
<cross>, g++-10-hppa-linux-gnu [hppa] <cross>, g++-10-i686-linux-gnu [i386] 
<cross>, g++-10-m68k-linux-gnu [m68k] <cross>, g++-10-mips-linux-gnu [mips] 
<cross>, g++-10-mipsel-linux-gnu [mipsel] <cross>, 
g++-10-mips64-linux-gnuabin32 [mipsn32] <cross>, 
g++-10-mips64el-linux-gnuabin32 [mipsn32el] <cross>, 
g++-10-mips64-linux-gnuabi64 [mips64] <cross>, g++-10-mips64el-linux-gnuabi64 
[mips64el] <cross>, g++-10-mipsisa32r6-linux-gnu [mipsr6] <cross>, 
g++-10-mipsisa32r6el-linux-gnu [mipsr6el] <cross>, 
g++-10-mipsisa64r6-linux-gnuabin32 [mipsn32r6] <cross>, 
g++-10-mipsisa64r6el-linux-gnuabin32 [mipsn32r6el] <cross>, 
g++-10-mipsisa64r6-linux-gnuabi64 [mips64r6] <cross>, 
g++-10-mipsisa64r6el-linux-gnuabi64 [mips64r6el] <cross>, 
g++-10-nios2-linux-gnu [nios2] <cross>, g++-10-powerpc-linux-gnu [powerpc] 
<cross>, g++-10-powerpc64-linux-gnu [ppc64] <cross>, 
g++-10-powerpc64le-linux-gnu [ppc64el] <cross>, g++-10-riscv64-linux-gnu 
[riscv64] <cross>, g++-10-sparc-linux-gnu [sparc] <cross>, 
g++-10-sparc64-linux-gnu [sparc64] <cross>, g++-10-s390x-linux-gnu [s390x] 
<cross>, g++-10-sh3-linux-gnu [sh3] <cross>, g++-10-sh4-linux-gnu [sh4] 
<cross>, g++-10-x86-64-linux-gnux32 [x32] <cross>, g++-10-alpha-linux-gnu 
[alpha] <cross>, g++-10-ia64-linux-gnu [ia64] <cross>,
+ gcc-10 (>= 10-20200431) [arm64] <!cross>, gcc-10-aarch64-linux-gnu (>= 
10-20200431) [arm64] <cross>,
+ gcc-10 (>= 10.1.0-3) [hurd-i386], gcc-10-i686-gnu (>= 10.1.0-3) [hurd-i386] 
<cross>,
  python3:native,
  libidn2-0 (>= 2.0.5~) <!nocheck>,
  libc-bin (>= 2.31) <cross>,
diff --minimal -Nru glibc-2.31/debian/control.in/main 
glibc-2.31/debian/control.in/main
--- glibc-2.31/debian/control.in/main   2021-01-03 17:11:31.000000000 +0100
+++ glibc-2.31/debian/control.in/main   2021-06-18 14:25:32.000000000 +0200
@@ -8,10 +8,11 @@
  mig-for-host (>= 1.5-3) [hurd-i386], gnumach-dev (>= 2:1.8+git20200710-2~) 
[hurd-i386],
  hurd-dev (>= 1:0.9.git20201127-4~) [hurd-i386] | hurd-headers-dev [hurd-i386],
  kfreebsd-kernel-headers [kfreebsd-any],
- binutils (>= 2.29),
- g++-10, g++-10-multilib [amd64 i386 kfreebsd-amd64 mips mipsel mipsn32 
mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 
mips64r6el powerpc ppc64 s390x sparc sparc64 x32] <!nobiarch>,
- gcc-10 (>= 10-20200431) [arm64],
- gcc-10 (>= 10.1.0-3) [hurd-i386],
+ binutils-for-host (>= 2.29),
+ g++-10 <!cross>, g++-10-multilib [amd64 i386 kfreebsd-amd64 mips mipsel 
mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el 
mips64r6 mips64r6el powerpc ppc64 s390x sparc sparc64 x32] <!nobiarch>,
+ @GPP_CROSS_DEP@
+ gcc-10 (>= 10-20200431) [arm64] <!cross>, gcc-10-aarch64-linux-gnu (>= 
10-20200431) [arm64] <cross>,
+ gcc-10 (>= 10.1.0-3) [hurd-i386], gcc-10-i686-gnu (>= 10.1.0-3) [hurd-i386] 
<cross>,
  python3:native,
  libidn2-0 (>= 2.0.5~) <!nocheck>,
  libc-bin (>= @GLIBC_VERSION@) <cross>,
diff --minimal -Nru glibc-2.31/debian/patches/cross.patch 
glibc-2.31/debian/patches/cross.patch
--- glibc-2.31/debian/patches/cross.patch       1970-01-01 01:00:00.000000000 
+0100
+++ glibc-2.31/debian/patches/cross.patch       2021-06-18 14:40:52.000000000 
+0200
@@ -0,0 +1,21 @@
+--- glibc-2.31.orig/malloc/Makefile
++++ glibc-2.31/malloc/Makefile
+@@ -139,10 +139,6 @@
+ endif
+ endif
+ 
+-# Unless we get a test for the availability of libgd which also works
+-# for cross-compiling we disable the memusagestat generation in this
+-# situation.
+-ifneq ($(cross-compiling),yes)
+ # If the gd library is available we build the `memusagestat' program.
+ ifneq ($(LIBGD),no)
+ others: $(objpfx)memusage
+@@ -158,7 +154,6 @@
+ # is to presume that the standard system headers will be ok for this file.
+ $(objpfx)memusagestat.o: sysincludes = # nothing
+ endif
+-endif
+ 
+ # Another goal which can be used to override the configure decision.
+ .PHONY: do-memusagestat
diff --minimal -Nru glibc-2.31/debian/patches/series 
glibc-2.31/debian/patches/series
--- glibc-2.31/debian/patches/series    2021-04-25 18:19:34.000000000 +0200
+++ glibc-2.31/debian/patches/series    2021-06-18 14:40:52.000000000 +0200
@@ -168,3 +168,4 @@
 any/local-test-install.diff
 any/git-surplus-tls-accounting.diff
 any/git-ld.so-cache-endianness-markup.diff
+cross.patch
diff --minimal -Nru glibc-2.31/debian/rules.d/control.mk 
glibc-2.31/debian/rules.d/control.mk
--- glibc-2.31/debian/rules.d/control.mk        2020-04-16 14:41:39.000000000 
+0200
+++ glibc-2.31/debian/rules.d/control.mk        2021-06-18 14:30:54.000000000 
+0200
@@ -15,6 +15,9 @@
            -e "s%@libc-dev-conflict@%$(foreach arch,$(filter-out 
$*,$(libc_packages)),$(arch)-dev,)%g" \
            < $< > $@
 
+COMMA=,
+GPP_CROSS_DEP = $(foreach a,$(libc0_1_archs) $(libc0_1_archs) $(libc6_archs) 
$(libc6_1_archs),g++-10-$(shell dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE 
| tr _ -) [$(a)] <cross>$(COMMA))
+
 debian/control: $(stamp)control
 $(stamp)control: debian/rules.d/control.mk $(control_deps) 
debian/tests/control.in
 
@@ -43,7 +46,7 @@
        cat debian/control.in/kfreebsd-i386     >> $@T
        cat debian/control.in/x32               >> $@T
        cat debian/control.in/opt               >> $@T
-       sed -e 's%@libc@%$(libc)%g' -e 's%@GLIBC_VERSION@%$(GLIBC_VERSION)%g' < 
$@T > debian/control
+       sed -e 's%@libc@%$(libc)%g' -e 's%@GLIBC_VERSION@%$(GLIBC_VERSION)%g' 
-e 's%@GPP_CROSS_DEP@%$(GPP_CROSS_DEP)%g' < $@T > debian/control
        rm $@T
 
        # And generate the tests control file with the current GCC

Reply via email to