Skip to content

Commit 6b929d5

Browse files
committed
[cmake] Reintroduce (ldconfig-compatible) SOVERSIONs on shared libraries
Reintroduce versioning of shared libraries via SOVERSION, addressing the issues with the previous design, since Gentoo is relying on shared-split install of LLVM. The SOVERSIONs were originally introduced in r229720 for all libraries, and removed in r252093 in favor of custom SONAME. As far as I understand, the major concern with the old versioning was that the used versions were incompatible with ldconfig. Having considered that, this commit introduce SOVERSIONS with the following considerations: 1. SOVERSIONs are formed of major & minor version concatenated -- i.e. for 4.0 its .so.40. This matches the common practice where the first version number indicates ABI breakage, and therefore fixes the issues with ldconfig. Additionally, VERSION with the remaining verion components appended is used, however this is not strictly necessary. 2. The versioning is only applied to libraries with no explicit SONAME specified -- i.e. it won't apply to libLLVM but only to the split libraries. It will also apply to libraries installed by the subprojects. 3. The versioning is only done on *nix systems, Darwin excluded. This matches the current use of SONAME. Differential Revision: https://reviews.llvm.org/D24757 llvm-svn: 283189
1 parent fd9f63b commit 6b929d5

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,18 @@ function(llvm_add_library name)
450450
PREFIX ""
451451
)
452452
endif()
453+
454+
# Set SOVERSION on shared libraries that lack explicit SONAME
455+
# specifier, on *nix systems that are not Darwin.
456+
if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
457+
set_target_properties(${name}
458+
PROPERTIES
459+
# Concatenate the version numbers since ldconfig expects exactly
460+
# one component indicating the ABI version, while LLVM uses
461+
# major+minor for that.
462+
SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}
463+
VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
464+
endif()
453465
endif()
454466

455467
if(ARG_MODULE OR ARG_SHARED)

0 commit comments

Comments
 (0)