From 5e2e245a64ac692ba5e6f22ea5187ec68c691ca1 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 28 Oct 2016 20:48:47 +0000 Subject: [PATCH] cmake: Enable the lto cache when building with -flto=thin on darwin llvm-svn: 285450 --- cmake/modules/HandleLLVMOptions.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 3c1d0d7e7b1..3abe57a5e3f 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -647,6 +647,11 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") append("-flto=thin" CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) + # 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) elseif(uppercase_LLVM_ENABLE_LTO STREQUAL "FULL") append("-flto=full" CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)