GNU bug report logs - #51088
clang-toolchain > 6 refers to /lib on foreign distros

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Date: Thu, 7 Oct 2021 18:33:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51088 in the body.
You can then email your comments to 51088 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to emmanuel.agullo <at> inria.fr, bug-guix <at> gnu.org:
bug#51088; Package guix. (Thu, 07 Oct 2021 18:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
New bug report received and forwarded. Copy sent to emmanuel.agullo <at> inria.fr, bug-guix <at> gnu.org. (Thu, 07 Oct 2021 18:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: bug-guix <at> gnu.org
Subject: clang-toolchain > 6 refers to /lib on foreign distros
Date: Thu, 07 Oct 2021 20:32:16 +0200
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 <at> 6 -- c++  hello.cpp
$ echo $?
0
$ guix environment --pure --ad-hoc clang-toolchain <at> 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 <at> 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 <at> 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 <at> 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 <at> 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 <at> 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’.




Information forwarded to bug-guix <at> gnu.org:
bug#51088; Package guix. (Sat, 09 Oct 2021 08:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 51088 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: 51088 <at> debbugs.gnu.org
Cc: emmanuel.agullo <at> inria.fr
Subject: Re: bug#51088: clang-toolchain > 6 refers to /lib on foreign distros
Date: Sat, 09 Oct 2021 10:51:25 +0200
Hi,

Ludovic Courtès <ludovic.courtes <at> 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 <at> 6 -- c++  hello.cpp
> $ echo $?
> 0
> $ guix environment --pure --ad-hoc clang-toolchain <at> 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 <at> 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 <at> 11, clang <at> 12: Do not refer to /lib on foreign distros.
  f1b4f46f0a gnu: clang <at> 10: Do not refer to /lib on foreign distros.
  46141bd372 gnu: clang <at> 9: Do not refer to /lib on foreign distros.
  66caab54b9 gnu: clang <at> 7, clang <at> 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




bug closed, send any further explanations to 51088 <at> debbugs.gnu.org and Ludovic Courtès <ludovic.courtes <at> inria.fr> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 09 Oct 2021 08:52:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 06 Nov 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 171 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.