(address . bug-guix@gnu.org)
clang-toolchain > 6 picks crt*.o from /lib or /lib64 on foreign
distros. Here are runs on a CentOS machine:
Toggle snippet (38 lines)
$ guix environment --pure --ad-hoc clang-toolchain@6 -- c++ hello.cpp
$ echo $?
0
$ guix environment --pure --ad-hoc clang-toolchain@7 -- c++ hello.cpp
ld: /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../../libstdc++.so: undefined reference to `__cxa_thread_atexit_impl@GLIBC_2.18'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
$ echo $?
1
$ guix environment --pure --ad-hoc clang-toolchain@12 -- c++ hello.cpp
ld: /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../../libstdc++.so: undefined reference to `__cxa_thread_atexit_impl@GLIBC_2.18'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
$ guix environment --pure --ad-hoc clang-toolchain@12 -- c++ -v hello.cpp
clang version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/bin
Found candidate GCC installation: /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0
Selected GCC installation: /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 10.0
"/gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/bin/clang-12" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/lib/clang/12.0.0 -c-isystem /gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/include -cxx-isystem /gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/include -internal-isystem /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++ -internal-isystem /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu -internal-isystem /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/backward -internal-isystem /usr/local/include -internal-isystem /gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/lib/clang/12.0.0/include -internal-externc-isystem /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include -fdeprecated-macro -fdebug-compilation-dir /home/courtes -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o /tmp/hello-7b344d.o -x c++ hello.cpp
clang -cc1 version 12.0.0 based upon LLVM 12.0.0 default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
/gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/include
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/backward
/usr/local/include
/gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/lib/clang/12.0.0/include
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include
End of search list.
"/gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker //gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 -o a.out /lib/../lib64/crt1.o /lib/../lib64/crti.o /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/crtbegin.o -L/gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0 -L/lib/../lib64 -L/gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../.. -L/gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/bin/../lib -L/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib -L/gnu/store/vgsb018grjlhhb2gjkb3gyfm5w7mx9mx-profile/lib /tmp/hello-7b344d.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/crtend.o /lib/../lib64/crtn.o
ld: /gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../../libstdc++.so: undefined reference to `__cxa_thread_atexit_impl@GLIBC_2.18'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
Notice ‘/lib/../lib64/crt1.o’ etc. above.
This suggests that ‘clang-11.0-libc-search-path.patch’ & co. aren’t
sufficient any longer.
‘strace’ shows that ‘c++’ goes through sequences like this one:
Toggle snippet (11 lines)
access("/gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/lib/clang/12.0.0/crt1.o", F_OK) = -1 ENOENT (No such f
ile or directory)
access("/gnu/store/nzfhh1rm85lx2p5plbx45qqj82pcv5hp-clang-runtime-12.0.0/lib/linux/crt1.o", F_OK) = -1 ENOENT (No such
file or directory)
access("/gnu/store/vn69pklab842xyig8d0c6xq6s9iyqhl0-clang-12.0.0/bin/../crt1.o", F_OK) = -1 ENOENT (No such file or dir
ectory)
access("/gnu/store/f0ca0lf64bw08srv1bj7gkg6ag0sbdb2-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/crt1.o", F_OK)
= -1 ENOENT (No such file or directory)
access("/lib/../lib64/crt1.o", F_OK) = 0
To be continued…
Ludo’.