SConscript (12063:06cd2c297b04) | SConscript (12222:6db0fc7407a5) |
---|---|
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 | 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# Capture this directory for the closure makeEnv, otherwise when it is 949# called, it won't know what directory it should use. 950variant_dir = Dir('.').path 951def variant(*path): 952 return os.path.join(variant_dir, *path) 953def variantd(*path): 954 return variant(*path)+'/' 955 | |
956# Function to create a new build environment as clone of current 957# environment 'env' with modified object suffix and optional stripped 958# binary. Additional keyword arguments are appended to corresponding 959# build environment vars. 960def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): 961 # SCons doesn't know to append a library suffix when there is a '.' in the 962 # name. Use '_' instead. | 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. |
963 libname = variant('gem5_' + label) 964 exename = variant('gem5.' + label) 965 secondary_exename = variant('m5.' + label) | 955 libname = 'gem5_' + label 956 exename = 'gem5.' + label 957 secondary_exename = 'm5.' + label |
966 967 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 968 new_env.Label = label 969 new_env.Append(**kwargs) 970 971 if env['GCC']: 972 # The address sanitizer is available for gcc >= 4.8 973 if GetOption('with_asan'): --- 122 unchanged lines hidden (view full) --- 1096 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 1097 1098 for test in UnitTest.all: 1099 flags = { test.target : True } 1100 test_sources = Source.get(**flags) 1101 test_objs = [ make_obj(s, static=True) for s in test_sources ] 1102 if test.main: 1103 test_objs += main_objs | 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 |
1104 path = variant('unittest/%s.%s' % (test.target, label)) | 1096 path = 'unittest/%s.%s' % (test.target, label) |
1105 new_env.Program(path, test_objs + static_objs) 1106 1107 progname = exename 1108 if strip: 1109 progname += '.unstripped' 1110 1111 targets = new_env.Program(progname, main_objs + static_objs) 1112 --- 7 unchanged lines hidden (view full) --- 1120 1121 new_env.Command(secondary_exename, exename, 1122 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 1123 1124 new_env.M5Binary = targets[0] 1125 1126 # Set up regression tests. 1127 SConscript(os.path.join(env.root.abspath, 'tests', 'SConscript'), | 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'), |
1128 variant_dir=variantd('tests', new_env.Label), | 1120 variant_dir=Dir('tests').Dir(new_env.Label).path, |
1129 exports={ 'env' : new_env }, duplicate=False) 1130 1131# Start out with the compiler flags common to all compilers, 1132# i.e. they all use -g for opt and -g -pg for prof 1133ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 1134 'perf' : ['-g']} 1135 1136# Start out with the linker flags common to all linkers, i.e. -pg for --- 50 unchanged lines hidden (view full) --- 1187 if match and match.group(1) in target_types: 1188 return match.group(1) 1189 return 'all' 1190 1191needed_envs = [identifyTarget(target) for target in BUILD_TARGETS] 1192if 'all' in needed_envs: 1193 needed_envs += target_types 1194 | 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 |
1195def makeEnvirons(target, source, env): 1196 # cause any later Source() calls to be fatal, as a diagnostic. 1197 Source.done() | 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'])) |
1198 | 1193 |
1199 # Debug binary 1200 if 'debug' in needed_envs: 1201 makeEnv(env, 'debug', '.do', 1202 CCFLAGS = Split(ccflags['debug']), 1203 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 1204 LINKFLAGS = Split(ldflags['debug'])) | 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'])) |
1205 | 1200 |
1206 # Optimized binary 1207 if 'opt' in needed_envs: 1208 makeEnv(env, 'opt', '.o', 1209 CCFLAGS = Split(ccflags['opt']), 1210 CPPDEFINES = ['TRACING_ON=1'], 1211 LINKFLAGS = Split(ldflags['opt'])) | 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) |
1212 | 1211 |
1213 # "Fast" binary 1214 if 'fast' in needed_envs: 1215 disable_partial = \ 1216 env.get('BROKEN_INCREMENTAL_LTO', False) and \ 1217 GetOption('force_lto') 1218 makeEnv(env, 'fast', '.fo', strip = True, 1219 CCFLAGS = Split(ccflags['fast']), 1220 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1221 LINKFLAGS = Split(ldflags['fast']), 1222 disable_partial=disable_partial) | 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'])) |
1223 | 1218 |
1224 # Profiled binary using gprof 1225 if 'prof' in needed_envs: 1226 makeEnv(env, 'prof', '.po', 1227 CCFLAGS = Split(ccflags['prof']), 1228 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1229 LINKFLAGS = Split(ldflags['prof'])) 1230 1231 # Profiled binary using google-pprof 1232 if 'perf' in needed_envs: 1233 makeEnv(env, 'perf', '.gpo', 1234 CCFLAGS = Split(ccflags['perf']), 1235 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1236 LINKFLAGS = Split(ldflags['perf'])) 1237 1238# The MakeEnvirons Builder defers the full dependency collection until 1239# after processing the ISA definition (due to dynamically generated 1240# source files). Add this dependency to all targets so they will wait 1241# until the environments are completely set up. Otherwise, a second 1242# process (e.g. -j2 or higher) will try to compile the requested target, 1243# not know how, and fail. 1244env.Append(BUILDERS = {'MakeEnvirons' : 1245 Builder(action=MakeAction(makeEnvirons, 1246 Transform("ENVIRONS", 1)))}) 1247 1248isa_target = '#${VARIANT_NAME}-deps' 1249environs = '#${VARIANT_NAME}-environs' 1250env.Depends('#all-deps', isa_target) 1251env.Depends('#all-environs', environs) 1252env.ScanISA(isa_target, File('arch/%s/generated/inc.d' % env['TARGET_ISA'])) 1253envSetup = env.MakeEnvirons(environs, isa_target) 1254 1255# make sure no -deps targets occur before all ISAs are complete 1256env.Depends(isa_target, '#all-isas') 1257# likewise for -environs targets and all the -deps targets 1258env.Depends(environs, '#all-deps') | 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'])) |