diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -1,3 +1,8 @@ +# In the main branch, LLVM_ABI_REVISION should always be 0. In the release +# branches, this should be incremented before each release candidate every +# time the ABI of libclang-cpp.so changes. +set(LLVM_ABI_REVISION 0) + # Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off if (NOT LLVM_ENABLE_PIC) return() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -586,11 +586,14 @@ # Set SOVERSION on shared libraries that lack explicit SONAME # specifier, on *nix systems that are not Darwin. if(UNIX AND NOT APPLE AND NOT ARG_SONAME) + if (NOT LLVM_ABI_REVISION) + set(LLVM_ABI_REVISION 0) + endif() set_target_properties(${name} PROPERTIES # Since 4.0.0, the ABI version is indicated by the major version - SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} - VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) + SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION} + VERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION}) endif() endif() diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -2,6 +2,11 @@ # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake # commandline. By default the shared library only exports the LLVM C API. +# In the main branch, LLVM_ABI_REVISION should always be 0. In the release +# branches, this should be incremented before each release candidate every +# time the ABI of libLLVM.so changes. +set(LLVM_ABI_REVISION 0) + set(SOURCES libllvm.cpp ) @@ -67,6 +72,10 @@ set_property(TARGET LLVM APPEND_STRING PROPERTY LINK_FLAGS " -compatibility_version 1 -current_version ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") + else() + set_target_properties(LLVM + PROPERTIES + SOVERSION ${LLVM_ABI_REVISION}) endif() if(TARGET libLLVMExports)