Skip to content

Commit

Permalink
[llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO
Browse files Browse the repository at this point in the history
This symlink was added in 91a3846 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 llvm#82647
  • Loading branch information
tstellar committed Feb 22, 2024
1 parent ff4d6c6 commit 112e69d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions llvm/cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-shlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 112e69d

Please sign in to comment.