[llvm-bugs] [Bug 52083] New: libc++ 13.0 still depends on "libgcc_s.so" even when it's built with "-DLIBCXX_USE_COMPILER_RT=ON"

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 5 08:38:06 PDT 2021


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

            Bug ID: 52083
           Summary: libc++ 13.0 still depends on "libgcc_s.so" even when
                    it's built with "-DLIBCXX_USE_COMPILER_RT=ON"
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zin.kosmos.1190 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

## Overview

When I build llvm project 13.0.0 (which includes libc++) using cmake with
"-DLIBCXX_USE_COMPILER_RT=ON" options, libc++ still depends on "libgcc_s.so.1".
But according to the clang document "Assembling a Complete Toolchain" (
https://clang.llvm.org/docs/Toolchain.html#compiler-rt-llvm), libc++ uses
compiler-rt rather than libgcc with the cmake options.

## System environment

OS: 5.11.0-37-generic #41~20.04.2-Ubuntu
cmake: version 3.21.3
ninja: 1.10.2

## Steps to Reproduce

1. Download "llvm-project-13.0.0.src.tar.xz"
(https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-project-13.0.0.src.tar.xz)
and "clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" (
https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz).
We use "clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04" to build
"llvm-project-13.0.0".

2. Extract "clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" and set
path to the clang binary,
```
export
PATH=${path-to-clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04}/bin:${PATH}
```

3. Extract "llvm-project-13.0.0.src.tar.xz" and build it using cmake and ninja
```
mkdir build
cd build
CC=clang CXX=clang++ cmake -GNinja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${PWD}/clang-nodeps
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libclc;libcxx;libcxxabi;libunwind;lld;lldb;mlir;openmp;parallel-libs;polly;pstl"
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON -DLIBCXXABI_USE_COMPILER_RT=ON
-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXX_USE_COMPILER_RT=ON
-DLIBUNWIND_USE_COMPILER_RT=ON ../llvm
cmake --build . --config Release --target install --parallel
```

4. Check dependencies using ldd
```
ldd ./clang-nodeps/lib/libc++.so.1
```

## Actual Result
ldd shows the libc++ depends on "libgcc_s.so.1",
```
        linux-vdso.so.1 (0x00007fffaa1ec000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f5843ef8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5843d06000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5843bb7000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5843bac000)
        libatomic.so.1 => /lib/x86_64-linux-gnu/libatomic.so.1
(0x00007f5843ba2000)
        libc++abi.so.1 => /home/sho/local/clang-nodeps/lib/libc++abi.so.1
(0x00007f5843b5f000)
        libunwind.so.1 => /home/sho/local/clang-nodeps/lib/libunwind.so.1
(0x00007f5843b4f000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f5843b34000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5844001000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5843b2e000)
```

## Expected Result
This is the ldd result of libc++ 12.0.1 which doesn't depend on
"libgcc_s.so.1",
```
        linux-vdso.so.1 (0x00007fff0309a000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f0dbb5c8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0dbb3d6000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0dbb287000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0dbb27c000)
        libatomic.so.1 => /lib/x86_64-linux-gnu/libatomic.so.1
(0x00007f0dbb272000)
        libc++abi.so.1 => /home/sho/local/clang-nodeps/lib/libc++abi.so.1
(0x00007f0dbb22f000)
        libunwind.so.1 => /home/sho/local/clang-nodeps/lib/libunwind.so.1
(0x00007f0dbb21f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0dbb6d1000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0dbb219000)
```

## Additional information
I also noticed libc++ 13.0 still depends on libatomic.so.1.
But according to the clang document "Assembling a Complete
Toolchain"(https://clang.llvm.org/docs/Toolchain.html#id1), compiler-rt is used
instead of libatomic when llvm is built with compiler-rt options.

-- 
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/20211005/923baa99/attachment.html>


More information about the llvm-bugs mailing list