Skip to content

Conversation

@tstellar
Copy link
Collaborator

@tstellar tstellar commented Oct 1, 2024

We do the same thing for libLLVM.so. This should help avoid issues when an applications loads two different versions of the library at the same time.

We do the same thing for libLLVM.so.  This should help avoid issues
when an applications loads two different versions of the library at
the same time.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2024

@llvm/pr-subscribers-clang

Author: Tom Stellard (tstellar)

Changes

We do the same thing for libLLVM.so. This should help avoid issues when an applications loads two different versions of the library at the same time.


Full diff: https://github.com/llvm/llvm-project/pull/110758.diff

2 Files Affected:

  • (modified) clang/tools/clang-shlib/CMakeLists.txt (+7)
  • (added) clang/tools/clang-shlib/simple_version_script.map.in (+1)
diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..004ce2897960ca 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -61,3 +61,10 @@ if (MINGW OR CYGWIN)
   # make sure we export all symbols despite potential dllexports.
   target_link_options(clang-cpp PRIVATE LINKER:--export-all-symbols)
 endif()
+
+# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
+if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+	         ${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+  target_link_options(clang-cpp PRIVATE -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+endif()
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: *; };

@nikic
Copy link
Contributor

nikic commented Nov 21, 2024

Closing this in favor of the merged #116556.

@nikic nikic closed this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants