$NetBSD: patch-tools_llvm-shlib_CMakeLists.txt,v 1.1 2019/01/26 20:14:02 tnn Exp $

Use the Linux style linking everywhere except Darwin and SunOS.

--- tools/llvm-shlib/CMakeLists.txt.orig	2016-05-26 04:35:35.000000000 +0000
+++ tools/llvm-shlib/CMakeLists.txt
@@ -37,11 +37,12 @@ endif()
 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"
-  # GNU ld doesn't resolve symbols in the version script.
-  set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
   set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
+  set(LIB_NAMES -Wl,-Bsymbolic -Wl,-z -Wl,allextract ${LIB_NAMES} -Wl,-z -Wl,defaultextract)
+else()
+  set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
 endif()
 
 target_link_libraries(LLVM PRIVATE ${LIB_NAMES})
