-
Notifications
You must be signed in to change notification settings - Fork 17.1k
[CMake] Version Darwin dylib identities #189004
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,30 @@ if(NOT LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE) | |
| set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) | ||
| endif() | ||
|
|
||
| # Darwin used to keep libLLVM's install name unversioned even when | ||
| # LLVM_VERSION_SUFFIX was set. That makes distinct LLVM builds look | ||
| # interchangeable to Mach-O consumers. Keep an opt-out for downstream users | ||
| # that still depend on the legacy install name. | ||
| option(LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN "If set, use versioned dylib names and install names on Darwin like other Unix platforms" ON) | ||
| mark_as_advanced(LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN) | ||
| # At the time of writing (2026-04-01), | ||
| # https://github.com/llvm/llvm-project/pull/189004#issuecomment-4171272082 | ||
| # claims that Xcode uses libclang for indexing and can load additional | ||
| # toolchains, so keeping libclang.dylib unversioned avoids breaking that | ||
| # compatibility by default. If this ever changes, audit Darwin libclang users | ||
| # first and verify that Xcode and downstream toolchains accept a versioned | ||
| # libclang install name before changing this default. | ||
| option(LLVM_UNVERSIONED_LIBCLANG_ON_DARWIN "If set, keep libclang's Darwin dylib identity unversioned when Darwin versioned dylib names are enabled" ON) | ||
| mark_as_advanced(LLVM_UNVERSIONED_LIBCLANG_ON_DARWIN) | ||
| # At the time of writing (2026-04-01), | ||
| # https://github.com/llvm/llvm-project/pull/189004#issuecomment-4165730721 | ||
| # claims that the macOS linker requires libLTO.dylib to keep that stable name | ||
| # for LTO builds. If this ever changes, audit Darwin LTO users first and | ||
| # verify that ld64 and downstream toolchains accept a versioned libLTO install | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's default to NO. Apple linker is pretty much the only user of libLTO on macOS and it requires unversioned since it has to load libLTO from all versions of LLVM in our internal build system. Loading a single or limited range of version of libLTO is not an option for us.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want |
||
| # name before changing this default. | ||
| option(LLVM_UNVERSIONED_LIBLTO_ON_DARWIN "If set, keep libLTO's Darwin dylib identity unversioned when Darwin versioned dylib names are enabled" ON) | ||
| mark_as_advanced(LLVM_UNVERSIONED_LIBLTO_ON_DARWIN) | ||
|
|
||
| include(${LLVM_COMMON_CMAKE_UTILS}/Modules/LLVMVersion.cmake) | ||
|
|
||
| set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
libclang and libLTO has stable ABI.
It is a requirement on macOS and in our toolchain that we have to link across major version boundaries.
I don't really mind the version number on llvm dylibs from
BUILD_SHARED_LIBS=YESbut libLTO and libclang cannot be versioned.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.
Yes, this PR preserves that.
MACHO_COMPATIBILITY_VERSIONandMACHO_CURRENT_VERSIONtake precedence overVERSION.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 think there is still a version number on the dylib right here right? It is just not equal to llvm version.
macOS toolchain has always been shipping with no version and new toolchain cannot have a version on it, otherwise, it will break compatibility with old tools. Let me know if I misunderstood the code.
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 think this is not correct; even before this PR libclang and libLTO had explicit version numbers, they were just doing it manually using
-compatibility_versionand-current_version. The second commit in this PR kept that behavior but changed the implementation to useMACHO_COMPATIBILITY_VERSIONandMACHO_CURRENT_VERSION.Uh oh!
There was an error while loading. Please reload this page.
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.
Can you help me understand why this is a requirement specifically on macOS? In particular, what behavior or distribution model depends on
libclang/libLTOkeeping an unversioned dylib identity on macOS only?