From 1cd7e3471d5e5b76823b3b0a6b6408f78173841d Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Tue, 27 Apr 2021 13:51:29 -0700 Subject: [PATCH] scons: Add `--with-lto` to enabled LTO; remove `--no-lto` LTO is no longer enabled by default and can instead be enabled by `--with-lto`. Change-Id: I2eea7d447703491675c02730707cf9026cface5f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44887 Reviewed-by: Jason Lowe-Power Reviewed-by: Gabe Black Maintainer: Jason Lowe-Power Tested-by: kokoro --- SConstruct | 15 +++++++-------- src/SConscript | 6 ++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/SConstruct b/SConstruct index f3d65f01c4..53fa124120 100755 --- a/SConstruct +++ b/SConstruct @@ -105,8 +105,8 @@ AddOption('--ignore-style', action='store_true', AddOption('--gold-linker', action='store_true', help='Use the gold linker') AddOption('--no-compress-debug', action='store_true', help="Don't compress debug info in build files") -AddOption('--no-lto', action='store_true', - help='Disable Link-Time Optimization for fast') +AddOption('--with-lto', action='store_true', + help='Enable Link-Time Optimization') AddOption('--verbose', action='store_true', help='Print full tool command lines') AddOption('--without-python', action='store_true', @@ -328,10 +328,9 @@ if main['GCC']: error('gcc version 5 or newer required.\n' 'Installed version:', main['CXXVERSION']) - # Add the appropriate Link-Time Optimization (LTO) flags - # unless LTO is explicitly turned off. Note that these flags - # are only used by the fast target. - if not GetOption('no_lto'): + # Add the appropriate Link-Time Optimization (LTO) flags if `--with-lto` is + # set. + if GetOption('with_lto'): # g++ uses "make" to parallelize LTO. The program can be overriden with # the environment variable "MAKE", but we currently make no attempt to # plumb that variable through. @@ -354,8 +353,8 @@ elif main['CLANG']: error('clang version 3.9 or newer required.\n' 'Installed version:', main['CXXVERSION']) - # If not disabled, set the Link-Time Optimization (LTO) flags. - if not GetOption('no_lto'): + # Set the Link-Time Optimization (LTO) flags if enabled. + if GetOption('with_lto'): for var in 'LTO_CCFLAGS', 'LTO_LDFLAGS': main[var] = ['-flto'] diff --git a/src/SConscript b/src/SConscript index 47aa2eaf9e..bf2d22e1b2 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1435,11 +1435,9 @@ if env['GCC']: # the optimization to the ldflags as LTO defers the optimization # to link time for target in ['opt', 'fast', 'prof', 'perf']: - ccflags[target] += ['-O3'] - ldflags[target] += ['-O3'] + ccflags[target] += ['-O3'] + env['LTO_CCFLAGS'] + ldflags[target] += ['-O3'] + env['LTO_LDFLAGS'] - ccflags['fast'] += env['LTO_CCFLAGS'] - ldflags['fast'] += env['LTO_LDFLAGS'] elif env['CLANG']: ccflags['debug'] += ['-g', '-O0'] # opt, fast, prof and perf all share the same cc flags