[PATCH] D35325: [Solaris] detect Solaris LD, use detection results to pass Solaris-ld options

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 14:25:23 PDT 2017


fedor.sergeev updated this revision to Diff 106306.
fedor.sergeev retitled this revision from "[CMake] linker detection now handles Gnu LD, Solaris LD and LLD" to "[Solaris] detect Solaris LD, use detection results to pass Solaris-ld options".
fedor.sergeev edited the summary of this revision.
fedor.sergeev added a comment.

One usage of LLVM_LINKER_IS_SOLARISLD added.


https://reviews.llvm.org/D35325

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -91,7 +91,7 @@
       DEPENDS ${export_file}
       VERBATIM
       COMMENT "Creating export file for ${target_name}")
-    if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+    if (${LLVM_LINKER_IS_SOLARISLD})
       set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                    LINK_FLAGS "  -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
     else()
@@ -148,13 +148,28 @@
 endfunction(add_llvm_symbol_exports)
 
 if(NOT WIN32 AND NOT APPLE)
+  # Detect what linker we have here
   execute_process(
     COMMAND ${CMAKE_C_COMPILER} -Wl,--version
     OUTPUT_VARIABLE stdout
-    ERROR_QUIET
+    ERROR_VARIABLE stderr
     )
+  set(LLVM_LINKER_DETECTED ON)
   if("${stdout}" MATCHES "GNU gold")
     set(LLVM_LINKER_IS_GOLD ON)
+    message(STATUS "Linker detection: GNU Gold")
+  elseif("${stdout}" MATCHES "^LLD")
+    set(LLVM_LINKER_IS_LLD ON)
+    message(STATUS "Linker detection: LLD")
+  elseif("${stdout}" MATCHES "GNU ld")
+    set(LLVM_LINKER_IS_GNULD ON)
+    message(STATUS "Linker detection: GNU ld")
+  elseif("${stderr}" MATCHES "Solaris Link Editors")
+    set(LLVM_LINKER_IS_SOLARISLD ON)
+    message(STATUS "Linker detection: Solaris ld")
+  else()
+    set(LLVM_LINKER_DETECTED OFF)
+    message(STATUS "Linker detection: unknown")
   endif()
 endif()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35325.106306.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170712/a1aa30c8/attachment.bin>


More information about the llvm-commits mailing list