From d05c4fa9ed08abcec4ec1b861d3c10d31d420d59 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Sun, 11 May 2014 01:44:13 +0200 Subject: [PATCH] Fix lto option in gcc 4.9 by using gcc-ar / gcc-ranlib --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76ec81072..4cf1ec966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,8 +107,16 @@ endif() # Check if LTO is available set(LTO_FLAGS "") CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) -if (HAS_LTO_FLAG) +if (HAS_LTO_FLAG) set(LTO_FLAGS "${LTO_FLAGS} -flto") + + # Since gcc 4.9 the LTO format is non-standart ('slim'), so we need to use the build-in tools + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9.0") + message(STATUS "Using gcc specific binutils for LTO.") + set(CMAKE_AR "/usr/bin/gcc-ar") + set(CMAKE_RANLIB "/usr/bin/gcc-ranlib") + endif() endif (HAS_LTO_FLAG) # disable partitioning of LTO process when possible (fixes Debian issues)