Author: Aaron Puchert Date: 2024-11-20T03:28:54+01:00 New Revision: 461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c
URL: https://github.com/llvm/llvm-project/commit/461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c DIFF: https://github.com/llvm/llvm-project/commit/461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c.diff LOG: Introduce symbol versioning for clang-cpp (#116556) The situation that required symbol versions on the LLVM shared library can also happen for clang-cpp, although it is less common: different tools require different versions of the library, and through transitive dependencies a process ends up with multiple copies of clang-cpp. This causes havoc with ELF, because calls meant to go one version of the library end up with another. I've also considered introducing a symbol version globally, but for example the clang (C) library and other targets outside of LLVM/Clang, e.g. libc++, would not want that. So it's probably best if we keep it to those libraries. Added: clang/tools/clang-shlib/simple_version_script.map.in Modified: clang/tools/clang-shlib/CMakeLists.txt llvm/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index 298d3a9d18fec8..2b07d0083c4359 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -48,6 +48,14 @@ add_clang_library(clang-cpp ${_OBJECTS} LINK_LIBS ${_DEPS}) + +configure_file(simple_version_script.map.in simple_version_script.map) + +if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD) + # Solaris ld does not accept global: *; so there is no way to version *all* global symbols + target_link_options(clang-cpp PRIVATE LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map) +endif() + # Optimize function calls for default visibility definitions to avoid PLT and # reduce dynamic relocations. if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS) diff --git a/clang/tools/clang-shlib/simple_version_script.map.in b/clang/tools/clang-shlib/simple_version_script.map.in new file mode 100644 index 00000000000000..cb2306d1f59682 --- /dev/null +++ b/clang/tools/clang-shlib/simple_version_script.map.in @@ -0,0 +1 @@ +@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; }; diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 74b72c98253413..cfcf1404d82b7c 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -27,7 +27,7 @@ if (NOT PACKAGE_VERSION) endif() if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION) - # "Symbol version prefix for libLLVM.so" + # "Symbol version prefix for libLLVM.so and libclang-cpp.so" set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") endif() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits