[llvm] r307852 - [Solaris] Detect Solaris LD, use detection results to pass Solaris-ld options
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 14:43:14 PDT 2017
Author: ruiu
Date: Wed Jul 12 14:43:14 2017
New Revision: 307852
URL: http://llvm.org/viewvc/llvm-project?rev=307852&view=rev
Log:
[Solaris] Detect Solaris LD, use detection results to pass Solaris-ld options
Solaris ld is not the only linker available on Solaris.
Introducing linker detection and using LLVM_LINKER_IS_SOLARISLD to
select Solaris-ld specific handling.
Patch by: Fedor Sergeev
Differential Revision: https://reviews.llvm.org/D35325
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=307852&r1=307851&r2=307852&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed Jul 12 14:43:14 2017
@@ -91,7 +91,7 @@ function(add_llvm_symbol_exports target_
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 @@ function(add_llvm_symbol_exports target_
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()
More information about the llvm-commits
mailing list