<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - libc++ 13.0 still depends on "libgcc_s.so" even when it's built with "-DLIBCXX_USE_COMPILER_RT=ON""
   href="https://bugs.llvm.org/show_bug.cgi?id=52083">52083</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libc++ 13.0 still depends on "libgcc_s.so" even when it's built with "-DLIBCXX_USE_COMPILER_RT=ON"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zin.kosmos.1190@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>## 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" (
<a href="https://clang.llvm.org/docs/Toolchain.html#compiler-rt-llvm">https://clang.llvm.org/docs/Toolchain.html#compiler-rt-llvm</a>), 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"
(<a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/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</a>)
and "clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" (
<a href="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">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</a>).
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"(<a href="https://clang.llvm.org/docs/Toolchain.html#id1">https://clang.llvm.org/docs/Toolchain.html#id1</a>), compiler-rt is used
instead of libatomic when llvm is built with compiler-rt options.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>