Evan Swick via llvm-dev
2015-Nov-02 13:37 UTC
[llvm-dev] Linking tools against libLLVM.dylib and libclang.dylib
Hello. I am trying to build LLVM and Clang for iOS. To save precious storage space, I would like to link all the tools against libLLVM.dylib and libclang.dylib, instead of using static libraries. I believe this is how Clang/LLVM is linked on Linux when BUILD_SHARED_LIBS is turned on. I am able to compile libLLVM.dylib by turning on the LLVM_BUILD_LLVM_DYLIB CMake flag. However, the tools are still linked against static libraries. When compiling with BUILD_SHARED_LIBS and LLVM_BUILD_LLVM_DYLIB turned on, the tools aren’t linked against libLLVM.dylib, but rather are linked against all of the individual dynamic libraries needed. Also, when building with these flags, libLLVM.dylib contains no symbols, and llvm-c-test fails to link. Can the Clang & LLVM tools be linked against only libclang.dylib and libLLVM.dylib? Is it feasible for this to be done?
Chris Bieneman via llvm-dev
2015-Nov-02 17:28 UTC
[llvm-dev] Linking tools against libLLVM.dylib and libclang.dylib
To do this the options you need to set are: LLVM_BUILD_LLVM_DYLIB and LLVM_LINK_LLVM_DYLIB. Don’t set BUILD_SHARED_LIBS, that doesn’t do what you want. This will not result in clang linking libclang, as we don’t support that in our build system. One thing to keep in mind when doing this is that on many platforms C++ weak-export symbol resolution has a significant impact on process launch time. If you build clang for Darwin (iOS is Darwin) and have it dynamically link LLVM, it will result in about a 10% increase in dynamic link time. This can result in significant compile-time impact. In my tests building clang with a clang that dynamically links LLVM takes 2 minutes longer than building clang with a statically linked clang. -Chris> On Nov 2, 2015, at 5:37 AM, Evan Swick via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello. I am trying to build LLVM and Clang for iOS. To save precious storage space, I would like to link all the tools against libLLVM.dylib and libclang.dylib, instead of using static libraries. I believe this is how Clang/LLVM is linked on Linux when BUILD_SHARED_LIBS is turned on. > > I am able to compile libLLVM.dylib by turning on the LLVM_BUILD_LLVM_DYLIB CMake flag. However, the tools are still linked against static libraries. > > When compiling with BUILD_SHARED_LIBS and LLVM_BUILD_LLVM_DYLIB turned on, the tools aren’t linked against libLLVM.dylib, but rather are linked against all of the individual dynamic libraries needed. Also, when building with these flags, libLLVM.dylib contains no symbols, and llvm-c-test fails to link. > > Can the Clang & LLVM tools be linked against only libclang.dylib and libLLVM.dylib? Is it feasible for this to be done? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev