Ruby: Use MasterPort base-class pointers where possible
[gem5.git] / src / SConscript
index 0a4bb57f499303867e9937b55a7795538fc5c6d8..fd6e725a493f028113f19d3c26b333b8d74d7cf8 100755 (executable)
@@ -791,7 +791,7 @@ def embedPyFile(target, source, env):
 
 namespace {
 
-const char data_${sym}[] = {
+const uint8_t data_${sym}[] = {
 ''')
     code.indent()
     step = 16
@@ -851,9 +851,12 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
         swig_env.Append(CCFLAGS='-Wno-uninitialized')
         swig_env.Append(CCFLAGS='-Wno-sign-compare')
         swig_env.Append(CCFLAGS='-Wno-parentheses')
-        if compareVersions(env['GCC_VERSION'], '4.6.0') != -1:
-            swig_env.Append(CCFLAGS='-Wno-unused-label')
+        swig_env.Append(CCFLAGS='-Wno-unused-label')
+        if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
             swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
+    if env['CLANG']:
+        swig_env.Append(CCFLAGS=['-Wno-unused-label'])
+
 
     werror_env = new_env.Clone()
     werror_env.Append(CCFLAGS='-Werror')
@@ -904,7 +907,7 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
         test_sources = Source.get(**flags)
         test_objs = [ make_obj(s, static=True) for s in test_sources ]
         testname = "unittest/%s.%s" % (test.target, label)
-        new_env.Program(testname, main_objs + test_objs + static_objs)
+        new_env.Program(testname, test_objs + static_objs)
 
     progname = exename
     if strip:
@@ -946,28 +949,61 @@ elif env['ICC']:
     ccflags['opt'] = '-g -O'
     ccflags['fast'] = '-fast'
     ccflags['prof'] = '-fast -g -pg'
+elif env['CLANG']:
+    ccflags['debug'] = '-g -O0'
+    ccflags['opt'] = '-g -O3'
+    ccflags['fast'] = '-O3'
+    ccflags['prof'] = '-O3 -g -pg'
 else:
     print 'Unknown compiler, please fix compiler options'
     Exit(1)
 
-makeEnv('debug', '.do',
-        CCFLAGS = Split(ccflags['debug']),
-        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
+
+# To speed things up, we only instantiate the build environments we
+# need.  We try to identify the needed environment for each target; if
+# we can't, we fall back on instantiating all the environments just to
+# be safe.
+target_types = ['debug', 'opt', 'fast', 'prof']
+obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof'}
+
+def identifyTarget(t):
+    ext = t.split('.')[-1]
+    if ext in target_types:
+        return ext
+    if obj2target.has_key(ext):
+        return obj2target[ext]
+    match = re.search(r'/tests/([^/]+)/', t)
+    if match and match.group(1) in target_types:
+        return match.group(1)
+    return 'all'
+
+needed_envs = [identifyTarget(target) for target in BUILD_TARGETS]
+if 'all' in needed_envs:
+    needed_envs += target_types
+
+# Debug binary
+if 'debug' in needed_envs:
+    makeEnv('debug', '.do',
+            CCFLAGS = Split(ccflags['debug']),
+            CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
 
 # Optimized binary
-makeEnv('opt', '.o',
-        CCFLAGS = Split(ccflags['opt']),
-        CPPDEFINES = ['TRACING_ON=1'])
+if 'opt' in needed_envs:
+    makeEnv('opt', '.o',
+            CCFLAGS = Split(ccflags['opt']),
+            CPPDEFINES = ['TRACING_ON=1'])
 
 # "Fast" binary
-makeEnv('fast', '.fo', strip = True,
-        CCFLAGS = Split(ccflags['fast']),
-        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
+if 'fast' in needed_envs:
+    makeEnv('fast', '.fo', strip = True,
+            CCFLAGS = Split(ccflags['fast']),
+            CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
 
 # Profiled binary
-makeEnv('prof', '.po',
-        CCFLAGS = Split(ccflags['prof']),
-        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
-        LINKFLAGS = '-pg')
+if 'prof' in needed_envs:
+    makeEnv('prof', '.po',
+            CCFLAGS = Split(ccflags['prof']),
+            CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
+            LINKFLAGS = '-pg')
 
 Return('envList')