diff --git a/SConstruct b/SConstruct index 3e2df39cfb..f3d65f01c4 100755 --- a/SConstruct +++ b/SConstruct @@ -328,7 +328,9 @@ if main['GCC']: error('gcc version 5 or newer required.\n' 'Installed version:', main['CXXVERSION']) - # If not disabled, set the Link-Time Optimization (LTO) flags. + # 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'): # g++ uses "make" to parallelize LTO. The program can be overriden with # the environment variable "MAKE", but we currently make no attempt to diff --git a/src/SConscript b/src/SConscript index 831f5c6484..47aa2eaf9e 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1435,8 +1435,11 @@ 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'] + env['LTO_CCFLAGS'] - ldflags[target] += ['-O3'] + env['LTO_LDFLAGS'] + ccflags[target] += ['-O3'] + ldflags[target] += ['-O3'] + + 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