summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-04-28 03:57:09 -0700
committerGabe Black <gabeblack@google.com>2017-05-01 23:27:46 +0000
commit4576541c176efee347cb3dfaee568fed1a2dd986 (patch)
tree9211351da7abc5ff30b7398347a05abf7b017933 /SConstruct
parentc5bfa6e4102c6aac73a80d50021105a39e4962bd (diff)
downloadgem5-4576541c176efee347cb3dfaee568fed1a2dd986.tar.xz
scons: Add builders for partially linked object files.
These intermediate object files can be used to perform a hierarchical link. Change-Id: I27634731734eebe6531ce6b0894abdd59ffdc5c9 Reviewed-on: https://gem5-review.googlesource.com/2944 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct33
1 files changed, 33 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index f4649c64d..84a0a98ed 100755
--- a/SConstruct
+++ b/SConstruct
@@ -688,6 +688,13 @@ if main['GCC'] or main['CLANG']:
if sys.platform.startswith('freebsd'):
main.Append(CCFLAGS=['-I/usr/local/include'])
main.Append(CXXFLAGS=['-I/usr/local/include'])
+
+ main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '')
+ main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}')
+ main['PLINKFLAGS'] = main.subst('${LINKFLAGS}')
+ shared_partial_flags = ['-Wl,--relocatable', '-nostdlib']
+ main.Append(PSHLINKFLAGS=shared_partial_flags)
+ main.Append(PLINKFLAGS=shared_partial_flags)
else:
print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
print "Don't know what compiler options to use for your compiler."
@@ -1340,6 +1347,32 @@ config_builder = Builder(emitter = config_emitter, action = config_action)
main.Append(BUILDERS = { 'ConfigFile' : config_builder })
+###################################################
+#
+# Builders for static and shared partially linked object files.
+#
+###################################################
+
+partial_static_builder = Builder(action=SCons.Defaults.LinkAction,
+ src_suffix='$OBJSUFFIX',
+ src_builder=['StaticObject', 'Object'],
+ LINKFLAGS='$PLINKFLAGS',
+ LIBS='')
+
+def partial_shared_emitter(target, source, env):
+ for tgt in target:
+ tgt.attributes.shared = 1
+ return (target, source)
+partial_shared_builder = Builder(action=SCons.Defaults.ShLinkAction,
+ emitter=partial_shared_emitter,
+ src_suffix='$SHOBJSUFFIX',
+ src_builder='SharedObject',
+ SHLINKFLAGS='$PSHLINKFLAGS',
+ LIBS='')
+
+main.Append(BUILDERS = { 'PartialShared' : partial_shared_builder,
+ 'PartialStatic' : partial_static_builder })
+
# builds in ext are shared across all configs in the build root.
ext_dir = abspath(joinpath(str(main.root), 'ext'))
for root, dirs, files in os.walk(ext_dir):