help="Don't compress debug info in build files")
AddOption('--no-lto', action='store_true',
help='Disable Link-Time Optimization for fast')
-AddOption('--force-lto', action='store_true',
- help='Use Link-Time Optimization instead of partial linking' +
- ' when the compiler doesn\'t support using them together.')
AddOption('--verbose', action='store_true',
help='Print full tool command lines')
AddOption('--without-python', action='store_true',
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')
-
########################################################################
#
# Set up the main build environment.
# option --as-needed
if sys.platform != "darwin":
main.Append(LINKFLAGS='-Wl,--as-needed')
- main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '')
- main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}')
if GetOption('gold_linker'):
main.Append(LINKFLAGS='-fuse-ld=gold')
- main['PLINKFLAGS'] = main.get('LINKFLAGS')
- shared_partial_flags = ['-r', '-nostdlib']
- main.Append(PSHLINKFLAGS=shared_partial_flags)
- main.Append(PLINKFLAGS=shared_partial_flags)
# Treat warnings as errors but white list some warnings that we
# want to allow (e.g., deprecation warnings).
main['GCC_VERSION'] = gcc_version
- # 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.
- #
- # 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.
- #
- # 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'])
-
- disable_lto = GetOption('no_lto')
- if not disable_lto and main.get('BROKEN_INCREMENTAL_LTO', False) and \
- not GetOption('force_lto'):
- warning('Your compiler doesn\'t support incremental linking and lto '
- '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
-
# 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 disable_lto:
+ if not GetOption('no_lto'):
# Pass the LTO flag when compiling to produce GIMPLE
# output, we merely create the flags here and only append
# them later
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 })
-
def add_local_rpath(env, *targets):
'''Set up an RPATH for a library which lives in the build directory.
Blob(joinpath(gdb_xml_dir, xml_id), symbol)
class Source(SourceFile):
- ungrouped_tag = 'No link group'
- source_groups = set()
-
- _current_group_tag = ungrouped_tag
-
- @staticmethod
- def link_group_tag(group):
- return 'link group: %s' % group
-
- @classmethod
- def set_group(cls, group):
- new_tag = Source.link_group_tag(group)
- Source._current_group_tag = new_tag
- Source.source_groups.add(group)
-
- def _add_link_group_tag(self):
- self.tags.add(Source._current_group_tag)
-
- '''Add a c/c++ source file to the build'''
- def __init__(self, source, tags=None, add_tags=None, append=None):
- '''specify the source file, and any tags'''
- super(Source, self).__init__(source, tags, add_tags, append)
- self._add_link_group_tag()
+ pass
class PySource(SourceFile):
'''Add a python source file to the named package'''
if 'SConscript' in files:
build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:])
- Source.set_group(build_dir)
SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir)
for extra_dir in extras_dir_list:
if 'SConscript' in files:
build_dir = joinpath(env['BUILDDIR'], root[prefix_len:])
- Source.set_group(build_dir)
SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir)
for opt in export_vars:
if GetOption('without_python'):
lib_sources = lib_sources.without_tag('python')
- static_objs = []
- shared_objs = []
-
- for s in lib_sources.with_tag(Source.ungrouped_tag):
- static_objs.append(s.static(new_env))
- shared_objs.append(s.shared(new_env))
-
- for group in Source.source_groups:
- srcs = lib_sources.with_tag(Source.link_group_tag(group))
- if not srcs:
- continue
-
- group_static = [ s.static(new_env) for s in srcs ]
- group_shared = [ s.shared(new_env) for s in srcs ]
-
- # Disable partial linking if mixing it with LTO is broken and LTO
- # is enabled.
- #
- # Also, up until Apple LLVM version 10.0.0 (clang-1000.11.45.5),
- # partial linked objects do not expose symbols that are marked with
- # the hidden visibility and consequently building gem5 on Mac OS
- # fails. As a workaround, we disable partial linking, however, we
- # may want to revisit in the future.
- broken_inc_lto = env.get('BROKEN_INCREMENTAL_LTO', False)
- forced_lto = GetOption('force_lto')
- darwin = (env['PLATFORM'] == 'darwin')
- disable_partial = (broken_inc_lto and forced_lto) or darwin
-
- # If partial linking is disabled, add these sources to the build
- # directly, and short circuit this loop.
- if disable_partial:
- static_objs.extend(group_static)
- shared_objs.extend(group_shared)
- continue
-
- # Set up the static partially linked objects.
- file_name = new_env.subst("${OBJPREFIX}lib${OBJSUFFIX}.partial")
- target = File(joinpath(group, file_name))
- partial = env.PartialStatic(target=target, source=group_static)
- static_objs.extend(partial)
-
- # Set up the shared partially linked objects.
- file_name = new_env.subst("${SHOBJPREFIX}lib${SHOBJSUFFIX}.partial")
- target = File(joinpath(group, file_name))
- partial = env.PartialShared(target=target, source=group_shared)
- shared_objs.extend(partial)
+ static_objs = list([ s.static(new_env) for s in lib_sources ])
+ shared_objs = list([ s.shared(new_env) for s in lib_sources ])
static_date = date_source.static(new_env)
new_env.Depends(static_date, static_objs)