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 protected] [...] arm-linux-gnueabihf-gcc ../sysdeps/arm/aeabi_lcsts.c -c -std=gnu11 -fgnu89-inline -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0 -ftls-model=initial-exec -I../include -I/tmp/guix-build-glibc-2.30.drv-0/build/csu -I/tmp/guix-build-glibc-2.30.drv-0/build -I../sysdeps/unix/sysv/linux/arm -I../sysdeps/arm/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm/armv7/multiarch -I../sysdeps/arm/armv7 -I../sysdeps/arm/armv6t2 -I../sysdeps/arm/armv6 -I../sysdeps/arm/include -I../sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /gnu/store/qxiyl966akwfj44vkswams3db61r45m7-gcc-cross-arm-linux-gnueabihf-10.3.0-lib/lib/gcc/arm-linux-gnueabihf/10.3.0/include -isystem /gnu/store/qxiyl966akwfj44vkswams3db61r45m7-gcc-cross-arm-linux-gnueabihf-10.3.0-lib/lib/gcc/arm-linux-gnueabihf/10.3.0/include-fixed -isystem /gnu/store/k4lzn762cpwwznxc2gvcyidfjnx3yw7b-linux-libre-headers-5.10.35/include -D_LIBC_REENTRANT -include /tmp/guix-build-glibc-2.30.drv-0/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DTOP_NAMESPACE=glibc -o /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_lcsts.o -MD -MP -MF /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_lcsts.o.dt -MT /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_lcsts.o 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]; | ^~~~~~~~ arm-linux-gnueabihf-gcc ../sysdeps/arm/aeabi_sighandlers.S -c -I../include -I/tmp/guix-build-glibc-2.30.drv-0/build/csu -I/tmp/guix-build-glibc-2.30.drv-0/build -I../sysdeps/unix/sysv/linux/arm -I../sysdeps/arm/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm/armv7/multiarch -I../sysdeps/arm/armv7 -I../sysdeps/arm/armv6t2 -I../sysdeps/arm/armv6 -I../sysdeps/arm/include -I../sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /gnu/store/qxiyl966akwfj44vkswams3db61r45m7-gcc-cross-arm-linux-gnueabihf-10.3.0-lib/lib/gcc/arm-linux-gnueabihf/10.3.0/include -isystem /gnu/store/qxiyl966akwfj44vkswams3db61r45m7-gcc-cross-arm-linux-gnueabihf-10.3.0-lib/lib/gcc/arm-linux-gnueabihf/10.3.0/include-fixed -isystem /gnu/store/k4lzn762cpwwznxc2gvcyidfjnx3yw7b-linux-libre-headers-5.10.35/include -D_LIBC_REENTRANT -include /tmp/guix-build-glibc-2.30.drv-0/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DTOP_NAMESPACE=glibc -DASSEMBLER -I/tmp/guix-build-glibc-2.30.drv-0/build/csu/. -g -Werror=undef -Wa,--noexecstack -o /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_sighandlers.o -MD -MP -MF /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_sighandlers.o.dt -MT /tmp/guix-build-glibc-2.30.drv-0/build/csu/aeabi_sighandlers.o 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
