SConscript revision 1154
1# -*- mode:python -*- 2 3# Copyright (c) 2004 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 31 32# This file defines how to build a particular configuration of M5 33# based on variable settings in the 'env' build environment. 34 35# Import build environment variable from SConstruct. 36Import('env') 37 38################################################### 39# 40# Define needed sources. 41# 42################################################### 43 44# Base sources used by all configurations. 45base_sources = Split(''' 46 arch/alpha/decoder.cc 47 arch/alpha/fast_cpu_exec.cc 48 arch/alpha/simple_cpu_exec.cc 49 arch/alpha/inorder_cpu_exec.cc 50 arch/alpha/full_cpu_exec.cc 51 arch/alpha/faults.cc 52 arch/alpha/isa_traits.cc 53 54 base/circlebuf.cc 55 base/copyright.cc 56 base/cprintf.cc 57 base/fast_alloc.cc 58 base/fifo_buffer.cc 59 base/hostinfo.cc 60 base/hybrid_pred.cc 61 base/inifile.cc 62 base/intmath.cc 63 base/match.cc 64 base/misc.cc 65 base/pollevent.cc 66 base/python.cc 67 base/range.cc 68 base/sat_counter.cc 69 base/socket.cc 70 base/statistics.cc 71 base/str.cc 72 base/time.cc 73 base/trace.cc 74 base/traceflags.cc 75 base/userinfo.cc 76 base/compression/lzss_compression.cc 77 base/loader/aout_object.cc 78 base/loader/ecoff_object.cc 79 base/loader/elf_object.cc 80 base/loader/object_file.cc 81 base/loader/symtab.cc 82 base/stats/events.cc 83 base/stats/python.cc 84 base/stats/statdb.cc 85 base/stats/visit.cc 86 base/stats/text.cc 87 88 cpu/base_cpu.cc 89 cpu/exec_context.cc 90 cpu/exetrace.cc 91 cpu/pc_event.cc 92 cpu/static_inst.cc 93 cpu/fast_cpu/fast_cpu.cc 94 cpu/full_cpu/bpred.cc 95 cpu/full_cpu/commit.cc 96 cpu/full_cpu/create_vector.cc 97 cpu/full_cpu/cv_spec_state.cc 98 cpu/full_cpu/dd_queue.cc 99 cpu/full_cpu/dep_link.cc 100 cpu/full_cpu/dispatch.cc 101 cpu/full_cpu/dyn_inst.cc 102 cpu/full_cpu/execute.cc 103 cpu/full_cpu/fetch.cc 104 cpu/full_cpu/floss_reasons.cc 105 cpu/full_cpu/fu_pool.cc 106 cpu/full_cpu/full_cpu.cc 107 cpu/full_cpu/inst_fifo.cc 108 cpu/full_cpu/instpipe.cc 109 cpu/full_cpu/issue.cc 110 cpu/full_cpu/ls_queue.cc 111 cpu/full_cpu/machine_queue.cc 112 cpu/full_cpu/pipetrace.cc 113 cpu/full_cpu/readyq.cc 114 cpu/full_cpu/reg_info.cc 115 cpu/full_cpu/rob_station.cc 116 cpu/full_cpu/spec_memory.cc 117 cpu/full_cpu/spec_state.cc 118 cpu/full_cpu/storebuffer.cc 119 cpu/full_cpu/writeback.cc 120 cpu/full_cpu/iq/iq_station.cc 121 cpu/full_cpu/iq/iqueue.cc 122 cpu/full_cpu/iq/segmented/chain_info.cc 123 cpu/full_cpu/iq/segmented/chain_wire.cc 124 cpu/full_cpu/iq/segmented/iq_seg.cc 125 cpu/full_cpu/iq/segmented/iq_segmented.cc 126 cpu/full_cpu/iq/segmented/seg_chain.cc 127 cpu/full_cpu/iq/seznec/iq_seznec.cc 128 cpu/full_cpu/iq/standard/iq_standard.cc 129 cpu/sampling_cpu/sampling_cpu.cc 130 cpu/simple_cpu/simple_cpu.cc 131 cpu/inorder_cpu/inorder_cpu.cc 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 137 mem/base_hier.cc 138 mem/base_mem.cc 139 mem/hier_params.cc 140 mem/mem_cmd.cc 141 mem/mem_debug.cc 142 mem/mem_req.cc 143 mem/memory_interface.cc 144 mem/bus/base_interface.cc 145 mem/bus/bus.cc 146 mem/bus/bus_bridge.cc 147 mem/bus/bus_bridge_master.cc 148 mem/bus/bus_bridge_slave.cc 149 mem/bus/bus_interface.cc 150 mem/bus/dma_bus_interface.cc 151 mem/bus/dma_interface.cc 152 mem/bus/master_interface.cc 153 mem/bus/slave_interface.cc 154 mem/cache/base_cache.cc 155 mem/cache/cache.cc 156 mem/cache/cache_builder.cc 157 mem/cache/coherence/coherence_protocol.cc 158 mem/cache/coherence/uni_coherence.cc 159 mem/cache/miss/blocking_buffer.cc 160 mem/cache/miss/miss_queue.cc 161 mem/cache/miss/mshr.cc 162 mem/cache/miss/mshr_queue.cc 163 mem/cache/tags/base_tags.cc 164 mem/cache/tags/cache_tags.cc 165 mem/cache/tags/fa_lru.cc 166 mem/cache/tags/iic.cc 167 mem/cache/tags/lru.cc 168 mem/cache/tags/split.cc 169 mem/cache/tags/split_lifo.cc 170 mem/cache/tags/split_lru.cc 171 mem/cache/tags/repl/gen.cc 172 mem/cache/tags/repl/repl.cc 173 mem/functional_mem/functional_memory.cc 174 mem/functional_mem/main_memory.cc 175 mem/timing_mem/base_memory.cc 176 mem/timing_mem/memory_builder.cc 177 mem/timing_mem/simple_mem_bank.cc 178 mem/trace/itx_writer.cc 179 mem/trace/mem_trace_writer.cc 180 mem/trace/m5_writer.cc 181 182 sim/builder.cc 183 sim/configfile.cc 184 sim/debug.cc 185 sim/eventq.cc 186 sim/main.cc 187 sim/param.cc 188 sim/profile.cc 189 sim/serialize.cc 190 sim/sim_events.cc 191 sim/sim_exit.cc 192 sim/sim_object.cc 193 sim/startup.cc 194 sim/stat_context.cc 195 sim/stat_control.cc 196 sim/trace_context.cc 197 sim/universe.cc 198 sim/pyconfig/pyconfig.cc 199 sim/pyconfig/code.cc 200 ''') 201 202base_obj_desc_files = Split(''' 203 cpu/full_cpu/iq/segmented/SegmentedIQ.od 204 cpu/full_cpu/iq/seznec/SeznecIQ.od 205 cpu/full_cpu/iq/standard/StandardIQ.od 206 cpu/full_cpu/iq/BaseIQ.od 207 cpu/full_cpu/BranchPred.od 208 cpu/full_cpu/FUDesc.od 209 cpu/full_cpu/FullCPU.od 210 cpu/full_cpu/FuncUnitPool.od 211 cpu/full_cpu/OpDesc.od 212 cpu/full_cpu/PipeTrace.od 213 cpu/sampling_cpu/SamplingCPU.od 214 cpu/simple_cpu/SimpleCPU.od 215 cpu/inorder_cpu/InorderCPU.od 216 cpu/BaseCPU.od 217 cpu/IntrControl.od 218 mem/bus/Bus.od 219 mem/bus/BusBridge.od 220 mem/cache/coherence/CoherenceProtocol.od 221 mem/cache/tags/repl/GenRepl.od 222 mem/cache/tags/repl/Repl.od 223 mem/cache/BaseCache.od 224 mem/functional_mem/FunctionalMemory.od 225 mem/functional_mem/MainMemory.od 226 mem/functional_mem/MemoryController.od 227 mem/functional_mem/PhysicalMemory.od 228 mem/timing_mem/BaseMemory.od 229 mem/BaseHier.od 230 mem/BaseMem.od 231 mem/HierParams.od 232 ''') 233 234 235# MySql sources 236mysql_sources = Split(''' 237 base/mysql.cc 238 base/stats/mysql.cc 239 ''') 240 241# Full-system sources 242full_system_sources = Split(''' 243 arch/alpha/alpha_memory.cc 244 arch/alpha/arguments.cc 245 arch/alpha/ev5.cc 246 arch/alpha/osfpal.cc 247 arch/alpha/pseudo_inst.cc 248 arch/alpha/vtophys.cc 249 250 base/crc.cc 251 base/inet.cc 252 base/remote_gdb.cc 253 254 cpu/intr_control.cc 255 256 dev/alpha_console.cc 257 dev/baddev.cc 258 dev/simconsole.cc 259 dev/disk_image.cc 260 dev/dma.cc 261 dev/etherbus.cc 262 dev/etherdump.cc 263 dev/etherint.cc 264 dev/etherlink.cc 265 dev/etherpkt.cc 266 dev/ethertap.cc 267 dev/ide_ctrl.cc 268 dev/ide_disk.cc 269 dev/io_device.cc 270 dev/ns_gige.cc 271 dev/etherdev.cc 272 dev/pciconfigall.cc 273 dev/pcidev.cc 274 dev/pktfifo.cc 275 dev/scsi.cc 276 dev/scsi_ctrl.cc 277 dev/scsi_disk.cc 278 dev/scsi_none.cc 279 dev/simple_disk.cc 280 dev/tlaser_clock.cc 281 dev/tlaser_ipi.cc 282 dev/tlaser_mbox.cc 283 dev/tlaser_mc146818.cc 284 dev/tlaser_node.cc 285 dev/tlaser_pcia.cc 286 dev/tlaser_pcidev.cc 287 dev/tlaser_serial.cc 288 dev/turbolaser.cc 289 dev/tsunami.cc 290 dev/tsunami_cchip.cc 291 dev/tsunami_fake.cc 292 dev/tsunami_io.cc 293 dev/tsunami_pchip.cc 294 dev/uart.cc 295 296 kern/kernel_binning.cc 297 kern/kernel_stats.cc 298 kern/system_events.cc 299 kern/linux/linux_events.cc 300 kern/linux/linux_syscalls.cc 301 kern/linux/linux_system.cc 302 kern/linux/printk.cc 303 kern/tru64/dump_mbuf.cc 304 kern/tru64/printf.cc 305 kern/tru64/tru64_events.cc 306 kern/tru64/tru64_syscalls.cc 307 kern/tru64/tru64_system.cc 308 309 mem/functional_mem/memory_control.cc 310 mem/functional_mem/physical_memory.cc 311 dev/platform.cc 312 313 sim/system.cc 314 ''') 315 316full_system_obj_desc_files = Split(''' 317 arch/alpha/AlphaDTB.od 318 arch/alpha/AlphaITB.od 319 arch/alpha/AlphaTLB.od 320 dev/AlphaConsole.od 321 dev/ConsoleListener.od 322 dev/CowDiskImage.od 323 dev/DiskImage.od 324 dev/DmaDevice.od 325 dev/DmaEngine.od 326 dev/EtherBus.od 327 dev/EtherDev.od 328 dev/EtherDevInt.od 329 dev/EtherDump.od 330 dev/EtherInt.od 331 dev/EtherLink.od 332 dev/EtherTap.od 333 dev/PioDevice.od 334 dev/RawDiskImage.od 335 dev/ScsiController.od 336 dev/ScsiDevice.od 337 dev/ScsiDisk.od 338 dev/SimConsole.od 339 dev/SimpleDisk.od 340 dev/TlaserClock.od 341 dev/TlaserIpi.od 342 dev/TlaserMBox.od 343 dev/TlaserMC146818.od 344 dev/TlaserNode.od 345 dev/TlaserPciDev.od 346 dev/TlaserPcia.od 347 dev/TlaserSerial.od 348 dev/TlaserUart.od 349 dev/Turbolaser.od 350 kern/tru64/Tru64System.od 351 sim/System.od 352 ''') 353 354# Syscall emulation (non-full-system) sources 355syscall_emulation_sources = Split(''' 356 arch/alpha/alpha_common_syscall_emul.cc 357 arch/alpha/alpha_linux_process.cc 358 arch/alpha/alpha_tru64_process.cc 359 cpu/memtest/memtest.cc 360 cpu/trace/opt_cpu.cc 361 cpu/trace/trace_cpu.cc 362 eio/eio.cc 363 eio/exolex.cc 364 eio/libexo.cc 365 sim/process.cc 366 sim/syscall_emul.cc 367 ''') 368 369syscall_emulation_obj_desc_files = Split(''' 370 cpu/memtest/MemTest.od 371 eio/EioProcess.od 372 sim/LiveProcess.od 373 sim/Process.od 374 ''') 375 376targetarch_files = Split(''' 377 alpha_common_syscall_emul.hh 378 alpha_linux_process.hh 379 alpha_memory.hh 380 alpha_tru64_process.hh 381 aout_machdep.h 382 arguments.hh 383 byte_swap.hh 384 ecoff_machdep.h 385 elf_machdep.h 386 ev5.hh 387 faults.hh 388 isa_fullsys_traits.hh 389 isa_traits.hh 390 machine_exo.h 391 osfpal.hh 392 pseudo_inst.hh 393 vptr.hh 394 vtophys.hh 395 ''') 396 397for f in targetarch_files: 398 env.Command('targetarch/' + f, 'arch/alpha/' + f, 399 '''echo '#include "arch/alpha/%s"' > $TARGET''' % f) 400 401 402# Set up complete list of sources based on configuration. 403sources = base_sources 404obj_desc_files = base_obj_desc_files 405 406if env['FULL_SYSTEM']: 407 sources += full_system_sources 408 obj_desc_files += full_system_obj_desc_files 409else: 410 sources += syscall_emulation_sources 411 obj_desc_files += syscall_emulation_obj_desc_files 412 413extra_libraries = [] 414if env['USE_MYSQL']: 415 sources += mysql_sources 416 env.Append(CPPDEFINES = 'USE_MYSQL') 417 env.Append(CPPDEFINES = 'STATS_BINNING') 418 env.Append(CPPPATH=['/usr/local/include/mysql', '/usr/include/mysql']) 419 env.Append(LIBS=['z']) 420 if os.path.isdir('/usr/lib64'): 421 env.Append(LIBPATH=['/usr/lib64/mysql']) 422 else: 423 env.Append(LIBPATH=['/usr/lib/mysql/']) 424 env.Append(LIBS=['mysqlclient']) 425 426 427################################################### 428# 429# Special build rules. 430# 431################################################### 432 433# base/traceflags.{cc,hh} are generated from base/traceflags.py. 434# $TARGET.base will expand to "<build-dir>/base/traceflags". 435env.Command(Split('base/traceflags.hh base/traceflags.cc'), 436 'base/traceflags.py', 437 'python $SOURCE $TARGET.base') 438 439# several files are generated from arch/$TARGET_ISA/isa_desc. 440env.Command(Split('''arch/alpha/decoder.cc 441 arch/alpha/decoder.hh 442 arch/alpha/fast_cpu_exec.cc 443 arch/alpha/simple_cpu_exec.cc 444 arch/alpha/inorder_cpu_exec.cc 445 arch/alpha/full_cpu_exec.cc'''), 446 Split('''arch/alpha/isa_desc 447 arch/isa_parser.py'''), 448 '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha') 449 450 451# libelf build is described in its own SConscript file. 452# SConscript-local is the per-config build, which just copies some 453# header files into a place where they can be found. 454SConscript('libelf/SConscript-local', exports = 'env', duplicate=0) 455 456SConscript('sim/pyconfig/SConscript', exports = ['env', 'obj_desc_files'], 457 duplicate=0) 458 459 460# This function adds the specified sources to the given build 461# environment, and returns a list of all the corresponding SCons 462# Object nodes (including an extra one for date.cc). We explicitly 463# add the Object nodes so we can set up special dependencies for 464# date.cc. 465def make_objs(sources, env): 466 objs = [env.Object(s) for s in sources] 467 # make date.cc depend on all other objects so it always gets 468 # recompiled whenever anything else does 469 date_obj = env.Object('base/date.cc') 470 env.Depends(date_obj, objs) 471 objs.append(date_obj) 472 objs.extend(extra_libraries) 473 return objs 474 475################################################### 476# 477# Define binaries. Each different build type (debug, opt, etc.) gets 478# a slightly different build environment. 479# 480################################################### 481 482# Include file paths are rooted in this directory. SCons will 483# automatically expand '.' to refer to both the source directory and 484# the corresponding build directory to pick up generated include 485# files. 486env.Append(CPPPATH='.') 487 488# Debug binary 489debug = env.Copy(OBJSUFFIX='.do') 490debug.Append(CCFLAGS=Split('-g -gstabs+ -O0')) 491debug.Append(CPPDEFINES='DEBUG') 492debug.Program(target = 'm5.debug', source = make_objs(sources, debug)) 493 494# Optimized binary 495opt = env.Copy() 496opt.Append(CCFLAGS=Split('-g -O5')) 497opt.Program(target = 'm5.opt', source = make_objs(sources, opt)) 498 499# "Fast" binary 500fast = env.Copy(OBJSUFFIX='.fo') 501fast.Append(CCFLAGS=Split('-O5')) 502fast.Append(CPPDEFINES='NDEBUG') 503fast.Program(target = 'm5.fast.unstripped', source = make_objs(sources, fast)) 504fast.Command(target = 'm5.fast', source = 'm5.fast.unstripped', 505 action = 'strip $SOURCE -o $TARGET') 506 507# Profiled binary 508prof = env.Copy(OBJSUFFIX='.po') 509prof.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg') 510prof.Program(target = 'm5.prof', source = make_objs(sources, prof)) 511