From 3b696fffb4e262f31916c9638d4c02d5311a4af9 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 23 Aug 2022 13:36:01 +1000 Subject: [PATCH] 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. --- nc_optimisation.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nc_optimisation.cmake b/nc_optimisation.cmake index b2b097c..95a589a 100644 --- a/nc_optimisation.cmake +++ b/nc_optimisation.cmake @@ -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")