def __init__(cls, name, bases, dict):
super(SourceMeta, cls).__init__(name, bases, dict)
cls.all = []
-
+
def get(cls, **guards):
'''Find all files that match the specified guards. If a source
file does not specify a flag, the default is False'''
target_isa = env['TARGET_ISA']
def define(isa):
return isa.upper() + '_ISA'
-
+
def namespace(isa):
- return isa[0].upper() + isa[1:].lower() + 'ISA'
+ return isa[0].upper() + isa[1:].lower() + 'ISA'
code = code_formatter()
env.Command('config/the_isa.hh', map(Value, all_isa_list),
MakeAction(makeTheISA, Transform("CFG ISA", 0)))
+def makeTheGPUISA(source, target, env):
+ isas = [ src.get_contents() for src in source ]
+ target_gpu_isa = env['TARGET_GPU_ISA']
+ def define(isa):
+ return isa.upper() + '_ISA'
+
+ def namespace(isa):
+ return isa[0].upper() + isa[1:].lower() + 'ISA'
+
+
+ code = code_formatter()
+ code('''\
+#ifndef __CONFIG_THE_GPU_ISA_HH__
+#define __CONFIG_THE_GPU_ISA_HH__
+
+''')
+
+ # create defines for the preprocessing and compile-time determination
+ for i,isa in enumerate(isas):
+ code('#define $0 $1', define(isa), i + 1)
+ code()
+
+ # create an enum for any run-time determination of the ISA, we
+ # reuse the same name as the namespaces
+ code('enum class GPUArch {')
+ for i,isa in enumerate(isas):
+ if i + 1 == len(isas):
+ code(' $0 = $1', namespace(isa), define(isa))
+ else:
+ code(' $0 = $1,', namespace(isa), define(isa))
+ code('};')
+
+ code('''
+
+#define THE_GPU_ISA ${{define(target_gpu_isa)}}
+#define TheGpuISA ${{namespace(target_gpu_isa)}}
+#define THE_GPU_ISA_STR "${{target_gpu_isa}}"
+
+#endif // __CONFIG_THE_GPU_ISA_HH__''')
+
+ code.write(str(target[0]))
+
+env.Command('config/the_gpu_isa.hh', map(Value, all_gpu_isa_list),
+ MakeAction(makeTheGPUISA, Transform("CFG ISA", 0)))
+
########################################################################
#
# Prevent any SimObjects from being added after this point, they
EmbeddedSwig embed_swig_${module}(init_${module});
''')
code.write(str(target[0]))
-
+
# Build all swig modules
for swig in SwigSource.all:
env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
env.Depends(SWIG, 'debug/flags.cc')
Source('debug/flags.cc')
+# version tags
+tags = \
+env.Command('sim/tags.cc', None,
+ MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET',
+ Transform("VER TAGS")))
+env.AlwaysBuild(tags)
+
# Embed python files. All .py files that have been indicated by a
# PySource() call in a SConscript need to be embedded into the M5
# library. To do that, we compile the file to byte code, marshal the
x = array.array('B', data[i:i+step])
code(''.join('%d,' % d for d in x))
code.dedent()
-
+
code('''};
EmbeddedPython embedded_${sym}(
# the SWIG generated code
swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value'])
- # Add additional warnings here that should not be applied to
- # the SWIG generated code
- new_env.Append(CXXFLAGS='-Wmissing-declarations')
-
if env['GCC']:
# Depending on the SWIG version, we also need to supress
# warnings about uninitialized variables and missing field
# initializers.
swig_env.Append(CCFLAGS=['-Wno-uninitialized',
'-Wno-missing-field-initializers',
- '-Wno-unused-but-set-variable'])
-
- # If gcc supports it, also warn for deletion of derived
- # classes with non-virtual desctructors. For gcc >= 4.7 we
- # also have to disable warnings about the SWIG code having
- # potentially uninitialized variables.
- if compareVersions(env['GCC_VERSION'], '4.7') >= 0:
- new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor')
- swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized')
+ '-Wno-unused-but-set-variable',
+ '-Wno-maybe-uninitialized',
+ '-Wno-type-limits'])
# Only gcc >= 4.9 supports UBSan, so check both the version
# and the command-line option before adding the compiler and
new_env.Append(CCFLAGS='-fsanitize=undefined')
new_env.Append(LINKFLAGS='-fsanitize=undefined')
+ # The address sanitizer is available for gcc >= 4.8
+ if GetOption('with_asan'):
+ new_env.Append(CCFLAGS=['-fsanitize=address',
+ '-fno-omit-frame-pointer'])
+ new_env.Append(LINKFLAGS='-fsanitize=address')
+
if env['CLANG']:
- # Always enable the warning for deletion of derived classes
- # with non-virtual destructors
- new_env.Append(CXXFLAGS=['-Wdelete-non-virtual-dtor'])
-
- swig_env.Append(CCFLAGS=[
- # Some versions of SWIG can return uninitialized values
- '-Wno-sometimes-uninitialized',
- # Register storage is requested in a lot of places in
- # SWIG-generated code.
- '-Wno-deprecated-register',
- ])
-
- # All supported clang versions have support for UBSan, so if
- # asked to use it, append the compiler and linker flags.
+ swig_env.Append(CCFLAGS=['-Wno-sometimes-uninitialized',
+ '-Wno-deprecated-register',
+ '-Wno-tautological-compare'])
+
+ # We require clang >= 3.1, so there is no need to check any
+ # versions here.
if GetOption('with_ubsan'):
new_env.Append(CCFLAGS='-fsanitize=undefined')
new_env.Append(LINKFLAGS='-fsanitize=undefined')
+ if GetOption('with_asan'):
+ new_env.Append(CCFLAGS=['-fsanitize=address',
+ '-fno-omit-frame-pointer'])
+ new_env.Append(LINKFLAGS='-fsanitize=address')
+
werror_env = new_env.Clone()
- werror_env.Append(CCFLAGS='-Werror')
+ # Treat warnings as errors but white list some warnings that we
+ # want to allow (e.g., deprecation warnings).
+ werror_env.Append(CCFLAGS=['-Werror',
+ '-Wno-error=deprecated-declarations',
+ '-Wno-error=deprecated',
+ ])
def make_obj(source, static, extra_deps = None):
'''This function adds the specified source to the correct
if 'all' in needed_envs:
needed_envs += target_types
-gem5_root = Dir('.').up().up().abspath
def makeEnvirons(target, source, env):
# cause any later Source() calls to be fatal, as a diagnostic.
Source.done()
# Set up the regression tests for each build.
for e in envList:
- SConscript(os.path.join(gem5_root, 'tests', 'SConscript'),
+ SConscript(os.path.join(env.root.abspath, 'tests', 'SConscript'),
variant_dir = variantd('tests', e.Label),
exports = { 'env' : e }, duplicate = False)