[llvm-dev] Statically linking against libc++

Carsten Mattner via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 9 09:05:43 PDT 2017


While considering statically linking against libc++ (and
other runtime libraries from LLVM), I rebuilt LLVM 4.0
with -DBUILD_SHARED_LIBS=OFF.

There are still some .so's in llvm/lib, and only one
of them seems to exist exclusively as a DSO (libLTO).
There's also livLLVMLTO.a, but I doubt LTO is used
after linking a binary so this just looks odd to an
uninformed LLVM outside and not insufficient or anything.

My question is two-fold:

1. when building a C++ program with clang, maybe making use
of clang-musl to avoid glibc as well, how do I statically
link libc++ and get a C++ program that runs on any Linux
kernel, allowing easy distribution of a single binary?

2. should the following .so's be built with -DBUILD_SHARED_LIBS=OFF?

$ ls *.so
BugpointPasses.so
LLVMHello.so
LLVMPolly.so
LLVMgold.so
libLTO.so
libc++.so
libc++abi.so
libclang.so
libgomp.so
libiomp5.so
liblldb.so
libomp.so


More information about the llvm-dev mailing list