summaryrefslogtreecommitdiff
path: root/src/SConscript
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-06-05 22:23:18 -0700
committerGabe Black <gabeblack@google.com>2017-06-06 17:07:19 +0000
commit670436b9cd7a23f03c9d7248abb8eb19939c83a6 (patch)
treeab5196a5ebc651dcf782bdd5c2f04a9619fae4b4 /src/SConscript
parent4966fe4b0f17ba30cba3d3dbae02b6452b87a70a (diff)
downloadgem5-670436b9cd7a23f03c9d7248abb8eb19939c83a6.tar.xz
scons: Try to handle problems with gcc, lto and partial linking.
gcc has had a lot of problems with incremental linking and partial linking at the same time. Basically, the partial link assumes that it's the only link that's going to happen, and it converts weak external symbols into regular external symbols. Then when the real final link happens, those symbols are duplicated and the link fails. Versions of gcc 6 and greater add an option called -flinker-output which lets you tell the linker to do an incremental link. Unfortunately, other bugs make that fail, and so gcc 6 doesn't work either. Hopefully version 7 works better. A --force-lto option was added so that, when only one of lto and partial linking is available, you can switch from having partial linking to having lto. Change-Id: I5e293f5cfb07a14343dc74030d99cb161fb8bbbe Reviewed-on: https://gem5-review.googlesource.com/3680 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/SConscript')
-rwxr-xr-xsrc/SConscript16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/SConscript b/src/SConscript
index ed59bd228..519a0a986 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -957,7 +957,7 @@ def variantd(*path):
# environment 'env' with modified object suffix and optional stripped
# binary. Additional keyword arguments are appended to corresponding
# build environment vars.
-def makeEnv(env, label, objsfx, strip = False, **kwargs):
+def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs):
# SCons doesn't know to append a library suffix when there is a '.' in the
# name. Use '_' instead.
libname = variant('gem5_' + label)
@@ -1059,6 +1059,14 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
if not srcs:
continue
+ # If partial linking is disabled, add these sources to the build
+ # directly, and short circuit this loop.
+ if disable_partial:
+ for s in srcs:
+ static_objs.append(make_obj(s, True))
+ shared_objs.append(make_obj(s, False))
+ continue
+
# Set up the static partially linked objects.
source_objs = [ make_obj(s, True) for s in srcs ]
file_name = new_env.subst("${OBJPREFIX}lib${OBJSUFFIX}.partial")
@@ -1204,10 +1212,14 @@ def makeEnvirons(target, source, env):
# "Fast" binary
if 'fast' in needed_envs:
+ disable_partial = \
+ env.get('BROKEN_INCREMENTAL_LTO', False) and \
+ GetOption('force_lto')
makeEnv(env, 'fast', '.fo', strip = True,
CCFLAGS = Split(ccflags['fast']),
CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
- LINKFLAGS = Split(ldflags['fast']))
+ LINKFLAGS = Split(ldflags['fast']),
+ disable_partial=disable_partial)
# Profiled binary using gprof
if 'prof' in needed_envs: