[PATCH] D80873: [clang][cmake] Force CMAKE_LINKER for multistage build in case of BOOTSTRAP_LLVM_ENABLE_LLD and MSVC
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 06:13:07 PDT 2020
krisb updated this revision to Diff 277806.
krisb edited the summary of this revision.
krisb added a comment.
Changed MSVC -> WIN32 check and simplified the warning fix.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80873/new/
https://reviews.llvm.org/D80873
Files:
clang/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -261,7 +261,12 @@
if ( LLVM_USE_LINKER )
message(FATAL_ERROR "LLVM_ENABLE_LLD and LLVM_USE_LINKER can't be set at the same time")
endif()
- set(LLVM_USE_LINKER "lld")
+ # In case of MSVC cmake always invokes the linker directly, so the linker
+ # should be specified by CMAKE_LINKER cmake variable instead of by -fuse-ld
+ # compiler option.
+ if ( NOT MSVC )
+ set(LLVM_USE_LINKER "lld")
+ endif()
endif()
if( LLVM_USE_LINKER )
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -745,6 +745,14 @@
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
-DCMAKE_ASM_COMPILER_ID=Clang)
+ # cmake requires CMAKE_LINKER to be specified if the compiler is MSVC-like,
+ # otherwise it defaults the linker to be link.exe.
+ if(BOOTSTRAP_LLVM_ENABLE_LLD)
+ if(WIN32 AND NOT BOOTSTRAP_CMAKE_SYSTEM_NAME)
+ set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link.exe)
+ endif()
+ endif()
+
if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
set(${CLANG_STAGE}_TABLEGEN
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80873.277806.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/b3f65679/attachment.bin>
More information about the llvm-commits
mailing list