From a46204ef9e8f63c5ee0416e75dc0a564db848dff Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 15 Nov 2015 13:54:47 +0100 Subject: [PATCH] cmake: add a USE_LTO option Note: nothing work so don't use it. --- cmake/BuildParameters.cmake | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index b5836e4203..e00befa81a 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -231,6 +231,8 @@ endif() #------------------------------------------------------------------------------- # Set some default compiler flags #------------------------------------------------------------------------------- +option(USE_LTO "Enable LTO optimization (will likely break the build)") + set(COMMON_FLAG "-pipe -fvisibility=hidden -pthread -fno-builtin-strcmp -fno-builtin-memcmp") if (DISABLE_SVU) set(COMMON_FLAG "${COMMON_FLAG} -DDISABLE_SVU") @@ -254,6 +256,18 @@ else() set(DBG "-ggdb") endif() +if (USE_LTO) + #gcc --print-file-name=liblto_plugin.so + #set(LTO_FLAGS "-fuse-linker-plugin -flto=4 --plugin=/usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so") + #set(LTO_FLAGS "-fuse-linker-plugin -fuse-ld=gold -flto=4 --plugin=/usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so") + set(LTO_FLAGS "-fuse-linker-plugin -fuse-ld=gold -flto=4") + #set(LINK_FLAGS "--plugin=/usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so") + set(USER_CMAKE_LD_FLAGS "--plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so") + set(DBG "") # not supported with LTO +else() + set(LTO_FLAGS "") +endif() + if(CMAKE_BUILD_TYPE MATCHES "Debug") set(DEBUG_FLAG "${DBG}") elseif(CMAKE_BUILD_TYPE MATCHES "Devel") @@ -284,7 +298,7 @@ else() endif() # Note: -DGTK_DISABLE_DEPRECATED can be used to test a build without gtk deprecated feature. It could be useful to port to a newer API -set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${AGGRESSIVE_WARNING} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG} ${OPTIMIZATION_FLAG}") +set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${AGGRESSIVE_WARNING} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG} ${OPTIMIZATION_FLAG} ${LTO_FLAGS}") # c++ only flags set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -std=c++11 -Wno-invalid-offsetof")