Subject: bug#30395: ‘gcc’ doesn't compile with LD_LIBRARY_PATH="$HOME/.guix-profile/lib"

From: [email-masked] (Ludovic Courtès)
Date: Fri, 16 Feb 2018 17:43:23 +0100

Mathieu Lirzin <[email-masked]> skribis:

> After looking at the attached ‘strace’ log, as you initially guessed
> this issue is that multiple GCC are loaded.  My ‘gcc-toolchain’ is using
> GCC 7.3 and ‘glibc’ is referring to GCC 5.4.

Normally ‘glibc’ does not contain references to ‘gcc’:

--8<---------------cut here---------------start------------->8---
$ guix size /gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25
store item                                                       total    self
/gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25              38.5    37.1  96.3%
/gnu/store/zhrajv6qf2hzn9c3g2bb07559hyrz5xp-bash-static-4.4.12       1.4     1.4   3.7%
total: 38.5 MiB
--8<---------------cut here---------------end--------------->8---

> After removing ‘glibc’ and from my profile calling ‘gcc’ completes, so I
> don't need to install ‘binutils’ in my profile anymore.

I don’t get it yet.  The log shows this:

--8<---------------cut here---------------start------------->8---
9543  execve("/gnu/store/x7i79rihhdjkps5fx0f9p2q0svh5a88n-guile-2.2.2/bin/guile", ["/gnu/store/x7i79rihhdjkps5fx0f9p"..., "-c", "(load-compiled \"/gnu/store/w27in"..., "-plugin", "/gnu/store/xjpchnxm9fgg05fqm9apy"..., "-plugin-opt=/gnu/store/xjpchnxm9"..., "-plugin-opt=-fresolution=/tmp/cc"..., "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lc", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-dynamic-linker", "/gnu/store/3h31zsqxjjg52da5gp3qm"..., "/gnu/store/0qg64bwn2z3g91b5iw16i"..., "/gnu/store/0qg64bwn2z3g91b5iw16i"..., "/gnu/store/45rhjm5ryms10frcyrzcd"..., "-L/gnu/store/0qg64bwn2z3g91b5iw1"..., "-L/gnu/store/45rhjm5ryms10frcyrz"..., "-L/gnu/store/45rhjm5ryms10frcyrz"..., "-L/gnu/store/3h31zsqxjjg52da5gp3"..., "/tmp/cc9aj9M2.o", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-L/gnu/store/3h31zsqxjjg52da5gp3"..., "-rpath=/gnu/store/3h31zsqxjjg52d"..., ...], 0x113a520 /* 31 vars */) = 0

9543  open("/home/mthl/.guix-profile/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

9543  write(2, "Uncaught exception:\n", 20) = 20
9543  futex(0x7f5d453c6930, FUTEX_WAKE_PRIVATE, 2147483647) = 0
9543  futex(0x7f5d43ab0190, FUTEX_WAKE_PRIVATE, 2147483647) = 0
9543  close(3)                          = 0
9543  close(4)                          = 0
9543  munmap(0x7f5d455e8000, 4096)      = 0
9543  exit(0)                           = ?
9539  <... wait4 resumed> 0xcddb20, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
9539  --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
--8<---------------cut here---------------end--------------->8---

This is the execution of ld-wrapper and it terminates with “Uncaught
exception”, which isn’t really helpful.  Apparently this happens before
‘boot-9.scm’ was even search for.

Can you reproduce it by running ‘ld’ directly in that environment?  Or
better yet, by running ‘guile’?  The next thing is to try and do that in
gdb…

Ludo’.