Subject: bug#69394: cross-gcc-toolchain for riscv64 doesn't search crt1.o properly

From: Jean-Pierre De Jesus Diaz <[email-masked]>
Date: Thu, 29 Feb 2024 13:59:35 +0000

Hello Ekaitz,

This problem is also present for other targets such as AVR[1] as when
I introduced
the cross-gcc-toolchain procedure I didn't add the NATIVE-SEARCH-PATHS and
SEARCH-PATHS fields for the toolchains as:

1. SEARCH-PATHS doesn't quite work with shells right now, as it is
impossible to create
a profile with cross packages. E.g. trying to use
gcc-cross-avr-toolchain and unity
built for AVR. So it is a bit useless, unless the toolchain is used
inside of GNU Guix as
a NATIVE-INPUT, but STANDARD-CROSS-PACKAGES takes care of this in
GNU-BUILD-SYSTEM by adding cross-gcc and cross-libc as inputs.

2. The other solution is to use NATIVE-SEARCH-PATHS but when using
mixed toolchains
in a single environment all of the cross compilers will share this
environment variable.

For example:

guix shell gcc-cross-avr-toolchain gcc-cross-i686-w64-mingw32-toolchain

Would have the same CROSS_* environment variables and could mix things up.

Ideally one should have per target cross variables, like, CROSS_AVR_*
CROSS_I686_W64_MINGW32_*, but this is not done right now.

Another option is to wrap every binary of the toolchain and set the
CROSS_* variables
so that they can find the C standard library includes and binaries
without adding
search paths to avoid collisions with other toolchains for the moment and since
profiles don't support cross-packages yet I think it is a fair trade-off.

I think I could update https://issues.guix.gnu.org/68058 to use the
latter method.

[1]: https://www.reddit.com/r/GUIX/comments/18rj84f/arduino_avr_compilation_help/

-- 
Jean-Pierre De Jesus DIAZ
Foundation Devices, Inc.