diff options
author | Shoaib Meenai <smeenai@fb.com> | 2018-06-14 23:26:33 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2018-06-14 23:26:33 +0000 |
commit | 4ec881844ea67b9edfe9e5ea548df6e2e4b5929c (patch) | |
tree | b3ee87e1cc6b33ac74493ffa714fd31371155a3f /cmake/modules | |
parent | caa16eabb4f319b8710e2379e138696b1f1d0232 (diff) |
[cmake] Add linker detection for Apple platforms
LLVM currently assumes that Apple platforms will always use ld64. In the
future, LLD Mach-O might also be supported, so add the beginnings of
linker detection support. ld64 is currently the only detected linker,
since `ld64.lld -v` doesn't yield any useful version output, but we can
add that detection later, and in the meantime it's still useful to have
the ld64 identification.
Switch clang's order file check to use this new detection rather than
just checking for the presence of an ld64 executable.
Differential Revision: https://reviews.llvm.org/D48201
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/AddLLVM.cmake | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index d631fcc0f05..2e0d4a4c6c8 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -147,7 +147,20 @@ function(add_llvm_symbol_exports target_name export_file) set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE) endfunction(add_llvm_symbol_exports) -if(NOT WIN32 AND NOT APPLE) +if(APPLE) + execute_process( + COMMAND "${CMAKE_LINKER}" -v + ERROR_VARIABLE stderr + ) + set(LLVM_LINKER_DETECTED ON) + if("${stderr}" MATCHES "PROJECT:ld64") + set(LLVM_LINKER_IS_LD64 ON) + message(STATUS "Linker detection: ld64") + else() + set(LLVM_LINKER_DETECTED OFF) + message(STATUS "Linker detection: unknown") + endif() +elseif(NOT WIN32) # Detect what linker we have here if( LLVM_USE_LINKER ) set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} -Wl,--version) |