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