[llvm-bugs] [Bug 48775] New: Trivial program fails libc++ linkage

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 16 15:07:49 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48775

            Bug ID: 48775
           Summary: Trivial program fails libc++ linkage
           Product: libc++
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: planetmarshalluk at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

I'm having the following problem compiling a trivial program with clang 11.0.1
and libc++. I suspect it's an environment issue but I'm having trouble tracking
it down. I am running Ubuntu 20.04 LTS

`main.cpp`:

```
#include <iostream>

int main() {
    std::cout << "hello world" << std::endl;
    return 0;
}
```
```
> clang++ -stdlib=libc++ main.cpp -o main
```

**output**
```
-/usr/bin/ld: cannot find l
clang-11: error: linker command failed with exit code 1 (use -v to see
invocation)
```

Linking to gnu stdlibc++ works as expected.

I installed clang from source with the following configuration:
```
cmake ../llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS=all \
  -DLLVM_ENABLE_OCAMLDOC=False \
  -DLLVM_ENABLE_BINDINGS=False \
  -DLIBCXX_ENABLE_PARALLEL_ALGORITHMS=True \
  -DPSTL_PARALLEL_BACKEND=tbb \
  -DCMAKE_PREFIX_PATH=../../oneTBB/install \
  -DLIBOMPTARGET_NVPTX_ALTERNATE_HOST_COMPILER=gcc-8 \
  -G Ninja
```

The output of
```
clang++ -v -stdlib=libc++ main.cpp -o main
```

is as follows:

```
clang version 11.0.1 (git at github.com:llvm/llvm-project.git
43ff75f2c3feef64f9d73328230d34dac8832a91)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-10.2, version 10.2
 "/usr/local/bin/clang-11" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names
-main-file-name main.cpp -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -v
-resource-dir /usr/local/lib/clang/11.0.1 -internal-isystem
/usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include
-internal-isystem /usr/local/lib/clang/11.0.1/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/andrew/projects/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/main-0e8b1d.o -x c++ main.cpp
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/11.0.1/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o main
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/9
-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -L/usr/local/bin/../lib -L/lib
-L/usr/lib /tmp/main-0e8b1d.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
-/usr/bin/ld: cannot find l
clang-11: error: linker command failed with exit code 1 (use -v to see
invocation)
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210116/41a2a8bc/attachment-0001.html>


More information about the llvm-bugs mailing list