diff tools/llvm-shlib/CMakeLists.txt @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents 1172e4bd9c6f
children c2174574ed3a
line wrap: on
line diff
--- a/tools/llvm-shlib/CMakeLists.txt	Fri Nov 25 19:14:25 2016 +0900
+++ b/tools/llvm-shlib/CMakeLists.txt	Fri Oct 27 17:07:41 2017 +0900
@@ -37,15 +37,30 @@
 add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
 
 list(REMOVE_DUPLICATES LIB_NAMES)
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf"
+if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
+   OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+   OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
+   OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
+  configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+  ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
+
   # GNU ld doesn't resolve symbols in the version script.
   set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
+  if (NOT LLVM_LINKER_IS_SOLARISLD)
+    # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
+    set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
+  endif()
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
   set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
 endif()
 
 target_link_libraries(LLVM PRIVATE ${LIB_NAMES})
 
+if (LLVM_DYLIB_SYMBOL_VERSIONING)
+  set_property(TARGET LLVM APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--default-symver")
+endif()
+
 if (APPLE)
   set_property(TARGET LLVM APPEND_STRING PROPERTY
               LINK_FLAGS