From 760f45eacadbabf9634fb81d7ccaa16c269cf19e Mon Sep 17 00:00:00 2001 From: Tobias Hieta Date: Mon, 25 May 2020 10:28:17 +0300 Subject: [PATCH] [CMake] Properly handle the LTO cache arguments for MinGW We want to make sure that LINKER_IS_LLD_LINK is properly set - in this case it shouldn't be set when building for MinGW. Then we want to make the test for it correct and finally include the option to build with thinlto cache since the MinGW driver now supports that. Differential Revision: https://reviews.llvm.org/D80493 --- llvm/cmake/modules/HandleLLVMOptions.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index b50100f..d5c924c 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -13,7 +13,7 @@ include(CheckCXXCompilerFlag) include(CheckSymbolExists) include(CMakeDependentOption) -if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL "lld") OR LLVM_ENABLE_LLD) +if(CMAKE_LINKER MATCHES "lld-link" OR (MSVC AND (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD))) set(LINKER_IS_LLD_LINK TRUE) else() set(LINKER_IS_LLD_LINK FALSE) @@ -941,7 +941,7 @@ if (LLVM_BUILD_INSTRUMENTED AND LLVM_BUILD_INSTRUMENTED_COVERAGE) message(FATAL_ERROR "LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE cannot both be specified") endif() -if(LLVM_ENABLE_LTO AND LLVM_ON_WIN32 AND NOT LINKER_IS_LLD_LINK) +if(LLVM_ENABLE_LTO AND LLVM_ON_WIN32 AND NOT LINKER_IS_LLD_LINK AND NOT MINGW) message(FATAL_ERROR "When compiling for Windows, LLVM_ENABLE_LTO requires using lld as the linker (point CMAKE_LINKER at lld-link.exe)") endif() if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") @@ -956,7 +956,7 @@ if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") if(APPLE) append("-Wl,-cache_path_lto,${PROJECT_BINARY_DIR}/lto.cache" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) - elseif(UNIX AND LLVM_USE_LINKER STREQUAL "lld") + elseif((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "lld") append("-Wl,--thinlto-cache-dir=${PROJECT_BINARY_DIR}/lto.cache" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) elseif(LLVM_USE_LINKER STREQUAL "gold") -- 2.7.4