Skip to content

Commit 7e23666

Browse files
committed
[llvm] Enable LLVM_LINK_LLVM_DYLIB by default on non-Windows platforms
As discussed in the RFC thread [1], this build configuration is a better default because it uses less RAM and disk to build LLVM, which makes it more accessible to beginners. The downside to the libLLVM build is that it increases tool binary startup time, which can have major impacts on configuration script times and the LLVM test suite itself. However, it is better for new users configuring LLVM builds for the first time. Long-time developers with beefy machines who prefer the finer grained dependencies of static linking can still use the old model by opting out with -DLLVM_LINK_LLVM_DYLIB=OFF. The fine-grained shared lib build is also still supported via -DBUILD_SHARED_LIBS=ON. MLIR's dylib build is configured to follow the LLVM dylib build, so this changes the default for MLIR as well. [1] https://discourse.llvm.org/t/rfc-llvm-link-llvm-dylib-should-default-to-on-on-posix-platforms/85908/1
1 parent 228b330 commit 7e23666

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,14 +904,26 @@ if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS)
904904
set(CAN_BUILD_LLVM_DYLIB ON)
905905
endif()
906906

907-
cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
907+
# Link the tools against the libllvm DSO by default.
908+
set(LLVM_LINK_LLVM_DYLIB_default ON)
909+
if (BUILD_SHARED_LIBS OR WIN32)
910+
set(LLVM_LINK_LLVM_DYLIB_default OFF)
911+
endif()
912+
913+
cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library"
914+
"${LLVM_LINK_LLVM_DYLIB_default}"
908915
"CAN_BUILD_LLVM_DYLIB" OFF)
909916

917+
message("LLVM_LINK_LLVM_DYLIB_default ${LLVM_LINK_LLVM_DYLIB_default}")
918+
message("BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")
919+
message("LLVM_LINK_LLVM_DYLIB ${LLVM_LINK_LLVM_DYLIB}")
920+
910921
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
911922
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
912923
set(LLVM_BUILD_LLVM_DYLIB_default ON)
913924
endif()
914-
cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
925+
cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library"
926+
"${LLVM_BUILD_LLVM_DYLIB_default}"
915927
"CAN_BUILD_LLVM_DYLIB" OFF)
916928

917929
cmake_dependent_option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when

llvm/docs/ReleaseNotes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ Changes to LLVM infrastructure
7777
Changes to building LLVM
7878
------------------------
7979

80+
* On non-Windows platforms, LLVM now builds as a large shared library, libLLVM,
81+
by default. To revert to the old behavior of producing and linking static
82+
libraries, pass ``-DLLVM_LINK_LLVM_DYLIB=OFF`` to CMake when configuring your
83+
build.
84+
8085
Changes to TableGen
8186
-------------------
8287

0 commit comments

Comments
 (0)