llvm.org GIT mirror llvm / c831070
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 Rui Ueyama 1 year, 11 months ago
1 changed file(s) with 4 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
193193 endif()
194194
195195 if( LLVM_USE_LINKER )
196 check_cxx_compiler_flag("-fuse-ld=${LLVM_USE_LINKER}" CXX_SUPPORTS_CUSTOM_LINKER)
196 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
197 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
198 check_cxx_source_compiles("int main() { return 0; }" CXX_SUPPORTS_CUSTOM_LINKER)
197199 if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
198200 message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
199201 endif()
202 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
200203 append("-fuse-ld=${LLVM_USE_LINKER}"
201204 CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
202205 endif()