optimisation: try to set -flto=auto where available

This removes a warning from GCC about serialisation of LTO compilation
jobs.

Though it shouldn't really be using the 'auto' value as it is liable to
flood the system with jobs.
This commit is contained in:
Danny Robson 2022-08-23 13:36:01 +10:00
parent 3b9eb09ba5
commit 3b696fffb4
1 changed files with 12 additions and 2 deletions

View File

@ -26,11 +26,21 @@ if (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")
# HACK: we shouldn't use 'auto' as it will likely lead to oversubscription
# but I'm sick of holding GCC's hand today.
append_first_link_flag("-flto=auto" "-flto")
# Enable LTO on the compilation side, but try very hard to avoid
# situations where we may accidentally use regular/fat objects.
append_compile_flag("-flto")
#
# GCC 12 will emit a warning about serial compilation of LTRANS jobs if an
# explicit parameter is not passed. It must be an integer, auto, or
# jobserver.
# Clang will only accept 'full', 'thin', or no argument.
#
# HACK: we shouldn't use 'auto' as it will likely lead to oversubscription
# but I'm sick of holding GCC's hand today.
append_first_compile_flag("-flto=auto" "-flto")
append_compile_flag("-fno-fat-lto-objects")
append_compile_flag("-flto-jobs=0")