unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51088: clang-toolchain > 6 refers to /lib on foreign distros
@ 2021-10-07 18:32 Ludovic Courtès
  2021-10-09  8:51 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ludovic Courtès @ 2021-10-07 18:32 UTC (permalink / raw)
  To: 51088; +Cc: emmanuel.agullo

clang-toolchain > 6 picks crt*.o from /lib or /lib64 on foreign
distros.  Here are runs on a CentOS machine:

--8<---------------cut here---------------start------------->8---
$ 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)
--8<---------------cut here---------------end--------------->8---

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:

--8<---------------cut here---------------start------------->8---
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
--8<---------------cut here---------------end--------------->8---

To be continued…

Ludo’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#51088: clang-toolchain > 6 refers to /lib on foreign distros
  2021-10-07 18:32 bug#51088: clang-toolchain > 6 refers to /lib on foreign distros Ludovic Courtès
@ 2021-10-09  8:51 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2021-10-09  8:51 UTC (permalink / raw)
  To: 51088; +Cc: emmanuel.agullo

Hi,

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

> 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’.

¹ https://github.com/llvm/llvm-project/blob/release/12.x/clang/lib/Driver/ToolChains/Linux.cpp#L40




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-09  8:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 18:32 bug#51088: clang-toolchain > 6 refers to /lib on foreign distros Ludovic Courtès
2021-10-09  8:51 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).