Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add an LTO_EXTRA_FLAG flag for cmake.
authorAugustin Degomme <adegomme@gmail.com>
Mon, 24 Feb 2020 14:11:22 +0000 (15:11 +0100)
committerAugustin Degomme <adegomme@gmail.com>
Mon, 24 Feb 2020 14:49:11 +0000 (15:49 +0100)
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

index 740e7f5..d44d17c 100644 (file)
@@ -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: