From: Martin Quinson Date: Sun, 20 Sep 2015 08:08:38 +0000 (+0200) Subject: allow to specify on cmake command line whether we want LTO X-Git-Tag: v3_12~161 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/100bbcc156ba33bb999af1734f1b870b81812a6b allow to specify on cmake command line whether we want LTO --- diff --git a/tools/cmake/Flags.cmake b/tools/cmake/Flags.cmake index 638c322833..4bc99960be 100644 --- a/tools/cmake/Flags.cmake +++ b/tools/cmake/Flags.cmake @@ -46,26 +46,42 @@ if(enable_compile_optimizations AND CMAKE_COMPILER_IS_GNUCC endif() # Configure LTO -# TODO, provide an option to manually choose whether to use LTO # NOTE, cmake 3.0 has a INTERPROCEDURAL_OPTIMIZATION target # property for this (http://www.cmake.org/cmake/help/v3.0/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html) -set(enable_lto OFF) -if(enable_compile_optimizations - AND CMAKE_COMPILER_IS_GNUCC - AND (NOT enable_model-checking)) - if(WIN32) - if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8") - # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293 - # - # We are experiencing assertion failures even with 4.8 on MinGW. - # Push the support forward: will see if 4.9 works when we test it. +if(enable_lto) # User wants LTO. Try if we can do that + set(enable_lto OFF) + if(enable_compile_optimizations + AND CMAKE_COMPILER_IS_GNUCC + AND (NOT enable_model-checking)) + if(WIN32) + if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8") + # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293 + # + # We are experiencing assertion failures even with 4.8 on MinGW. + # Push the support forward: will see if 4.9 works when we test it. + set(enable_lto ON) + endif() + elseif(LINKER_VERSION STRGREATER "2.22") set(enable_lto ON) endif() - elseif(LINKER_VERSION STRGREATER "2.22") - set(enable_lto ON) endif() + if(enable_lto) + message("-- LTO seems usable.") + else() + if(NOT enable_compile_optimizations) + message("-- LTO disabled: Compile-time optimizations turned off.") + else() + if(enable_model-checking) + message("-- LTO disabled when compiling with model-checking.") + else() + message("-- LTO does not seem usable -- try updating your build chain.") + endif() + endif() + endif() +else() + message("-- LTO disabled on the command line.") endif() -if(enable_lto) +if(enable_lto) # User wants LTO, and it seems usable. Go for it set(optCFLAGS "${optCFLAGS} -flto ") # See https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ#ar.2C_nm_and_ranlib: # "Since version 4.9 gcc produces slim object files that only contain diff --git a/tools/cmake/Option.cmake b/tools/cmake/Option.cmake index 760c89bf9a..4c3bb539e7 100644 --- a/tools/cmake/Option.cmake +++ b/tools/cmake/Option.cmake @@ -50,6 +50,7 @@ mark_as_advanced(enable_print_message) option(enable_model-checking "Turn this on to experiment with our prototype of model-checker (hinders the simulation's performance even if turned off at runtime)" off) option(enable_lib_static "" off) option(enable_lib_in_jar "Whether the native libraries are bundled in a Java jar file" on) +option(enable_lto "Whether we should try to activate the LTO (link time optimisation)" on) option(enable_jedule "Jedule output of SimDAG." off) option(enable_debug "Turn this off to remove all debug messages at compile time (faster, but no debug activatable)" on) option(enable_msg_deprecated "This option enables the use of deprecated MSG functions" off) diff --git a/tools/cmake/PrintArgs.cmake b/tools/cmake/PrintArgs.cmake index ebbdf1a5eb..57e2725c32 100644 --- a/tools/cmake/PrintArgs.cmake +++ b/tools/cmake/PrintArgs.cmake @@ -102,6 +102,7 @@ message("") message(" CFlags ......................: ${CMAKE_C_FLAGS}") message(" CXXFlags ....................: ${CMAKE_CXX_FLAGS}") message(" LDFlags .....................: ${CMAKE_C_LINK_FLAGS}") +message(" with LTO ....................: ${enable_lto}") message("") if (HAVE_NS3)