Skip to content

[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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bolt/unittests/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ target_link_libraries(CoreTests
LLVMBOLTRewrite
LLVMBOLTProfile
LLVMBOLTUtils
LLVMTestingSupport
)
Copy link
Collaborator Author

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.

Copy link
Contributor

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.


foreach (tgt ${BOLT_TARGETS_TO_BUILD})
Expand Down
3 changes: 1 addition & 2 deletions bolt/unittests/Core/MemoryMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

using namespace llvm;
Expand Down Expand Up @@ -110,7 +109,7 @@ TEST_P(MemoryMapsTester, ParseMultipleSegments) {
Error Err = DA.preprocessProfile(*BC);

// Ignore errors from perf2bolt when parsing memory events later on.
ASSERT_THAT_ERROR(std::move(Err), Succeeded());
ASSERT_FALSE(!!Err) << "Expected success";

auto &BinaryMMapInfo = DA.getBinaryMMapInfo();
auto El = BinaryMMapInfo.find(Pid);
Expand Down
2 changes: 0 additions & 2 deletions bolt/unittests/Profile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ target_link_libraries(ProfileTests
PRIVATE
LLVMBOLTCore
LLVMBOLTProfile
LLVMTargetParser
LLVMTestingSupport
)

foreach (tgt ${BOLT_TARGETS_TO_BUILD})
Expand Down
5 changes: 5 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ Non-comprehensive list of changes in this release
- Clang no longer rejects reinterpret_cast conversions between indirect
ARC-managed pointers and other pointer types. The prior behavior was overly
strict and inconsistent with the ARC specification.
- On non-Windows platforms, Clang now builds as a large shared library,
``libclang-cpp``, by default. To revert to the old behavior of producing and
linking static libraries, pass ``-DCLANG_LINK_CLANG_DYLIB=OFF`` to CMake when
configuring your build. The new behavior matches LLVM, which also builds as a
large shared library.

New Compiler Flags
------------------
Expand Down
12 changes: 10 additions & 2 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

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

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
Expand Down
5 changes: 5 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------

Expand Down