[llvm-dev] Statically linking against libc++

Carsten Mattner via llvm-dev llvm-dev at lists.llvm.org
Tue Apr 11 14:07:13 PDT 2017


On Mon, Apr 10, 2017 at 3:57 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:

> I can be wrong as well :)
>
> But here that’s not my reading of the documentation:
> http://llvm.org/docs/CMake.html
>
> BUILD_SHARED_LIBS:BOOL
> Flag indicating if each LLVM component (e.g. Support) is built as a shared
> library (ON) or as a static library (OFF). Its default value is OFF. On
> Windows, shared libraries may be used when building with MinGW, including
> mingw-w64, but not when building with the Microsoft toolchain.
>
> This applies to the individual LLVM component. I don’t think the shared lib
> you mentioned are part of this.

I set this in the cmake invocation for all of llvm from the root.
Do I need to do this differently for it to affect every project?

> When I build clang, I always get libc++.so and libc++.a ; I don’t think
> there is an option to have clang always link libc++ statically afterward
> though. I believe it requires to opt-in explicitly when you link with clang.

Yeah you need -static globally in the CXX call which may not be
flexible enough, but you could argue that if one needs to link
libc++ statically they should run it where everything is used
is available for -static use.


More information about the llvm-dev mailing list