-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[llvm] Enable LLVM_LINK_LLVM_DYLIB by default on non-Windows platforms #138187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
The premerge check failures seem related, and they seem related to bolt:
It was pointed out in the RFC that Bolt links LLVM statically instead of using the dylib because it directly refers to symbols in Target libraries that are hidden visibility. I think resolving that may become a blocker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of the naming as LLVM_LINK_LLVM_DYLIB
and LLVM_BUILD_LLVM_DYLIB
are easy to mix up in a quick read. However, it also makes sense to name them similarly for the configuration behaviour. I'm not sure if there is a great solution here, but pointing this out just incase someone happens to have some brilliant inishgt.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-bolt Author: Reid Kleckner (rnk) ChangesAs discussed in the RFC thread [1], this build configuration is a better Long-time developers with beefy machines who prefer the finer grained MLIR's dylib build is configured to follow the LLVM dylib build, so this Full diff: https://github.com/llvm/llvm-project/pull/138187.diff 4 Files Affected:
diff --git a/bolt/unittests/Profile/CMakeLists.txt b/bolt/unittests/Profile/CMakeLists.txt
index ce01c6c4b949e..4d468372f27fc 100644
--- a/bolt/unittests/Profile/CMakeLists.txt
+++ b/bolt/unittests/Profile/CMakeLists.txt
@@ -15,8 +15,6 @@ target_link_libraries(ProfileTests
PRIVATE
LLVMBOLTCore
LLVMBOLTProfile
- LLVMTargetParser
- LLVMTestingSupport
)
foreach (tgt ${BOLT_TARGETS_TO_BUILD})
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4b9e70fad2152..cd2adf1cddace 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -919,14 +919,22 @@ if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS)
set(CAN_BUILD_LLVM_DYLIB ON)
endif()
-cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
+# Link the tools against the libllvm DSO by default.
+set(LLVM_LINK_LLVM_DYLIB_default ON)
+if (BUILD_SHARED_LIBS OR WIN32)
+ set(LLVM_LINK_LLVM_DYLIB_default OFF)
+endif()
+
+cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library"
+ "${LLVM_LINK_LLVM_DYLIB_default}"
"CAN_BUILD_LLVM_DYLIB" OFF)
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
-cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
+cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library"
+ "${LLVM_BUILD_LLVM_DYLIB_default}"
"CAN_BUILD_LLVM_DYLIB" OFF)
cmake_dependent_option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 4a1005667692d..d4b1e353499f5 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -90,6 +90,11 @@ Changes to LLVM infrastructure
Changes to building LLVM
------------------------
+* On non-Windows platforms, LLVM now builds as a large shared library, libLLVM,
+ by default. To revert to the old behavior of producing and linking static
+ libraries, pass ``-DLLVM_LINK_LLVM_DYLIB=OFF`` to CMake when configuring your
+ build.
+
Changes to TableGen
-------------------
diff --git a/llvm/lib/Testing/Support/CMakeLists.txt b/llvm/lib/Testing/Support/CMakeLists.txt
index 6955271239ca6..e5f3af23a6a13 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -14,6 +14,8 @@ add_llvm_library(LLVMTestingSupport
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/Testing/Support
+ DISABLE_LLVM_LINK_LLVM_DYLIB
+
LINK_COMPONENTS
Support
)
|
@llvm/pr-subscribers-llvm-support Author: Reid Kleckner (rnk) ChangesAs discussed in the RFC thread [1], this build configuration is a better Long-time developers with beefy machines who prefer the finer grained MLIR's dylib build is configured to follow the LLVM dylib build, so this Full diff: https://github.com/llvm/llvm-project/pull/138187.diff 4 Files Affected:
diff --git a/bolt/unittests/Profile/CMakeLists.txt b/bolt/unittests/Profile/CMakeLists.txt
index ce01c6c4b949e..4d468372f27fc 100644
--- a/bolt/unittests/Profile/CMakeLists.txt
+++ b/bolt/unittests/Profile/CMakeLists.txt
@@ -15,8 +15,6 @@ target_link_libraries(ProfileTests
PRIVATE
LLVMBOLTCore
LLVMBOLTProfile
- LLVMTargetParser
- LLVMTestingSupport
)
foreach (tgt ${BOLT_TARGETS_TO_BUILD})
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4b9e70fad2152..cd2adf1cddace 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -919,14 +919,22 @@ if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS)
set(CAN_BUILD_LLVM_DYLIB ON)
endif()
-cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
+# Link the tools against the libllvm DSO by default.
+set(LLVM_LINK_LLVM_DYLIB_default ON)
+if (BUILD_SHARED_LIBS OR WIN32)
+ set(LLVM_LINK_LLVM_DYLIB_default OFF)
+endif()
+
+cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library"
+ "${LLVM_LINK_LLVM_DYLIB_default}"
"CAN_BUILD_LLVM_DYLIB" OFF)
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
-cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
+cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library"
+ "${LLVM_BUILD_LLVM_DYLIB_default}"
"CAN_BUILD_LLVM_DYLIB" OFF)
cmake_dependent_option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 4a1005667692d..d4b1e353499f5 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -90,6 +90,11 @@ Changes to LLVM infrastructure
Changes to building LLVM
------------------------
+* On non-Windows platforms, LLVM now builds as a large shared library, libLLVM,
+ by default. To revert to the old behavior of producing and linking static
+ libraries, pass ``-DLLVM_LINK_LLVM_DYLIB=OFF`` to CMake when configuring your
+ build.
+
Changes to TableGen
-------------------
diff --git a/llvm/lib/Testing/Support/CMakeLists.txt b/llvm/lib/Testing/Support/CMakeLists.txt
index 6955271239ca6..e5f3af23a6a13 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -14,6 +14,8 @@ add_llvm_library(LLVMTestingSupport
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/Testing/Support
+ DISABLE_LLVM_LINK_LLVM_DYLIB
+
LINK_COMPONENTS
Support
)
|
@@ -20,7 +20,6 @@ target_link_libraries(CoreTests | |||
LLVMBOLTRewrite | |||
LLVMBOLTProfile | |||
LLVMBOLTUtils | |||
LLVMTestingSupport | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removal here was interesting. Bolt doesn't support the LLVM dylib build, and it tries to disable linking the LLVM dylib. However, it ends up depending on it transitively through LLVMTestingSupport, resulting in double registration of command line flags due to two copies of Support libraries, static and from the dylib. I think it should be possible to link LLVMTestingSupport as a single static archive and not reference the dylib, but I couldn't figure that out. In the end, I cut the library dependency because it was easier.
This library dependency was introduced in Dec 2024 5100307 and I think it breaks building bolt with cmake and the dylib build enabled, so I think that was actually a regression in functionality, but I need to confirm it.
Anyway, I think this will finally pass premerge checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should split this into a separate PR. Worth noting that #145448 has an alternative approach where a separate statically linked LLVMTestingSupportStatic is introduced. But given that that this is barely used here, just dropping it entirely is fine.
@@ -919,14 +919,22 @@ if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS) | |||
set(CAN_BUILD_LLVM_DYLIB ON) | |||
endif() | |||
|
|||
cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF | |||
# Link the tools against the libllvm DSO by default. | |||
set(LLVM_LINK_LLVM_DYLIB_default ON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned on the RFC thread, the deployment story on AIX does not work well with such a configuration (due to lack of relative rpath support).
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