Hello Gabe Black,

I'd like you to do a code review. Please visit


to review the following change.

Change subject: scons: Enable LTO and partial linking with gcc >= 8.1.

scons: Enable LTO and partial linking with gcc >= 8.1.

The bug(s) which prevented LTO and partial linking from working with gcc
have been fixed in my local version (9.3), and according to one of the
original bug reports:


A fix was committed in gcc version 8.1.

The original code left in the SConstruct describing the problem with
versions greated than 6.0 also enabled an -flinker-output option and set
it to "rel". That option doesn't show up in the gcc 8.4 documentation
even though it was added in 6.0, but in the 9.3 documentation it
describes it and says that it defaults to "rel" when the -r (partial
linking) option is used.

This *should* mean that LTO and partial linking can be used together
with no issues after version 8.1, and at most by version 9.3. If someone
finds that that isn't true, then the range of bad versions can be

Change-Id: Ie0529d077a0042ef55e2af995d01430d1695c031
M SConstruct
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/SConstruct b/SConstruct
index 0f36eac..c8d1428 100755
--- a/SConstruct
+++ b/SConstruct
@@ -169,7 +169,7 @@
 AddLocalOption('--with-systemc-tests', dest='with_systemc_tests',
                action='store_true', help='Build systemc tests')

-from gem5_scons import Transform, error, warning
+from gem5_scons import Transform, error, warning, summarize_warnings

 if GetOption('no_lto') and GetOption('force_lto'):
     error('--no-lto and --force-lto are mutually exclusive')
@@ -401,27 +401,22 @@

     main['GCC_VERSION'] = gcc_version

-    if compareVersions(gcc_version, '4.9') >= 0:
+    if compareVersions(gcc_version, '4.9') >= 0 and \
+       compareVersions(gcc_version, '8.1') < 0:
         # Incremental linking with LTO is currently broken in gcc versions
-        # 4.9 and above. A version where everything works completely hasn't
-        # yet been identified.
+        # 4.9 to 8.1.
         # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548
-        main['BROKEN_INCREMENTAL_LTO'] = True
-    if compareVersions(gcc_version, '6.0') >= 0:
+        #
         # gcc versions 6.0 and greater accept an -flinker-output flag which
         # selects what type of output the linker should generate. This is
         # necessary for incremental lto to work, but is also broken in
-        # current versions of gcc. It may not be necessary in future
- # versions. We add it here since it might be, and as a reminder that
-        # it exists. It's excluded if lto is being forced.
+        # versions of gcc up to 8.1.
         # https://gcc.gnu.org/gcc-6/changes.html
         # https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03161.html
         # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69866
-        if not GetOption('force_lto'):
-            main.Append(PSHLINKFLAGS='-flinker-output=rel')
-            main.Append(PLINKFLAGS='-flinker-output=rel')
+        main['BROKEN_INCREMENTAL_LTO'] = True

     disable_lto = GetOption('no_lto')
     if not disable_lto and main.get('BROKEN_INCREMENTAL_LTO', False) and \
@@ -430,7 +425,7 @@
'at the same time, so lto is being disabled. To force lto on '
                 'anyway, use the --force-lto option. That will disable '
                 'partial linking.')
-        disable_lto = True
+        #disable_lto = True

     # Add the appropriate Link-Time Optimization (LTO) flags
     # unless LTO is explicitly turned off. Note that these flags

To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27131
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie0529d077a0042ef55e2af995d01430d1695c031
Gerrit-Change-Number: 27131
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
gem5-dev mailing list

Reply via email to