optimisation: set gcc-{ar,nm,ranlib} for LTO targets

This commit is contained in:
Danny Robson 2017-05-12 15:57:30 +10:00
parent cec999bfdf
commit e1ac923f32

View File

@ -19,9 +19,9 @@ option(LTO "enable link-time optimisation" OFF)
##----------------------------------------------------------------------------- ##-----------------------------------------------------------------------------
## Enable link-time optimisation. ## Enable link-time optimisation.
## ##
## Rather than rely on the INTERPROCEDURAL_OPTIMISATION flag we add some ## The INTERPROCEDURAL_OPTIMISATION flag is silently ignored for almost all
## arguments explicitly because we want a little more control over object ## compilers. Fuck you too CMake. We have to make up for its deficiencies
## creation. ## ourselves.
if (LTO) if (LTO)
# Add the linker flags first otherwise the linker may not recognise the # Add the linker flags first otherwise the linker may not recognise the
# object format # object format
@ -37,6 +37,15 @@ if (LTO)
# particularly care about checking Debug/Release here because LTO is # particularly care about checking Debug/Release here because LTO is
# pretty heavyweight anyway. # pretty heavyweight anyway.
append_compile_flag("-fdevirtualize-at-ltrans") append_compile_flag("-fdevirtualize-at-ltrans")
# If we're using GCC we probably need to use gcc-{ar,nm,ranlib} so that
# plugin support works. Ideally we'd actually do some compilation tests,
# but... it's a royal PITA with CMake.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set (CMAKE_AR "gcc-ar")
set (CMAKE_NM "gcc-nm")
set (CMAKE_RANLIB "gcc-ranlib")
endif ()
endif () endif ()