[PATCH] D105594: cmake: Allow shared libraries to customize the soname using LLVM_ABI_REVISION

Tom Stellard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 7 14:41:22 PDT 2021


tstellar created this revision.
Herald added a subscriber: mgorny.
tstellar requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

The LLVM_ABI_REVISION variable is intended to be used for release
candidates which introduce an ABI change to a shared library.  This
variable can be specified per library, so there is not one global value
for all of LLVM.

For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library
compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for
library will be incremented by 1.

In the main branch, LLVM_ABI_REVISION should always be 0, it is only
meant to be used in the release branch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105594

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ 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)
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ 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()
 
Index: clang/tools/clang-shlib/CMakeLists.txt
===================================================================
--- clang/tools/clang-shlib/CMakeLists.txt
+++ 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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105594.357082.patch
Type: text/x-patch
Size: 2366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210707/ed96004f/attachment-0001.bin>


More information about the cfe-commits mailing list