|
|
bbcd893 |
From 3dc5722d5c7673a879f2b4680369d3ac8b6b64b6 Mon Sep 17 00:00:00 2001
|
|
|
bbcd893 |
From: Tom Stellard <tstellar@redhat.com>
|
|
|
bbcd893 |
Date: Wed, 4 Aug 2021 14:05:38 -0700
|
|
|
bbcd893 |
Subject: [PATCH] cmake: Allow shared libraries to customize the soname using
|
|
|
bbcd893 |
LLVM_ABI_REVISION
|
|
|
bbcd893 |
|
|
|
bbcd893 |
The LLVM_ABI_REVISION variable is intended to be used for release
|
|
|
bbcd893 |
candidates which introduce an ABI change to a shared library. This
|
|
|
bbcd893 |
variable can be specified per library, so there is not one global value
|
|
|
bbcd893 |
for all of LLVM.
|
|
|
bbcd893 |
|
|
|
bbcd893 |
For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library
|
|
|
bbcd893 |
compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for
|
|
|
bbcd893 |
library will be incremented by 1.
|
|
|
bbcd893 |
|
|
|
bbcd893 |
In the main branch, LLVM_ABI_REVISION should always be 0, it is only
|
|
|
bbcd893 |
meant to be used in the release branch.
|
|
|
bbcd893 |
|
|
|
bbcd893 |
Differential Revision: https://reviews.llvm.org/D105594
|
|
|
bbcd893 |
---
|
|
|
bbcd893 |
llvm/cmake/modules/AddLLVM.cmake | 7 +++++--
|
|
|
bbcd893 |
llvm/tools/llvm-shlib/CMakeLists.txt | 9 +++++++++
|
|
|
bbcd893 |
3 files changed, 19 insertions(+), 2 deletions(-)
|
|
|
bbcd893 |
|
|
|
bbcd893 |
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
|
|
|
bbcd893 |
index 3e009f5061d3..a09405a1be3e 100644
|
|
|
bbcd893 |
--- a/llvm/cmake/modules/AddLLVM.cmake
|
|
|
bbcd893 |
+++ b/llvm/cmake/modules/AddLLVM.cmake
|
|
|
bbcd893 |
@@ -586,11 +586,14 @@ function(llvm_add_library name)
|
|
|
bbcd893 |
# Set SOVERSION on shared libraries that lack explicit SONAME
|
|
|
bbcd893 |
# specifier, on *nix systems that are not Darwin.
|
|
|
bbcd893 |
if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
|
|
|
bbcd893 |
+ if (NOT LLVM_ABI_REVISION)
|
|
|
bbcd893 |
+ set(LLVM_ABI_REVISION 0)
|
|
|
bbcd893 |
+ endif()
|
|
|
bbcd893 |
set_target_properties(${name}
|
|
|
bbcd893 |
PROPERTIES
|
|
|
bbcd893 |
# Since 4.0.0, the ABI version is indicated by the major version
|
|
|
bbcd893 |
- SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
|
|
|
bbcd893 |
- VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
|
|
|
bbcd893 |
+ SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION}
|
|
|
bbcd893 |
+ VERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION})
|
|
|
bbcd893 |
endif()
|
|
|
bbcd893 |
endif()
|
|
|
bbcd893 |
|
|
|
bbcd893 |
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
|
|
|
bbcd893 |
index 76b9a25cbbcd..b876e7fed6b5 100644
|
|
|
bbcd893 |
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
|
|
|
bbcd893 |
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
|
|
|
bbcd893 |
@@ -2,6 +2,11 @@
|
|
|
bbcd893 |
# library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake
|
|
|
bbcd893 |
# commandline. By default the shared library only exports the LLVM C API.
|
|
|
bbcd893 |
|
|
|
bbcd893 |
+# In the main branch, LLVM_ABI_REVISION should always be 0. In the release
|
|
|
bbcd893 |
+# branches, this should be incremented before each release candidate every
|
|
|
bbcd893 |
+# time the ABI of libLLVM.so changes.
|
|
|
bbcd893 |
+set(LLVM_ABI_REVISION 0 CACHE STRING "ABI Revision number for SONAMEs (default: 0)")
|
|
|
bbcd893 |
+
|
|
|
bbcd893 |
set(SOURCES
|
|
|
bbcd893 |
libllvm.cpp
|
|
|
bbcd893 |
)
|
|
|
bbcd893 |
@@ -67,6 +72,10 @@ if(LLVM_BUILD_LLVM_DYLIB)
|
|
|
bbcd893 |
set_property(TARGET LLVM APPEND_STRING PROPERTY
|
|
|
bbcd893 |
LINK_FLAGS
|
|
|
bbcd893 |
" -compatibility_version 1 -current_version ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
|
|
|
bbcd893 |
+ else()
|
|
|
bbcd893 |
+ set_target_properties(LLVM
|
|
|
bbcd893 |
+ PROPERTIES
|
|
|
bbcd893 |
+ SOVERSION ${LLVM_ABI_REVISION})
|
|
|
bbcd893 |
endif()
|
|
|
bbcd893 |
|
|
|
bbcd893 |
if(TARGET libLLVMExports)
|
|
|
bbcd893 |
--
|
|
|
bbcd893 |
2.27.0
|
|
|
bbcd893 |
|