From c54e1625d173fd18853b9a8c77d8777fab65feb6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 14 May 2023 09:34:29 +0300 Subject: [PATCH] scripts: waifulib: compiler_optimizations: fixes for LTO --- scripts/waifulib/compiler_optimizations.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/waifulib/compiler_optimizations.py b/scripts/waifulib/compiler_optimizations.py index 9cc81b7c..67009e4f 100644 --- a/scripts/waifulib/compiler_optimizations.py +++ b/scripts/waifulib/compiler_optimizations.py @@ -99,13 +99,13 @@ CFLAGS = { LTO_CFLAGS = { 'msvc': ['/GL'], - 'gcc': ['-flto'], + 'gcc': ['-flto=auto'], 'clang': ['-flto'] } LTO_LINKFLAGS = { 'msvc': ['/LTCG'], - 'gcc': ['-flto'], + 'gcc': ['-flto=auto'], 'clang': ['-flto'] } @@ -177,4 +177,8 @@ def get_optimization_flags(conf): # remove fvisibility to allow everything to be exported by default cflags.remove('-fvisibility=hidden') + # on all compilers (except MSVC?) we need to copy CFLAGS to LINKFLAGS + if conf.options.LTO and conf.env.COMPILER_CC != 'msvc': + linkflags += cflags + return cflags, linkflags