summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-03-15 16:28:43 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-03-15 16:28:43 +0000
commit603d3c6be1966c7a2fef4886d94eb668adf68581 (patch)
tree52875fd7b62eb791ecee1cef4b1331b64d0ff2f5 /cmake
parentcbe96ddc5f952c02abf6109d313f7cf19e4f054e (diff)
Re-apply r296730, "cmake: Configure the ThinLTO cache directory when using ELF lld or gold."
All known cache-related bugs observed when self hosting have been fixed (r296907 and r297853). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297854 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake19
1 files changed, 14 insertions, 5 deletions
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index d776285b80fe..8d9051cfdd7c 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -715,11 +715,20 @@ if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
if(NOT LINKER_IS_LLD_LINK)
append("-flto=thin" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
- # On darwin, enable the lto cache. This improves initial build time a little
- # since we re-link a lot of the same objects, and significantly improves
- # incremental build time.
- append_if(APPLE "-Wl,-cache_path_lto,${PROJECT_BINARY_DIR}/lto.cache"
- CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ # If the linker supports it, enable the lto cache. This improves initial build
+ # time a little since we re-link a lot of the same objects, and significantly
+ # improves incremental build time.
+ # FIXME: We should move all this logic into the clang driver.
+ 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")
+ append("-Wl,--thinlto-cache-dir=${PROJECT_BINARY_DIR}/lto.cache"
+ CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ elseif(LLVM_USE_LINKER STREQUAL "gold")
+ append("-Wl,--plugin-opt,cache-dir=${PROJECT_BINARY_DIR}/lto.cache"
+ CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ endif()
elseif(uppercase_LLVM_ENABLE_LTO STREQUAL "FULL")
append("-flto=full" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
if(NOT LINKER_IS_LLD_LINK)