[llvm-dev] Statically linking against libc++
Mehdi Amini via llvm-dev
llvm-dev at lists.llvm.org
Sun Apr 9 21:59:55 PDT 2017
> On Apr 9, 2017, at 9:05 AM, Carsten Mattner via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> While considering statically linking against libc++ (and
> other runtime libraries from LLVM), I rebuilt LLVM 4.0
> with -DBUILD_SHARED_LIBS=OFF.
What you build with clang and how clang is built aren’t related at all.
You can build LLVM as a set of dynamic libraries, and still use clang to generate a statically linked binary.
> 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?
Yes, most of them are intended to stay .so.
Note that -DBUILD_SHARED_LIBS=OFF is not a special settings, this is the default.
> $ ls *.so
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
More information about the llvm-dev