From a0b5b999b0784522499d7d1360708689b6cb0a85 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 5 Feb 2021 21:43:40 -0800 Subject: [PATCH] scons: Enable LTO for opt, perf and prof builds. The name of the build is opt, so it should be fully optomized. Also, the fast build, the only one with LTO historically, is dangerous to use since it disables many error checks. I personally run gem5 many times while developing, iterating and trying to fix bugs, and so want it to run quickly then too, not just the final time when collecting results. Also, since they mirror the opt build, the perf and prof builds also have LTO options added. This has the nice side effect of speeding up the build time of build/X86 significantly (6:20 -> 4:27) due to parallelization of the link, and reduces the size of the build/X86 directory (with debug compression enabled) from 3.4GB to 2.8GB. The size of build/X86/python/_m5 is still 1.6GB, so still more than half of the total size of build/X86. Change-Id: I8feabf99454693fdd100d9e1a64fdeae53362f75 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40815 Maintainer: Bobby R. Bruce Tested-by: kokoro Reviewed-by: Earl Ou --- SConstruct | 3 +-- src/SConscript | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index e9dfae5038..e1814c37c3 100755 --- a/SConstruct +++ b/SConstruct @@ -358,8 +358,7 @@ if main['GCC']: main['GCC_VERSION'] = gcc_version # 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. + # unless LTO is explicitly turned off. if not GetOption('no_lto'): # Pass the LTO flag when compiling to produce GIMPLE # output, we merely create the flags here and only append diff --git a/src/SConscript b/src/SConscript index aeb7038a61..5fe0ab2c25 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1341,11 +1341,8 @@ 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['fast'] += env['LTO_CCFLAGS'] - ldflags['fast'] += env['LTO_LDFLAGS'] + ccflags[target] += ['-O3'] + env['LTO_CCFLAGS'] + ldflags[target] += ['-O3'] + env['LTO_LDFLAGS'] elif env['CLANG']: ccflags['debug'] += ['-g', '-O0'] # opt, fast, prof and perf all share the same cc flags