1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 931 unchanged lines hidden (view full) --- 940# 941# Define binaries. Each different build type (debug, opt, etc.) gets 942# a slightly different build environment. 943# 944 945# List of constructed environments to pass back to SConstruct 946date_source = Source('base/date.cc', skip_lib=True) 947 |
948# Function to create a new build environment as clone of current 949# environment 'env' with modified object suffix and optional stripped 950# binary. Additional keyword arguments are appended to corresponding 951# build environment vars. 952def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): 953 # SCons doesn't know to append a library suffix when there is a '.' in the 954 # name. Use '_' instead. |
955 libname = 'gem5_' + label 956 exename = 'gem5.' + label 957 secondary_exename = 'm5.' + label |
958 959 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 960 new_env.Label = label 961 new_env.Append(**kwargs) 962 963 if env['GCC']: 964 # The address sanitizer is available for gcc >= 4.8 965 if GetOption('with_asan'): --- 122 unchanged lines hidden (view full) --- 1088 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 1089 1090 for test in UnitTest.all: 1091 flags = { test.target : True } 1092 test_sources = Source.get(**flags) 1093 test_objs = [ make_obj(s, static=True) for s in test_sources ] 1094 if test.main: 1095 test_objs += main_objs |
1096 path = 'unittest/%s.%s' % (test.target, label) |
1097 new_env.Program(path, test_objs + static_objs) 1098 1099 progname = exename 1100 if strip: 1101 progname += '.unstripped' 1102 1103 targets = new_env.Program(progname, main_objs + static_objs) 1104 --- 7 unchanged lines hidden (view full) --- 1112 1113 new_env.Command(secondary_exename, exename, 1114 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 1115 1116 new_env.M5Binary = targets[0] 1117 1118 # Set up regression tests. 1119 SConscript(os.path.join(env.root.abspath, 'tests', 'SConscript'), |
1120 variant_dir=Dir('tests').Dir(new_env.Label).path, |
1121 exports={ 'env' : new_env }, duplicate=False) 1122 1123# Start out with the compiler flags common to all compilers, 1124# i.e. they all use -g for opt and -g -pg for prof 1125ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 1126 'perf' : ['-g']} 1127 1128# Start out with the linker flags common to all linkers, i.e. -pg for --- 50 unchanged lines hidden (view full) --- 1179 if match and match.group(1) in target_types: 1180 return match.group(1) 1181 return 'all' 1182 1183needed_envs = [identifyTarget(target) for target in BUILD_TARGETS] 1184if 'all' in needed_envs: 1185 needed_envs += target_types 1186 |
1187# Debug binary 1188if 'debug' in needed_envs: 1189 makeEnv(env, 'debug', '.do', 1190 CCFLAGS = Split(ccflags['debug']), 1191 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 1192 LINKFLAGS = Split(ldflags['debug'])) |
1193 |
1194# Optimized binary 1195if 'opt' in needed_envs: 1196 makeEnv(env, 'opt', '.o', 1197 CCFLAGS = Split(ccflags['opt']), 1198 CPPDEFINES = ['TRACING_ON=1'], 1199 LINKFLAGS = Split(ldflags['opt'])) |
1200 |
1201# "Fast" binary 1202if 'fast' in needed_envs: 1203 disable_partial = \ 1204 env.get('BROKEN_INCREMENTAL_LTO', False) and \ 1205 GetOption('force_lto') 1206 makeEnv(env, 'fast', '.fo', strip = True, 1207 CCFLAGS = Split(ccflags['fast']), 1208 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1209 LINKFLAGS = Split(ldflags['fast']), 1210 disable_partial=disable_partial) |
1211 |
1212# Profiled binary using gprof 1213if 'prof' in needed_envs: 1214 makeEnv(env, 'prof', '.po', 1215 CCFLAGS = Split(ccflags['prof']), 1216 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1217 LINKFLAGS = Split(ldflags['prof'])) |
1218 |
1219# Profiled binary using google-pprof 1220if 'perf' in needed_envs: 1221 makeEnv(env, 'perf', '.gpo', 1222 CCFLAGS = Split(ccflags['perf']), 1223 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1224 LINKFLAGS = Split(ldflags['perf'])) |