From d030a75b32b364f4fa464be3878256cf429f0cee Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 24 Feb 2020 15:11:22 +0100 Subject: [PATCH] add an LTO_EXTRA_FLAG flag for cmake. This enables to give "auto", to use all cores, a number to use n cores and speedup linking phase. flto=auto should be enabled by default in GCC 10, so this option can be used to give a lower value in case resources are scarce. --- tools/cmake/Flags.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/cmake/Flags.cmake b/tools/cmake/Flags.cmake index 740e7f5d8c..d44d17c10b 100644 --- a/tools/cmake/Flags.cmake +++ b/tools/cmake/Flags.cmake @@ -143,6 +143,10 @@ else() endif() if(enable_lto) # User wants LTO, and it seems usable. Go for it set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + if(LTO_EXTRA_FLAG AND CMAKE_COMPILER_IS_GNUCC) + list(APPEND CMAKE_C_COMPILE_OPTIONS_IPO "-flto=${LTO_EXTRA_FLAG}") + list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=${LTO_EXTRA_FLAG}") + endif() # "Since version 4.9 gcc produces slim object files that only contain # the intermediate representation. In order to handle archives of # these objects you have to use the gcc wrappers: -- 2.20.1