[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 17:23:20 PST 2024
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/82409
>From 1d4de7556e20621245bbc32fca97544ea18cb6c5 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 1/2] [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")
>From 1246bfdef17ea7fd9e0942ea23d2c6b3e517c042 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Wed, 21 Feb 2024 00:14:59 +0000
Subject: [PATCH 2/2] Fix llvm-x86_64-debian-dylib buildbot
This was broken by 91a384621e5b762d9c173ffd247cfeadd5f436a2.
(cherry picked from commit ff4d6c64ee4269e4a9b67a4dae7e0b82ae1c3419)
---
llvm/test/lit.cfg.py | 7 ++++---
llvm/test/lit.site.cfg.py.in | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index c6f9ee82e08cc1..74e7769a480598 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -414,10 +414,11 @@ def version_int(ver):
config.available_features.add("llvm-dylib")
config.substitutions.append(
(
+ # libLLVM.so.19.0git
"%llvmdylib",
- "{}/libLLVM-{}{}".format(
- config.llvm_shlib_dir, config.llvm_dylib_version, config.llvm_shlib_ext
- ),
+ "{}/libLLVM{}.{}".format(
+ config.llvm_shlib_dir, config.llvm_shlib_ext, config.llvm_dylib_version
+ )
)
)
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index 1138b2ccf7bce7..b6f255d472d16f 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -44,7 +44,7 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@
config.enable_threads = @LLVM_ENABLE_THREADS@
config.build_shared_libs = @BUILD_SHARED_LIBS@
config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
-config.llvm_dylib_version = "@LLVM_VERSION_MAJOR@@LLVM_VERSION_SUFFIX@"
+config.llvm_dylib_version = "@LLVM_VERSION_MAJOR at .@LLVM_VERSION_MINOR@@LLVM_VERSION_SUFFIX@"
config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
config.host_arch = "@HOST_ARCH@"
config.have_opt_viewer_modules = @LLVM_HAVE_OPT_VIEWER_MODULES@
More information about the llvm-branch-commits
mailing list