[llvm] r330924 - [cmake] Make linker detection take flags into account

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 25 23:04:47 PDT 2018


Author: smeenai
Date: Wed Apr 25 23:04:46 2018
New Revision: 330924

URL: http://llvm.org/viewvc/llvm-project?rev=330924&view=rev
Log:
[cmake] Make linker detection take flags into account

LLVM might be compiled using a toolchain file which controls the linker
to use via flags (e.g. `-B` or `-fuse-ld=`). Take these flags into
account for linker detection. We can also correct the detection by
manually passing LLVM_USE_LINKER, of course, but it seems more
convenient to have the detection take flags into account.

Differential Revision: https://reviews.llvm.org/D45464

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=330924&r1=330923&r2=330924&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed Apr 25 23:04:46 2018
@@ -152,7 +152,8 @@ if(NOT WIN32 AND NOT APPLE)
   if( LLVM_USE_LINKER )
     set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} -Wl,--version)
   else()
-    set(command ${CMAKE_C_COMPILER} -Wl,--version)
+    separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
+    set(command ${CMAKE_C_COMPILER} ${flags} -Wl,--version)
   endif()
   execute_process(
     COMMAND ${command}




More information about the llvm-commits mailing list