Using libunwind

How do I build clang/libc++/libc++abi/libunwind/compiler-rt without requiring libgcc_s?

Do I need --rtlib=compiler-rt somewhere?

I build like this:

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXXABI_USE_LLVM_UNWINDER=YES -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../llvm/projects/libcxxabi/include -DLIT_EXECUTABLE=../../llvm/utils/lit/lit.py -DLLVM_CONFIG_PATH=../../llvm/tools.llvm-config -DCMAKE_C_COMPILER=clang-3.7 -DCMAKE_CXX_COMPILER=clang++-3.7 -DCMAKE_INSTALL_PREFIX=../../install/release ../../llvm/

And end up with:

ben@yyls03:~/development/test$ ldd ~/development/llvm/trunk/build/release/lib/libunwind.so
  linux-vdso.so.1 => (0x00007fffdf168000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f42a0203000)
  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f429ffff000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f429fde0000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f42a0600000)
ben@yyls03:~/development/test$ ldd ~/development/llvm/trunk/build/release/lib/libc++abi.so
  linux-vdso.so.1 => (0x00007ffcc90c2000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe3fad53000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe3fab35000)
  libunwind.so.1 => /home/ben/development/llvm/trunk/build/release/lib/../lib/libunwind.so.1 (0x00007fe3fab27000)
  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe3fa923000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fe3fb18f000)
ben@yyls03:~/development/test$ ldd ~/development/llvm/trunk/build/release/lib/libc++.so
  linux-vdso.so.1 => (0x00007ffd3bfc1000)
  libc++abi.so.1 => /home/ben/development/llvm/trunk/build/release/lib/../lib/libc++abi.so.1 (0x00007fe8077aa000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe807563000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe80719d000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe806e97000)
  librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe806c8f000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe806a77000)
  libunwind.so.1 => /home/ben/development/llvm/trunk/build/release/lib/../lib/../lib/libunwind.so.1 (0x00007fe806a6a000)
  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe806865000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fe8078b8000)

Is it correct that libc++ depends on libgcc_s?

Ben

Is it correct that libc++ depends on libgcc_s?

IIRC ldd will also print indirect library dependencies. It is quite possible,
that you have an indirect dependency on libgcc_s via your host libc. To
see the direct dependencies only, try

readelf -a mylib.so | grep NEEDED

readelf -a ~/development/llvm/trunk/build/release/lib/libc++.so | grep NEEDED
  0x0000000000000001 (NEEDED) Shared library: [libc++abi.so.1]
  0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
  0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
  0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
  0x0000000000000001 (NEEDED) Shared library: [librt.so.1]
  0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]

readelf -a /lib/x86_64-linux-gnu/libc.so.6 | grep NEEDED
  0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2]

Oh well, never mind.

Thanks,

Ben