Subject: cross-compilation doesn't honor gcc native input

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 13 Dec 2022 21:16:20 -0500

Hello Guix,

I've recently noticed that cross-compiling with a different GCC was not
possible by simply adding them as native inputs the same way we can
already do when compiling natively.

Here's an example in our package collection that fails to cross-compile
for that reason:

--8<---------------cut here---------------start------------->8---
$ guix build --target=arm-linux-gnueabihf --no-offload [email-masked]

[...]

In file included from ../sysdeps/arm/libc-tls.c:19:
../csu/libc-tls.c: In function ‘__libc_setup_tls’:
../csu/libc-tls.c:209:30: error: array subscript 1 is outside the bounds of an interior zero-length array ‘struct dtv_slotinfo[0]’ [-Werror=zero-length-bounds]
  209 |   static_slotinfo.si.slotinfo[1].map = main_map;
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from ../sysdeps/arm/ldsodefs.h:38,
                 from ../sysdeps/gnu/ldsodefs.h:46,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from ../sysdeps/unix/sysv/linux/arm/ldsodefs.h:22,
                 from ../csu/libc-tls.c:21,
                 from ../sysdeps/arm/libc-tls.c:19:
../sysdeps/generic/ldsodefs.h:406:7: note: while referencing ‘slotinfo’
  406 |     } slotinfo[0];
      |       ^~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [/tmp/guix-build-glibc-2.30.drv-0/build/sysd-rules:519: /tmp/guix-build-glibc-2.30.drv-0/build/csu/libc-tls.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/tmp/guix-build-glibc-2.30.drv-0/glibc-2.30/csu'
make[1]: *** [Makefile:259: csu/subdir_lib] Error 2
make[1]: Leaving directory '/tmp/guix-build-glibc-2.30.drv-0/glibc-2.30'
make: *** [Makefile:9: all] Error 2
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "make" arguments: ("-j" "4") exit-status: 2 term-signal: #f stop-signal: #f> 
phase `build' failed after 8.5 seconds
command "make" "-j" "4" failed with status 2
builder for `/gnu/store/cpabyq7ly2sf1jxxbn8srbqkd9chz9w1-glibc-2.30.drv' failed with exit code 1
build of /gnu/store/cpabyq7ly2sf1jxxbn8srbqkd9chz9w1-glibc-2.30.drv failed
--8<---------------cut here---------------end--------------->8---

-- 
Thanks,
Maxim