diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index aa7fcd1efed4..054c7d59ec34 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 LLVM_LINKER_IS_SOLARISLD AND NOT MINGW) + # 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) 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 000000000000..cb2306d1f596 --- /dev/null +++ b/clang/tools/clang-shlib/simple_version_script.map.in @@ -0,0 +1 @@ +@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; };