Build libLTO.a instead of libLTO.dylib with Cmake

Hello,

Is there any CMake variable available to build LLVM libs as static libraries. I found one -DLIBCLANG_BUILD_STATIC=ON but what if I want libLTO.a instead of libLTO.dylib ?

Hi,

Having a look at tools/lto/CMakeLists.txt it is unconditionally defined as a shared library:

add_llvm_library(LTO SHARED ${SOURCES})

Have you tried removing the “SHARED” keyword here?

For libLTO we don’t build a static archive because the use case for libLTO is pretty specific, and there is virtually no code that is in libLTO and not in the LLVM static libraries. If there is code that is libLTO specific that you want to link into a static archive I think there is a better case for moving that code into libLLVMLTO rather than supporting making libLTO static.

-Chris