summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-10-30 21:19:54 +0000
committerRui Ueyama <ruiu@google.com>2017-10-30 21:19:54 +0000
commitc831070a703f899237ea27c425b97bb6f0bc49be (patch)
tree3c1e45a9d6c202715bce4f9cd298c58159852675 /cmake
parent2bd22dfce737d1731a4c9df6a1a424ef57bed0c5 (diff)
Fix -fuse-ld feature detection error.
check_cxx_compiler_flag doesn't seem to try to link a program, so the existing code doesn't correctly detect the availability of a given linker. This patch uses check_cxx_source_compiles instead. I confirmed that cmake now reports this error Host compiler does not support '-fuse-ld=foo' for -DLLVM_USE_LINKER=foo. Differential Revision: https://reviews.llvm.org/D39274 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 76683c351d8..03b96645249 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -194,10 +194,13 @@ if( LLVM_ENABLE_LLD )
endif()
if( LLVM_USE_LINKER )
- check_cxx_compiler_flag("-fuse-ld=${LLVM_USE_LINKER}" CXX_SUPPORTS_CUSTOM_LINKER)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
+ check_cxx_source_compiles("int main() { return 0; }" CXX_SUPPORTS_CUSTOM_LINKER)
if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
endif()
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
append("-fuse-ld=${LLVM_USE_LINKER}"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()