guix/gnu
Leo Nikkilä 556a8cd6f9
gnu: gcc-4.7: Fix slash in startfile prefix.
These prefixes must have a trailing slash.[0] When this slash is
omitted, gcc fails to find ?crt*.o files when LIBRARY_PATH is not set:

    $ uname -a
    Linux guix 6.10.14-gnu #1 SMP PREEMPT_DYNAMIC 1 aarch64 GNU/Linux
    $ guix shell --pure gcc-toolchain -- /bin/sh -c 'LIBRARY_PATH= gcc hello.c'
    ld: cannot find crt1.o: No such file or directory
    ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status

I ran into this when building Yocto images in Guix containers, where
bitbake resets the environment and expects an FHS system.

Looking at `-print-search-dirs', the prefix is definitely present at the
end of the startfiles prefixes list[1]:

    $ guix shell --pure gcc-toolchain -- /bin/sh -c 'LIBRARY_PATH= gcc -print-search-dirs'
    <...>
    libraries: <...>:/gnu/store/3gvs8sw95ldfypr1n688svl5brwdmdi9-glibc-2.39/lib

However, looking closer with strace, gcc is trying to find crt1.o at
`/lib../lib/crt1.o' and `/libcrt1.o', which are paths that have been
mangled due to the missing slash:

    $ guix shell --pure gcc-toolchain strace -- /bin/sh -c 'LIBRARY_PATH= strace -e trace=file gcc hello.c' 2>&1 | grep /gnu/store/3gvs8sw95ldfypr1n688svl5brwdmdi9-glibc-2.39/lib
    <...>
    faccessat(AT_FDCWD, "/gnu/store/3gvs8sw95ldfypr1n688svl5brwdmdi9-glibc-2.39/lib../lib/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    faccessat(AT_FDCWD, "/gnu/store/3gvs8sw95ldfypr1n688svl5brwdmdi9-glibc-2.39/libcrt1.o", R_OK) = -1 ENOENT (No such file or directory)
    <...>

[0]: <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=92c92996401005a9ad17fecd1af4385833785cec;hb=HEAD#l1610>
[1]: <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=92c92996401005a9ad17fecd1af4385833785cec;hb=HEAD#l8604>

* gnu/packages/gcc.scm (gcc-4.7): Fix replaced startfile prefix.
[arguments]: <#:phases>: Fix it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-01-16 23:32:14 +01:00
..
bootloader
build
home
installer
machine
packages gnu: gcc-4.7: Fix slash in startfile prefix. 2025-01-16 23:32:14 +01:00
services gnu: xfce: Enable xfce4-screensaver. 2025-01-12 14:18:03 +08:00
system
tests services: rootless-podman: Enable I/O delegation. 2025-01-11 23:36:58 +01:00
artwork.scm
bootloader.scm
ci.scm
compression.scm
home.scm
image.scm
installer.scm
local.mk gnu: Add gettext-minimal-0.21. 2025-01-12 16:18:59 +01:00
machine.scm
packages.scm
services.scm
system.scm
tests.scm tests: Run without the Linux kernel “quiet” argument. 2025-01-08 22:54:38 +01:00