0001-cmake-Allow-shared-libraries-to-customize-the-soname.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From 3dc5722d5c7673a879f2b4680369d3ac8b6b64b6 Mon Sep 17 00:00:00 2001
  2. From: Tom Stellard <tstellar@redhat.com>
  3. Date: Wed, 4 Aug 2021 14:05:38 -0700
  4. Subject: [PATCH] cmake: Allow shared libraries to customize the soname using
  5. LLVM_ABI_REVISION
  6. The LLVM_ABI_REVISION variable is intended to be used for release
  7. candidates which introduce an ABI change to a shared library. This
  8. variable can be specified per library, so there is not one global value
  9. for all of LLVM.
  10. For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library
  11. compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for
  12. library will be incremented by 1.
  13. In the main branch, LLVM_ABI_REVISION should always be 0, it is only
  14. meant to be used in the release branch.
  15. Differential Revision: https://reviews.llvm.org/D105594
  16. ---
  17. llvm/cmake/modules/AddLLVM.cmake | 7 +++++--
  18. llvm/tools/llvm-shlib/CMakeLists.txt | 9 +++++++++
  19. 3 files changed, 19 insertions(+), 2 deletions(-)
  20. diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
  21. index 3e009f5061d3..a09405a1be3e 100644
  22. --- a/llvm/cmake/modules/AddLLVM.cmake
  23. +++ b/llvm/cmake/modules/AddLLVM.cmake
  24. @@ -586,11 +586,14 @@ function(llvm_add_library name)
  25. # Set SOVERSION on shared libraries that lack explicit SONAME
  26. # specifier, on *nix systems that are not Darwin.
  27. if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
  28. + if (NOT LLVM_ABI_REVISION)
  29. + set(LLVM_ABI_REVISION 0)
  30. + endif()
  31. set_target_properties(${name}
  32. PROPERTIES
  33. # Since 4.0.0, the ABI version is indicated by the major version
  34. - SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
  35. - VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
  36. + SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION}
  37. + VERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION})
  38. endif()
  39. endif()
  40. diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
  41. index 76b9a25cbbcd..b876e7fed6b5 100644
  42. --- a/llvm/tools/llvm-shlib/CMakeLists.txt
  43. +++ b/llvm/tools/llvm-shlib/CMakeLists.txt
  44. @@ -2,6 +2,11 @@
  45. # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake
  46. # commandline. By default the shared library only exports the LLVM C API.
  47. +# In the main branch, LLVM_ABI_REVISION should always be 0. In the release
  48. +# branches, this should be incremented before each release candidate every
  49. +# time the ABI of libLLVM.so changes.
  50. +set(LLVM_ABI_REVISION 0 CACHE STRING "ABI Revision number for SONAMEs (default: 0)")
  51. +
  52. set(SOURCES
  53. libllvm.cpp
  54. )
  55. @@ -67,6 +72,10 @@ if(LLVM_BUILD_LLVM_DYLIB)
  56. set_property(TARGET LLVM APPEND_STRING PROPERTY
  57. LINK_FLAGS
  58. " -compatibility_version 1 -current_version ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
  59. + else()
  60. + set_target_properties(LLVM
  61. + PROPERTIES
  62. + SOVERSION ${LLVM_ABI_REVISION})
  63. endif()
  64. if(TARGET libLLVMExports)
  65. --
  66. 2.27.0