[llvm-dev] Statically linking against libc++

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 13 00:27:52 PDT 2017


> On Apr 11, 2017, at 11:07 AM, Carsten Mattner <carstenmattner at gmail.com> wrote:
> 
> 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?

No, what I meant is that there are components for which we don’t want to do anything else than generate a shared library. For example your list includes LLVMHello.so which is intended to showcase/test how passes can be dynamically loaded in LLVM.

— 
Mehdi






> 
>> 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