[llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660)

This symlink was added in 91a384621e5b762d9c173ffd247cfeadd5f436a2 to
maintain backwards compatibility, but it needs to point to
libLLVM.so.$MAJOR.$MINOR rather than libLLVM.so. This works better for
distros that ship libLLVM.so and libLLVM.so.$MAJOR.$MINOR in separate
packages and also prevents mistakes like
libLLVM-19.so -> libLLVM.so -> libLLVM.so.18.1

Fixes #82647

(cherry picked from commit 10c48a772742b7afe665a815b7eba2047f17dc4b)
This commit is contained in:
Tom Stellard 2024-02-23 15:58:32 -08:00
parent d1a1d7afb1
commit 4cc7a75aa6
2 changed files with 8 additions and 4 deletions

View File

@ -2074,7 +2074,7 @@ function(add_lit_testsuites project directory)
endfunction()
function(llvm_install_library_symlink name dest type)
cmake_parse_arguments(ARG "" "COMPONENT" "" ${ARGN})
cmake_parse_arguments(ARG "" "COMPONENT;SOVERSION" "" ${ARGN})
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
@ -2088,7 +2088,11 @@ function(llvm_install_library_symlink name dest type)
endif()
set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
if (ARG_SOVERSION)
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}.${ARG_SOVERSION})
else()
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
endif()
if(LLVM_USE_SYMLINKS)
set(LLVM_LINK_OR_COPY create_symlink)

View File

@ -35,8 +35,8 @@ if(LLVM_BUILD_LLVM_DYLIB)
endif()
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)
get_target_property(LLVM_DYLIB_SOVERSION LLVM SOVERSION)
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} LLVM SHARED COMPONENT LLVM SOVERSION ${LLVM_DYLIB_SOVERSION})
list(REMOVE_DUPLICATES LIB_NAMES)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")