[llvm-branch-commits] [llvm] release/18.x: [cmake] Add minor version to library SONAME (#79376) (PR #82409)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Feb 20 11:52:31 PST 2024
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/82409
Backport 91a384621e5b762d9c173ffd247cfeadd5f436a2
Requested by: @tstellar
>From 4f49c058f52996c02b791106d73b841cd8552d2c Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Mon, 19 Feb 2024 16:46:16 -0800
Subject: [PATCH] [cmake] Add minor version to library SONAME (#79376)
We need to do this now that we are bumping the minor release number when
we create the release branch.
This also results in a slight change to the library names for LLVM. The
main library now has a more convential library name:
'libLLVM.so.$major.$minor'. The old library name: libLLVM-$major.so is
now a symlink that points to the new library. However, the symlink is
not present in the build directory. It is only present in the install
directory.
The library name was changed because it helped to keep the CMake changes
more simple.
Fixes #76273
(cherry picked from commit 91a384621e5b762d9c173ffd247cfeadd5f436a2)
---
llvm/CMakeLists.txt | 2 +-
llvm/cmake/modules/AddLLVM.cmake | 8 ++++----
llvm/tools/llvm-shlib/CMakeLists.txt | 5 ++++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c2fb77d5a371f4..44f2850b92d522 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -35,7 +35,7 @@ endif()
if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
# "Symbol version prefix for libLLVM.so"
- set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}")
+ set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
endif()
if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (MSVC_TOOLSET_VERSION LESS 142) AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 5e989618552824..5fc663d10b8f77 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -108,7 +108,7 @@ function(add_llvm_symbol_exports target_name export_file)
COMMAND "${Python3_EXECUTABLE}" "-c"
"import sys; \
lines = [' ' + l.rstrip() for l in sys.stdin] + [' local: *;']; \
- print('LLVM_${LLVM_VERSION_MAJOR} {'); \
+ print('LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} {'); \
print(' global:') if len(lines) > 1 else None; \
print(';\\n'.join(lines) + '\\n};')"
< ${export_file} > ${native_export_file}
@@ -646,9 +646,9 @@ function(llvm_add_library name)
if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
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})
+ # Since 18.1.0, the ABI version is indicated by the major and minor version.
+ SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}
+ VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX})
endif()
endif()
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index a47a0ec84c625c..09c15e304614c4 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -33,7 +33,10 @@ if(LLVM_BUILD_LLVM_DYLIB)
if (LLVM_LINK_LLVM_DYLIB)
set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
endif()
- add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+ add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM ${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+ # Add symlink for backwards compatibility with old library name
+ get_target_property(LLVM_DYLIB_FILENAME LLVM OUTPUT_NAME)
+ llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} ${LLVM_DYLIB_FILENAME} SHARED COMPONENT LLVM)
list(REMOVE_DUPLICATES LIB_NAMES)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
More information about the llvm-branch-commits
mailing list