[PATCH] D45464: [cmake] Make linker detection take flags into account

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 15:38:25 PDT 2018


smeenai created this revision.
smeenai added a reviewer: beanz.
Herald added a subscriber: mgorny.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D45464

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -152,7 +152,9 @@
   if( LLVM_USE_LINKER )
     set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} -Wl,--version)
   else()
-    set(command ${CMAKE_C_COMPILER} -Wl,--version)
+    string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
+    separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${build_type}}")
+    set(command ${CMAKE_C_COMPILER} ${flags} -Wl,--version)
   endif()
   execute_process(
     COMMAND ${command}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45464.141757.patch
Type: text/x-patch
Size: 636 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180409/a453f6e7/attachment.bin>


More information about the llvm-commits mailing list