From db1d884a9bcd3ea041d89b42bdf1e6ed17de23f9 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 14 Apr 2014 12:38:52 +0200 Subject: [PATCH] don't enable flto if ld version <= 2.22, as there are bugs with some version of GCC Its not clear whether bugs were actually in gcc < 4.7.2 or in the bfl ld version ... example of related bugs : http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53780 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52900 Disabling flto when ld is too old is one of the possible fixes, as ld 2.24 doesn't triggers these bugs. --- CMakeLists.txt | 3 +++ buildtools/Cmake/Flags.cmake | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4803a264c1..edd9041069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,9 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") endif() endif() +exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION") +string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}") + string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}") if(VBC) message(FATAL_ERROR "VB is not yet supported by Simgrid.") diff --git a/buildtools/Cmake/Flags.cmake b/buildtools/Cmake/Flags.cmake index 5e959e3602..675587b54c 100644 --- a/buildtools/Cmake/Flags.cmake +++ b/buildtools/Cmake/Flags.cmake @@ -36,7 +36,7 @@ if(enable_compile_optimizations) endif() else() # On non-windows, 4.6 is enough for that - if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5") + if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5" AND LINKER_VERSION STRGREATER "2.22") set(optCFLAGS "${optCFLAGS} -flto ") endif() endif() -- 2.20.1