optimisation: use a more reliable LTO flag test order

This commit is contained in:
Danny Robson 2017-01-25 18:45:42 +11:00
parent dfdf4da1b1
commit 7fea529319

View File

@ -8,12 +8,27 @@ option(ENABLE_LTO "enable link-time optimisation" OFF)
##----------------------------------------------------------------------------- ##-----------------------------------------------------------------------------
## Enable link-time optimisation.
##
## Rather than rely on the INTERPROCEDURAL_OPTIMISATION flag we add some
## arguments explicitly because we want a little more control over object
## creation.
if (ENABLE_LTO) if (ENABLE_LTO)
# Add the linker flags first otherwise the linker may not recognise the
# object format
append_link_flag("-fuse-linker-plugin")
append_link_flag("-flto")
# Actually enable LTO object creation, but try very hard to avoid
# situations where we may accidentally use regular/fat objects.
append_compile_flag("-flto") append_compile_flag("-flto")
append_compile_flag("-fno-fat-lto-objects") append_compile_flag("-fno-fat-lto-objects")
append_link_flag("-fuse-linker-plugin")
append_compile_flags("-fdevirtualize-at-ltrans") # Throw in some optimisation flags that are LTO specific. We don't
endif (ENABLE_LTO) # particularly care about checking Debug/Release here because LTO is
# pretty heavyweight anyway.
append_compile_flag("-fdevirtualize-at-ltrans")
endif ()
############################################################################### ###############################################################################