diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-02 03:01:12 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-02 03:01:12 +0000 |
commit | 414fbb4549ca667e31207b8a86499236df7eadbf (patch) | |
tree | 7923af26c1b2a81f14f2b577a941b57c80941cbc | |
parent | a528e747353fe38cc305ae4aa66c295f6a1e3138 (diff) | |
download | bcm5719-llvm-414fbb4549ca667e31207b8a86499236df7eadbf.tar.gz bcm5719-llvm-414fbb4549ca667e31207b8a86499236df7eadbf.zip |
cmake: Configure the ThinLTO cache directory when using ELF lld or gold.
Differential Revision: https://reviews.llvm.org/D30522
llvm-svn: 296730
-rw-r--r-- | llvm/cmake/modules/HandleLLVMOptions.cmake | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index d776285b80f..8d9051cfdd7 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/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) |