bug#69394: cross-gcc-toolchain for riscv64 doesn't search crt1.o properly
Hello Jean-Pierre, Today I ran into the issue reported in this bug with a custom toolchain package for aarch64-linux-gnu. I applied your patch from issue 68058 and that solved the problem! Thank you very much for your insights and proposed solutions. A couple of comments below: Jean-Pierre De Jesus Diaz via Bug reports for GNU Guix writes: > 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. That would be awesome. If I understand correctly what you wrote, as things stand today many cross toolchains are unusable because of this problem (but not all? IIUC bare-metal cross toolchains aren't affected because they don't use crt*.o files, right?) So even your patch as it is currently proposed in issue 68058 would be an improvement over the status quo. IMHO, supporting more than one cross toolchain installed in the same profile would be interesting (I for one would find it useful to have both aarch64-linux-gnu and arm-linux-gnueabihf cross toolchains installed at the same time) but even if that is not possible yet, supporting just one cross toolchain installed in a profile would be an important improvement. :-) All this to say: unless there are other downsides to the patch in 68058, I think it should be committed. -- Thiago
bug#69394: cross-gcc-toolchain for riscv64 doesn't search crt1.o properly
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.
bug#69394: cross-gcc-toolchain for riscv64 doesn't search crt1.o properly
Hi, I made this package: ``` (define-module (cross) #:use-module (guix packages) #:use-module (guix gexp) #:use-module (gnu packages cross-base)) (define-public gcc-cross-riscv64-linux-gnu-toolchain (cross-gcc-toolchain "riscv64-linux-gnu")) ``` And used in in the session you can read in the bottom of this email. During the session, the `crt1.o` file is not found, and the `riscv64-linux-gnu-gcc -v whatever.c` call shows `crt1.o` is passed to the compiler using only the name, while in `gcc-toolchain` it's passed using the full path to the libc. This looks like the `cross-gcc-toolchain` is missing some configuration for proper usage in a guix shell. Best, Ekaitz The session I that explains the behavior: ``` # Using gcc-toolchain here `crt1.o` is found: Ekaitz@tuxedo ~/projects/nlnet/gzip-1.2.4$ guix shell gcc-toolchain Ekaitz@tuxedo ~/projects/nlnet/gzip-1.2.4 [env]$ gcc -v deflate.c Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/cc1 -quiet -v deflate.c -quiet -dumpdir a- -dumpbase deflate.c -dumpbase-ext .c -mtune=generic -march=x86-64 -version -o /tmp/ccffA64a.s GNU C17 (GCC) version 13.2.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 13.2.0, GMP version 6.2.1, MPFR version 4.2.0, MPC version 1.3.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/no-gcc-local-prefix/include" ignoring nonexistent directory "/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /gnu/store/0pr5ryw11f7pg5nhn42616k17ahdnily-profile/include /gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include /gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include-fixed /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/include End of search list. Compiler executable checksum: cd54e13587d35c4cb99945e5484c0675 COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' as -v --64 -o /tmp/cciGP5tQ.o /tmp/ccffA64a.s GNU assembler version 2.38 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.38 COMPILER_PATH=/gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/:/gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/:/gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/:/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/:/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/gnu/store/0pr5ryw11f7pg5nhn42616k17ahdnily-profile/lib/:/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/:/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../:/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.' /gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/collect2 -plugin /gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/liblto_plugin.so -plugin-opt=/gnu/store/vjjk375kysja1jz0837lypd09rdgs47c-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccdr9flx.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/ld-linux-x86-64.so.2 /gnu/store/0pr5ryw11f7pg5nhn42616k17ahdnily-profile/lib/crt1.o /gnu/store/0pr5ryw11f7pg5nhn42616k17ahdnily-profile/lib/crti.o /gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/crtbegin.o -L/gnu/store/0pr5ryw11f7pg5nhn42616k17ahdnily-profile/lib -L/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0 -L/gnu/store/m57d52krll9vlzmc0cqfg6dwn7n0p52j-gcc-13.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../.. -L/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib