[PATCH] D51804: [CMake] Fix LTO option on Windows

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 7 11:02:34 PDT 2018


aganea created this revision.
aganea added reviewers: inglorion, hans, rnk.
Herald added subscribers: llvm-commits, dexonsmith, mehdi_amini, mgorny.

Previously, the option `LLVM_ENABLE_LLD` was not adequatly taken into account when using `LLVM_ENABLE_LTO` on Windows.

The picture below shows the problem before the patch. `CMAKE_LINKER` says `lld-link.exe`, however when running configure, `CMAKE_LINKER` is back to `link.exe` (the message was printed in `HandleLLVMOptions.cmake`. This is probably caused by `CMakeCXXCompiler.cmake` which indeed overrides `CMAKE_LINKER` (I'm using CMake 3.12.0).

F7151111: cmake_error.png <https://reviews.llvm.org/F7151111>

This causes `LINKER_IS_LLD_LINK` not being set, which in turns prevents using LTO.


Repository:
  rL LLVM

https://reviews.llvm.org/D51804

Files:
  cmake/modules/HandleLLVMOptions.cmake


Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -11,7 +11,7 @@
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 
-if(CMAKE_LINKER MATCHES "lld-link.exe" OR (WIN32 AND LLVM_USE_LINKER STREQUAL "lld"))
+if(CMAKE_LINKER MATCHES "lld-link.exe" OR (WIN32 AND LLVM_USE_LINKER STREQUAL "lld") OR LLVM_ENABLE_LLD)
   set(LINKER_IS_LLD_LINK TRUE)
 else()
   set(LINKER_IS_LLD_LINK FALSE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51804.164458.patch
Type: text/x-patch
Size: 543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180907/8b95efb6/attachment.bin>


More information about the llvm-commits mailing list