SConscript revision 2397
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 29import os 30import sys 31from os.path import isdir 32 33# This file defines how to build a particular configuration of M5 34# based on variable settings in the 'env' build environment. 35 36# Import build environment variable from SConstruct. 37Import('env') 38 39################################################### 40# 41# Define needed sources. 42# 43################################################### 44 45# Base sources used by all configurations. 46base_sources = Split(''' 47 arch/alpha/decoder.cc 48 arch/alpha/faults.cc 49 arch/alpha/isa_traits.cc 50 51 base/circlebuf.cc 52 base/copyright.cc 53 base/cprintf.cc 54 base/embedfile.cc 55 base/fast_alloc.cc 56 base/fifo_buffer.cc 57 base/hostinfo.cc 58 base/hybrid_pred.cc 59 base/inifile.cc 60 base/intmath.cc 61 base/match.cc 62 base/misc.cc 63 base/output.cc 64 base/pollevent.cc 65 base/range.cc 66 base/random.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/object_file.cc 80 base/loader/symtab.cc 81 base/stats/events.cc 82 base/stats/statdb.cc 83 base/stats/visit.cc 84 base/stats/text.cc 85 86 cpu/base.cc 87 cpu/exec_context.cc 88 cpu/exetrace.cc 89 cpu/pc_event.cc 90 cpu/static_inst.cc 91 cpu/sampler/sampler.cc 92 93 mem/memory.cc 94 mem/page_table.cc 95 mem/physical.cc 96 mem/proxy.cc 97 98 python/pyconfig.cc 99 python/embedded_py.cc 100 101 sim/builder.cc 102 sim/configfile.cc 103 sim/debug.cc 104 sim/eventq.cc 105 sim/main.cc 106 sim/param.cc 107 sim/profile.cc 108 sim/root.cc 109 sim/serialize.cc 110 sim/sim_events.cc 111 sim/sim_exit.cc 112 sim/sim_object.cc 113 sim/startup.cc 114 sim/stat_context.cc 115 sim/stat_control.cc 116 sim/system.cc 117 sim/trace_context.cc 118 ''') 119 120fast_cpu_sources = Split(''' 121 arch/alpha/fast_cpu_exec.cc 122 cpu/fast/cpu.cc 123 ''') 124 125simple_cpu_sources = Split(''' 126 arch/alpha/simple_cpu_exec.cc 127 cpu/simple/cpu.cc 128 ''') 129 130trace_reader_sources = Split(''' 131 cpu/trace/reader/mem_trace_reader.cc 132 cpu/trace/reader/ibm_reader.cc 133 cpu/trace/reader/itx_reader.cc 134 cpu/trace/reader/m5_reader.cc 135 cpu/trace/opt_cpu.cc 136 cpu/trace/trace_cpu.cc 137 ''') 138 139full_cpu_sources = Split(''' 140 arch/alpha/full_cpu_exec.cc 141 cpu/base_dyn_inst.cc 142 encumbered/cpu/full/bpred.cc 143 encumbered/cpu/full/commit.cc 144 encumbered/cpu/full/cpu.cc 145 encumbered/cpu/full/create_vector.cc 146 encumbered/cpu/full/cv_spec_state.cc 147 encumbered/cpu/full/dd_queue.cc 148 encumbered/cpu/full/dep_link.cc 149 encumbered/cpu/full/dispatch.cc 150 encumbered/cpu/full/dyn_inst.cc 151 encumbered/cpu/full/execute.cc 152 encumbered/cpu/full/fetch.cc 153 encumbered/cpu/full/floss_reasons.cc 154 encumbered/cpu/full/inst_fifo.cc 155 encumbered/cpu/full/instpipe.cc 156 encumbered/cpu/full/issue.cc 157 encumbered/cpu/full/ls_queue.cc 158 encumbered/cpu/full/machine_queue.cc 159 encumbered/cpu/full/pipetrace.cc 160 encumbered/cpu/full/readyq.cc 161 encumbered/cpu/full/reg_info.cc 162 encumbered/cpu/full/rob_station.cc 163 encumbered/cpu/full/spec_memory.cc 164 encumbered/cpu/full/spec_state.cc 165 encumbered/cpu/full/storebuffer.cc 166 encumbered/cpu/full/writeback.cc 167 encumbered/cpu/full/iq/iq_station.cc 168 encumbered/cpu/full/iq/iqueue.cc 169 encumbered/cpu/full/iq/segmented/chain_info.cc 170 encumbered/cpu/full/iq/segmented/chain_wire.cc 171 encumbered/cpu/full/iq/segmented/iq_seg.cc 172 encumbered/cpu/full/iq/segmented/iq_segmented.cc 173 encumbered/cpu/full/iq/segmented/seg_chain.cc 174 encumbered/cpu/full/iq/seznec/iq_seznec.cc 175 encumbered/cpu/full/iq/standard/iq_standard.cc 176 ''') 177 178o3_cpu_sources = Split(''' 179 arch/alpha/alpha_o3_exec.cc 180 cpu/o3/2bit_local_pred.cc 181 cpu/o3/alpha_dyn_inst.cc 182 cpu/o3/alpha_cpu.cc 183 cpu/o3/alpha_cpu_builder.cc 184 cpu/o3/bpred_unit.cc 185 cpu/o3/btb.cc 186 cpu/o3/commit.cc 187 cpu/o3/decode.cc 188 cpu/o3/fetch.cc 189 cpu/o3/free_list.cc 190 cpu/o3/cpu.cc 191 cpu/o3/iew.cc 192 cpu/o3/inst_queue.cc 193 cpu/o3/ldstq.cc 194 cpu/o3/mem_dep_unit.cc 195 cpu/o3/ras.cc 196 cpu/o3/rename.cc 197 cpu/o3/rename_map.cc 198 cpu/o3/rob.cc 199 cpu/o3/sat_counter.cc 200 cpu/o3/store_set.cc 201 cpu/o3/tournament_pred.cc 202 ''') 203 204# MySql sources 205mysql_sources = Split(''' 206 base/mysql.cc 207 base/stats/mysql.cc 208 ''') 209 210# Full-system sources 211full_system_sources = Split(''' 212 arch/alpha/alpha_memory.cc 213 arch/alpha/arguments.cc 214 arch/alpha/ev5.cc 215 arch/alpha/osfpal.cc 216 arch/alpha/pseudo_inst.cc 217 arch/alpha/stacktrace.cc 218 arch/alpha/vtophys.cc 219 220 base/crc.cc 221 base/inet.cc 222 base/remote_gdb.cc 223 224 cpu/intr_control.cc 225 cpu/profile.cc 226 227 dev/alpha_console.cc 228 dev/baddev.cc 229 dev/simconsole.cc 230 dev/disk_image.cc 231 dev/etherbus.cc 232 dev/etherdump.cc 233 dev/etherint.cc 234 dev/etherlink.cc 235 dev/etherpkt.cc 236 dev/ethertap.cc 237 dev/ide_ctrl.cc 238 dev/ide_disk.cc 239 dev/io_device.cc 240 dev/ns_gige.cc 241 dev/pciconfigall.cc 242 dev/pcidev.cc 243 dev/pcifake.cc 244 dev/pktfifo.cc 245 dev/platform.cc 246 dev/sinic.cc 247 dev/simple_disk.cc 248 dev/tsunami.cc 249 dev/tsunami_cchip.cc 250 dev/isa_fake.cc 251 dev/tsunami_io.cc 252 dev/tsunami_pchip.cc 253 dev/uart.cc 254 dev/uart8250.cc 255 256 kern/kernel_binning.cc 257 kern/kernel_stats.cc 258 kern/system_events.cc 259 kern/freebsd/freebsd_system.cc 260 kern/linux/linux_syscalls.cc 261 kern/linux/linux_system.cc 262 kern/linux/printk.cc 263 kern/tru64/dump_mbuf.cc 264 kern/tru64/printf.cc 265 kern/tru64/tru64_events.cc 266 kern/tru64/tru64_syscalls.cc 267 kern/tru64/tru64_system.cc 268 269 mem/functional/memory_control.cc 270 ''') 271 272# turbolaser encumbered sources 273turbolaser_sources = Split(''' 274 encumbered/dev/dma.cc 275 encumbered/dev/etherdev.cc 276 encumbered/dev/scsi.cc 277 encumbered/dev/scsi_ctrl.cc 278 encumbered/dev/scsi_disk.cc 279 encumbered/dev/scsi_none.cc 280 encumbered/dev/tlaser_clock.cc 281 encumbered/dev/tlaser_ipi.cc 282 encumbered/dev/tlaser_mbox.cc 283 encumbered/dev/tlaser_mc146818.cc 284 encumbered/dev/tlaser_node.cc 285 encumbered/dev/tlaser_pcia.cc 286 encumbered/dev/tlaser_pcidev.cc 287 encumbered/dev/tlaser_serial.cc 288 encumbered/dev/turbolaser.cc 289 encumbered/dev/uart8530.cc 290 ''') 291 292# Syscall emulation (non-full-system) sources 293syscall_emulation_sources = Split(''' 294 arch/alpha/alpha_common_syscall_emul.cc 295 arch/alpha/alpha_linux_process.cc 296 arch/alpha/alpha_tru64_process.cc 297 cpu/memtest/memtest.cc 298 encumbered/eio/eio.cc 299 encumbered/eio/exolex.cc 300 encumbered/eio/libexo.cc 301 sim/process.cc 302 sim/syscall_emul.cc 303 ''') 304 305targetarch_files = Split(''' 306 alpha_common_syscall_emul.hh 307 alpha_linux_process.hh 308 alpha_memory.hh 309 alpha_tru64_process.hh 310 aout_machdep.h 311 arguments.hh 312 byte_swap.hh 313 ecoff_machdep.h 314 ev5.hh 315 faults.hh 316 isa_fullsys_traits.hh 317 isa_traits.hh 318 osfpal.hh 319 pseudo_inst.hh 320 stacktrace.hh 321 vptr.hh 322 vtophys.hh 323 ''') 324 325for f in targetarch_files: 326 env.Command('targetarch/' + f, 'arch/alpha/' + f, 327 '''echo '#include "arch/alpha/%s"' > $TARGET''' % f) 328 329 330# Set up complete list of sources based on configuration. 331sources = base_sources 332 333if env['FULL_SYSTEM']: 334 sources += full_system_sources 335 if env['ALPHA_TLASER']: 336 sources += turbolaser_sources 337else: 338 sources += syscall_emulation_sources 339 340if env['USE_MYSQL']: 341 sources += mysql_sources 342 343for opt in env.ExportOptions: 344 env.ConfigFile(opt) 345 346################################################### 347# 348# Special build rules. 349# 350################################################### 351 352# base/traceflags.{cc,hh} are generated from base/traceflags.py. 353# $TARGET.base will expand to "<build-dir>/base/traceflags". 354env.Command(Split('base/traceflags.hh base/traceflags.cc'), 355 'base/traceflags.py', 356 'python $SOURCE $TARGET.base') 357 358# several files are generated from arch/$TARGET_ISA/isa_desc. 359env.Command(Split('''arch/alpha/decoder.cc 360 arch/alpha/decoder.hh 361 arch/alpha/alpha_o3_exec.cc 362 arch/alpha/fast_cpu_exec.cc 363 arch/alpha/simple_cpu_exec.cc'''), 364 Split('''arch/alpha/isa_desc 365 arch/isa_parser.py'''), 366 '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha') 367 368 369# libelf build is described in its own SConscript file. 370# SConscript-local is the per-config build, which just copies some 371# header files into a place where they can be found. 372SConscript('libelf/SConscript-local', exports = 'env', duplicate=0) 373SConscript('python/SConscript', exports = ['env'], duplicate=0) 374 375# This function adds the specified sources to the given build 376# environment, and returns a list of all the corresponding SCons 377# Object nodes (including an extra one for date.cc). We explicitly 378# add the Object nodes so we can set up special dependencies for 379# date.cc. 380def make_objs(sources, env): 381 objs = [env.Object(s) for s in sources] 382 # make date.cc depend on all other objects so it always gets 383 # recompiled whenever anything else does 384 date_obj = env.Object('base/date.cc') 385 env.Depends(date_obj, objs) 386 objs.append(date_obj) 387 return objs 388 389################################################### 390# 391# Define binaries. Each different build type (debug, opt, etc.) gets 392# a slightly different build environment. 393# 394################################################### 395 396# Include file paths are rooted in this directory. SCons will 397# automatically expand '.' to refer to both the source directory and 398# the corresponding build directory to pick up generated include 399# files. 400env.Append(CPPPATH='.') 401 402# Debug binary 403debugEnv = env.Copy(OBJSUFFIX='.do') 404debugEnv.Label = 'debug' 405debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0')) 406debugEnv.Append(CPPDEFINES='DEBUG') 407tlist = debugEnv.Program(target = 'm5.debug', 408 source = make_objs(sources, debugEnv)) 409debugEnv.M5Binary = tlist[0] 410 411# Optimized binary 412optEnv = env.Copy() 413optEnv.Label = 'opt' 414optEnv.Append(CCFLAGS=Split('-g -O5')) 415tlist = optEnv.Program(target = 'm5.opt', 416 source = make_objs(sources, optEnv)) 417optEnv.M5Binary = tlist[0] 418 419# "Fast" binary 420fastEnv = env.Copy(OBJSUFFIX='.fo') 421fastEnv.Label = 'fast' 422fastEnv.Append(CCFLAGS=Split('-O5')) 423fastEnv.Append(CPPDEFINES='NDEBUG') 424fastEnv.Program(target = 'm5.fast.unstripped', 425 source = make_objs(sources, fastEnv)) 426tlist = fastEnv.Command(target = 'm5.fast', 427 source = 'm5.fast.unstripped', 428 action = 'strip $SOURCE -o $TARGET') 429fastEnv.M5Binary = tlist[0] 430 431# Profiled binary 432profEnv = env.Copy(OBJSUFFIX='.po') 433profEnv.Label = 'prof' 434profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg') 435tlist = profEnv.Program(target = 'm5.prof', 436 source = make_objs(sources, profEnv)) 437profEnv.M5Binary = tlist[0] 438 439envList = [debugEnv, optEnv, fastEnv, profEnv] 440 441Return('envList') 442