clang-toolchain > 6 refers to /lib on foreign distros

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Ludovic Courtès
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 7 Oct 2021 20:32
(address . bug-guix@gnu.org)
87wnmoadov.fsf@inria.fr
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’.
L
L
Ludovic Courtès wrote on 9 Oct 2021 10:51
(address . 51088@debbugs.gnu.org)(address . emmanuel.agullo@inria.fr)
87h7dq37jm.fsf@gnu.org
Hi,

Ludovic Courtès <ludovic.courtes@inria.fr> skribis:

Toggle quote (10 lines)
> clang-toolchain > 6 picks crt*.o from /lib or /lib64 on foreign
> distros. Here are runs on a CentOS machine:
>
> $ 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)

This is fixed by these commits:

b37fe44b7d gnu: clang@11, clang@12: Do not refer to /lib on foreign distros.
f1b4f46f0a gnu: clang@10: Do not refer to /lib on foreign distros.
46141bd372 gnu: clang@9: Do not refer to /lib on foreign distros.
66caab54b9 gnu: clang@7, clang@8: Do not refer to /lib on foreign distros.

The only remaining FHS thing that shows up in ‘strace c++ hello.cpp’ is:

stat("/lib/x86_64-linux-gnu", 0x7ffc3a4fc6d0) = -1 ENOENT (No such file or directory)

It’s harmless, coming from the somewhat comical ‘getMultiarchTriple’
function¹; excerpt:

case llvm::Triple::x86_64:
if (IsAndroid)
return "x86_64-linux-android";
// We don't want this for x32, otherwise it will match x86_64 libs
if (TargetEnvironment != llvm::Triple::GNUX32 &&
D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
return "x86_64-linux-gnu";
break;

:-)

Thanks,
Ludo’.

L
L
Ludovic Courtès wrote on 9 Oct 2021 10:51
control message for bug #51088
(address . control@debbugs.gnu.org)
87fsta37jf.fsf@gnu.org
close 51088
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 51088@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 51088
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch