[PATCH] D38665: [CMake] Fix linker detection in AddLLVM.cmake
Oleksii Vilchanskyi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 7 05:33:37 PDT 2017
light2yellow created this revision.
Herald added a subscriber: mgorny.
Fix linker not being correctly detected when a custom one is specified
through LLVM_USE_LINKER CMake variable.
In particular,
`cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=gold ../llvm`
resulted into
`-- Linker detection: GNU ld`
instead of
`-- Linker detection: GNU Gold`
due to the construction not accounting for such variable. It led to the general
confusion and prevented setting linker-specific flags inside functions defined
in AddLLVM.cmake.
https://reviews.llvm.org/D38665
Files:
cmake/modules/AddLLVM.cmake
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -149,8 +149,13 @@
if(NOT WIN32 AND NOT APPLE)
# Detect what linker we have here
+ if( LLVM_USE_LINKER )
+ set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} -Wl,--version)
+ else()
+ set(command ${CMAKE_C_COMPILER} -Wl,--version)
+ endif()
execute_process(
- COMMAND ${CMAKE_C_COMPILER} -Wl,--version
+ COMMAND ${command}
OUTPUT_VARIABLE stdout
ERROR_VARIABLE stderr
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38665.118132.patch
Type: text/x-patch
Size: 587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171007/77e09d72/attachment.bin>
More information about the llvm-commits
mailing list