SConscript revision 4177:eeb07aef07d0
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 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution; 13# neither the name of the copyright holders nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28# 29# Authors: Steve Reinhardt 30 31import os 32import sys 33from os.path import isfile, join as joinpath 34 35# This file defines how to build a particular configuration of M5 36# based on variable settings in the 'env' build environment. 37 38# Import build environment variable from SConstruct. 39Import('env') 40 41################################################### 42# 43# Define needed sources. 44# 45################################################### 46 47# Base sources used by all configurations. 48 49base_sources = Split(''' 50 base/annotate.cc 51 base/bigint.cc 52 base/circlebuf.cc 53 base/cprintf.cc 54 base/fast_alloc.cc 55 base/fifo_buffer.cc 56 base/hostinfo.cc 57 base/hybrid_pred.cc 58 base/inifile.cc 59 base/intmath.cc 60 base/match.cc 61 base/misc.cc 62 base/output.cc 63 base/pollevent.cc 64 base/range.cc 65 base/random.cc 66 base/remote_gdb.cc 67 base/sat_counter.cc 68 base/socket.cc 69 base/statistics.cc 70 base/str.cc 71 base/time.cc 72 base/trace.cc 73 base/traceflags.cc 74 base/userinfo.cc 75 base/compression/lzss_compression.cc 76 base/loader/aout_object.cc 77 base/loader/ecoff_object.cc 78 base/loader/elf_object.cc 79 base/loader/raw_object.cc 80 base/loader/object_file.cc 81 base/loader/symtab.cc 82 base/stats/events.cc 83 base/stats/output.cc 84 base/stats/statdb.cc 85 base/stats/visit.cc 86 base/stats/text.cc 87 88 cpu/activity.cc 89 cpu/base.cc 90 cpu/cpuevent.cc 91 cpu/exetrace.cc 92 cpu/func_unit.cc 93 cpu/op_class.cc 94 cpu/pc_event.cc 95 cpu/quiesce_event.cc 96 cpu/static_inst.cc 97 cpu/simple_thread.cc 98 cpu/thread_state.cc 99 100 mem/bridge.cc 101 mem/bus.cc 102 mem/dram.cc 103 mem/mem_object.cc 104 mem/packet.cc 105 mem/physical.cc 106 mem/port.cc 107 mem/tport.cc 108 109 mem/cache/base_cache.cc 110 mem/cache/cache.cc 111 mem/cache/coherence/coherence_protocol.cc 112 mem/cache/coherence/uni_coherence.cc 113 mem/cache/miss/blocking_buffer.cc 114 mem/cache/miss/miss_buffer.cc 115 mem/cache/miss/miss_queue.cc 116 mem/cache/miss/mshr.cc 117 mem/cache/miss/mshr_queue.cc 118 mem/cache/prefetch/base_prefetcher.cc 119 mem/cache/prefetch/ghb_prefetcher.cc 120 mem/cache/prefetch/stride_prefetcher.cc 121 mem/cache/prefetch/tagged_prefetcher.cc 122 mem/cache/tags/base_tags.cc 123 mem/cache/tags/fa_lru.cc 124 mem/cache/tags/iic.cc 125 mem/cache/tags/lru.cc 126 mem/cache/tags/repl/gen.cc 127 mem/cache/tags/repl/repl.cc 128 mem/cache/tags/split.cc 129 mem/cache/tags/split_lifo.cc 130 mem/cache/tags/split_lru.cc 131 132 mem/cache/cache_builder.cc 133 134 python/swig/init.cc 135 python/swig/core_wrap.cc 136 python/swig/debug_wrap.cc 137 python/swig/event_wrap.cc 138 python/swig/random_wrap.cc 139 python/swig/sim_object_wrap.cc 140 python/swig/stats_wrap.cc 141 python/swig/trace_wrap.cc 142 python/swig/pyevent.cc 143 python/swig/pyobject.cc 144 145 sim/async.cc 146 sim/builder.cc 147 sim/core.cc 148 sim/debug.cc 149 sim/eventq.cc 150 sim/faults.cc 151 sim/main.cc 152 sim/param.cc 153 sim/root.cc 154 sim/serialize.cc 155 sim/sim_events.cc 156 sim/sim_object.cc 157 sim/simulate.cc 158 sim/startup.cc 159 sim/stat_control.cc 160 sim/system.cc 161 ''') 162 163trace_reader_sources = Split(''' 164 cpu/trace/reader/mem_trace_reader.cc 165 cpu/trace/reader/ibm_reader.cc 166 cpu/trace/reader/itx_reader.cc 167 cpu/trace/reader/m5_reader.cc 168 cpu/trace/opt_cpu.cc 169 cpu/trace/trace_cpu.cc 170 ''') 171 172 173 174# MySql sources 175mysql_sources = Split(''' 176 base/mysql.cc 177 base/stats/mysql.cc 178 ''') 179 180# Full-system sources 181full_system_sources = Split(''' 182 base/crc.cc 183 base/inet.cc 184 185 cpu/intr_control.cc 186 cpu/profile.cc 187 188 dev/uart.cc 189 dev/uart8250.cc 190 191 mem/vport.cc 192 193 sim/pseudo_inst.cc 194 ''') 195 #dev/sinic.cc 196 #dev/i8254xGBe.cc 197 198if env['TARGET_ISA'] == 'alpha': 199 full_system_sources += Split(''' 200 kern/tru64/dump_mbuf.cc 201 kern/tru64/printf.cc 202 kern/tru64/tru64_events.cc 203 kern/tru64/tru64_syscalls.cc 204 ''') 205 206# Syscall emulation (non-full-system) sources 207syscall_emulation_sources = Split(''' 208 mem/translating_port.cc 209 mem/page_table.cc 210 sim/process.cc 211 sim/syscall_emul.cc 212 ''') 213 214#if env['TARGET_ISA'] == 'alpha': 215# syscall_emulation_sources += Split(''' 216# kern/tru64/tru64.cc 217# ''') 218 219memtest_sources = Split(''' 220 cpu/memtest/memtest.cc 221 ''') 222 223# Include file paths are rooted in this directory. SCons will 224# automatically expand '.' to refer to both the source directory and 225# the corresponding build directory to pick up generated include 226# files. 227env.Append(CPPPATH=Dir('.')) 228 229# Add a flag defining what THE_ISA should be for all compilation 230env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 231 232arch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env') 233 234cpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env') 235 236if env['FULL_SYSTEM']: 237 dev_sources = SConscript(os.path.join('dev', 'SConscript'), 238 exports = 'env') 239 full_system_sources += dev_sources 240 241 kern_sources = SConscript(os.path.join('kern', 'SConscript'), 242 exports = 'env') 243 full_system_sources += kern_sources 244 245# Set up complete list of sources based on configuration. 246sources = base_sources + arch_sources + cpu_sources 247 248# encumbered should be last because we're adding to some of the other groups 249if isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')): 250 sources += SConscript('encumbered/SConscript', exports = 'env') 251 252 253if env['FULL_SYSTEM']: 254 sources += full_system_sources 255else: 256 sources += syscall_emulation_sources 257 258if env['USE_MYSQL']: 259 sources += mysql_sources 260 261for opt in env.ExportOptions: 262 env.ConfigFile(opt) 263 264################################################### 265# 266# Special build rules. 267# 268################################################### 269 270# base/traceflags.{cc,hh} are generated from base/traceflags.py. 271# $TARGET.base will expand to "<build-dir>/base/traceflags". 272env.Command(Split('base/traceflags.hh base/traceflags.cc'), 273 'base/traceflags.py', 274 'python $SOURCE $TARGET.base') 275 276SConscript('python/SConscript', exports = ['env']) 277 278# This function adds the specified sources to the given build 279# environment, and returns a list of all the corresponding SCons 280# Object nodes (including an extra one for date.cc). We explicitly 281# add the Object nodes so we can set up special dependencies for 282# date.cc. 283def make_objs(sources, env): 284 objs = [env.Object(s) for s in sources] 285 # make date.cc depend on all other objects so it always gets 286 # recompiled whenever anything else does 287 date_obj = env.Object('base/date.cc') 288 env.Depends(date_obj, objs) 289 objs.append(date_obj) 290 return objs 291 292################################################### 293# 294# Define binaries. Each different build type (debug, opt, etc.) gets 295# a slightly different build environment. 296# 297################################################### 298 299# List of constructed environments to pass back to SConstruct 300envList = [] 301 302# Function to create a new build environment as clone of current 303# environment 'env' with modified object suffix and optional stripped 304# binary. Additional keyword arguments are appended to corresponding 305# build environment vars. 306def makeEnv(label, objsfx, strip = False, **kwargs): 307 newEnv = env.Copy(OBJSUFFIX=objsfx) 308 newEnv.Label = label 309 newEnv.Append(**kwargs) 310 exe = 'm5.' + label # final executable 311 bin = exe + '.bin' # executable w/o appended Python zip archive 312 newEnv.Program(bin, make_objs(sources, newEnv)) 313 if strip: 314 stripped_bin = bin + '.stripped' 315 if sys.platform == 'sunos5': 316 newEnv.Command(stripped_bin, bin, 'cp $SOURCE $TARGET; strip $TARGET') 317 else: 318 newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET') 319 bin = stripped_bin 320 targets = newEnv.Concat(exe, [bin, 'python/m5py.zip']) 321 newEnv.M5Binary = targets[0] 322 envList.append(newEnv) 323 324# Debug binary 325ccflags = {} 326if env['GCC']: 327 if sys.platform == 'sunos5': 328 ccflags['debug'] = '-gstabs+' 329 else: 330 ccflags['debug'] = '-ggdb3' 331 ccflags['opt'] = '-g -O3' 332 ccflags['fast'] = '-O3' 333 ccflags['prof'] = '-O3 -g -pg' 334elif env['SUNCC']: 335 ccflags['debug'] = '-g0' 336 ccflags['opt'] = '-g -O' 337 ccflags['fast'] = '-fast' 338 ccflags['prof'] = '-fast -g -pg' 339elif env['ICC']: 340 ccflags['debug'] = '-g -O0' 341 ccflags['opt'] = '-g -O' 342 ccflags['fast'] = '-fast' 343 ccflags['prof'] = '-fast -g -pg' 344else: 345 print 'Unknown compiler, please fix compiler options' 346 Exit(1) 347 348makeEnv('debug', '.do', 349 CCFLAGS = Split(ccflags['debug']), 350 CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 351 352# Optimized binary 353makeEnv('opt', '.o', 354 CCFLAGS = Split(ccflags['opt']), 355 CPPDEFINES = ['TRACING_ON=1']) 356 357# "Fast" binary 358makeEnv('fast', '.fo', strip = True, 359 CCFLAGS = Split(ccflags['fast']), 360 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 361 362# Profiled binary 363makeEnv('prof', '.po', 364 CCFLAGS = Split(ccflags['prof']), 365 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 366 LINKFLAGS = '-pg') 367 368Return('envList') 369