From: Augustin Degomme Date: Mon, 24 Feb 2020 14:11:22 +0000 (+0100) Subject: add an LTO_EXTRA_FLAG flag for cmake. X-Git-Tag: v3.26~903 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d030a75b32b364f4fa464be3878256cf429f0cee?ds=sidebyside 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. --- 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: