SConscript revision 3683
111901Sjason@lowepower.com# -*- mode:python -*- 211901Sjason@lowepower.com 311901Sjason@lowepower.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 411901Sjason@lowepower.com# All rights reserved. 511901Sjason@lowepower.com# 611901Sjason@lowepower.com# Redistribution and use in source and binary forms, with or without 711901Sjason@lowepower.com# modification, are permitted provided that the following conditions are 811901Sjason@lowepower.com# met: redistributions of source code must retain the above copyright 911901Sjason@lowepower.com# notice, this list of conditions and the following disclaimer; 1011901Sjason@lowepower.com# redistributions in binary form must reproduce the above copyright 1111901Sjason@lowepower.com# notice, this list of conditions and the following disclaimer in the 1211901Sjason@lowepower.com# documentation and/or other materials provided with the distribution; 1311901Sjason@lowepower.com# neither the name of the copyright holders nor the names of its 1411901Sjason@lowepower.com# contributors may be used to endorse or promote products derived from 1511901Sjason@lowepower.com# this software without specific prior written permission. 1611901Sjason@lowepower.com# 1711901Sjason@lowepower.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1811901Sjason@lowepower.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1911901Sjason@lowepower.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2011901Sjason@lowepower.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2111901Sjason@lowepower.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2211901Sjason@lowepower.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2311901Sjason@lowepower.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2411901Sjason@lowepower.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2511901Sjason@lowepower.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2611901Sjason@lowepower.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2711901Sjason@lowepower.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2811901Sjason@lowepower.com# 2911901Sjason@lowepower.com# Authors: Steve Reinhardt 3011901Sjason@lowepower.com 3111901Sjason@lowepower.comimport os 3211901Sjason@lowepower.comimport sys 3311901Sjason@lowepower.comfrom os.path import isfile, join as joinpath 3411901Sjason@lowepower.com 3511901Sjason@lowepower.com# This file defines how to build a particular configuration of M5 3611901Sjason@lowepower.com# based on variable settings in the 'env' build environment. 3711901Sjason@lowepower.com 3811901Sjason@lowepower.com# Import build environment variable from SConstruct. 3911901Sjason@lowepower.comImport('env') 4011901Sjason@lowepower.com 4111901Sjason@lowepower.com################################################### 4211901Sjason@lowepower.com# 4311901Sjason@lowepower.com# Define needed sources. 4411901Sjason@lowepower.com# 4511901Sjason@lowepower.com################################################### 4611901Sjason@lowepower.com 4711901Sjason@lowepower.com# Base sources used by all configurations. 4811901Sjason@lowepower.com 4911901Sjason@lowepower.combase_sources = Split(''' 5011901Sjason@lowepower.com base/annotate.cc 5111901Sjason@lowepower.com base/circlebuf.cc 5211901Sjason@lowepower.com base/cprintf.cc 5311901Sjason@lowepower.com base/fast_alloc.cc 5411901Sjason@lowepower.com base/fifo_buffer.cc 5511901Sjason@lowepower.com base/hostinfo.cc 5611901Sjason@lowepower.com base/hybrid_pred.cc 5711901Sjason@lowepower.com base/inifile.cc 5811901Sjason@lowepower.com base/intmath.cc 5911901Sjason@lowepower.com base/match.cc 6011901Sjason@lowepower.com base/misc.cc 6111901Sjason@lowepower.com base/output.cc 6211901Sjason@lowepower.com base/pollevent.cc 6311901Sjason@lowepower.com base/range.cc 6411901Sjason@lowepower.com base/random.cc 6511901Sjason@lowepower.com base/sat_counter.cc 6611901Sjason@lowepower.com base/socket.cc 6711901Sjason@lowepower.com base/statistics.cc 6811901Sjason@lowepower.com base/str.cc 6911901Sjason@lowepower.com base/time.cc 7011901Sjason@lowepower.com base/trace.cc 7111901Sjason@lowepower.com base/traceflags.cc 7211901Sjason@lowepower.com base/userinfo.cc 7311901Sjason@lowepower.com base/compression/lzss_compression.cc 7411901Sjason@lowepower.com base/loader/aout_object.cc 7511901Sjason@lowepower.com base/loader/ecoff_object.cc 7611901Sjason@lowepower.com base/loader/elf_object.cc 7711901Sjason@lowepower.com base/loader/raw_object.cc 7811901Sjason@lowepower.com base/loader/object_file.cc 7911901Sjason@lowepower.com base/loader/symtab.cc 8011901Sjason@lowepower.com base/stats/events.cc 8111901Sjason@lowepower.com base/stats/statdb.cc 8211901Sjason@lowepower.com base/stats/visit.cc 8311901Sjason@lowepower.com base/stats/text.cc 8411901Sjason@lowepower.com 8511901Sjason@lowepower.com cpu/activity.cc 8611901Sjason@lowepower.com cpu/base.cc 8711901Sjason@lowepower.com cpu/cpuevent.cc 8811901Sjason@lowepower.com cpu/exetrace.cc 8911901Sjason@lowepower.com cpu/func_unit.cc 9011901Sjason@lowepower.com cpu/op_class.cc 9111901Sjason@lowepower.com cpu/pc_event.cc 9211901Sjason@lowepower.com cpu/quiesce_event.cc 9311901Sjason@lowepower.com cpu/static_inst.cc 9411901Sjason@lowepower.com cpu/simple_thread.cc 9511901Sjason@lowepower.com cpu/thread_state.cc 9611901Sjason@lowepower.com 9711901Sjason@lowepower.com mem/bridge.cc 9811901Sjason@lowepower.com mem/bus.cc 9911901Sjason@lowepower.com mem/dram.cc 10011901Sjason@lowepower.com mem/mem_object.cc 10111901Sjason@lowepower.com mem/packet.cc 10211901Sjason@lowepower.com mem/physical.cc 10311901Sjason@lowepower.com mem/port.cc 10411901Sjason@lowepower.com mem/tport.cc 10511901Sjason@lowepower.com 10611901Sjason@lowepower.com mem/cache/base_cache.cc 10711901Sjason@lowepower.com mem/cache/cache.cc 10811901Sjason@lowepower.com mem/cache/coherence/coherence_protocol.cc 10911901Sjason@lowepower.com mem/cache/coherence/uni_coherence.cc 11011901Sjason@lowepower.com mem/cache/miss/blocking_buffer.cc 11111901Sjason@lowepower.com mem/cache/miss/miss_queue.cc 11211901Sjason@lowepower.com mem/cache/miss/mshr.cc 11311901Sjason@lowepower.com mem/cache/miss/mshr_queue.cc 11411901Sjason@lowepower.com mem/cache/prefetch/base_prefetcher.cc 11511901Sjason@lowepower.com mem/cache/prefetch/ghb_prefetcher.cc 11611901Sjason@lowepower.com mem/cache/prefetch/prefetcher.cc 11711901Sjason@lowepower.com mem/cache/prefetch/stride_prefetcher.cc 11811901Sjason@lowepower.com mem/cache/prefetch/tagged_prefetcher.cc 11911901Sjason@lowepower.com mem/cache/tags/base_tags.cc 12011901Sjason@lowepower.com mem/cache/tags/cache_tags.cc 12111901Sjason@lowepower.com mem/cache/tags/fa_lru.cc 12211901Sjason@lowepower.com mem/cache/tags/iic.cc 12311901Sjason@lowepower.com mem/cache/tags/lru.cc 12411901Sjason@lowepower.com mem/cache/tags/repl/gen.cc 12511901Sjason@lowepower.com mem/cache/tags/repl/repl.cc 12611901Sjason@lowepower.com mem/cache/tags/split.cc 12711901Sjason@lowepower.com mem/cache/tags/split_lifo.cc 12811901Sjason@lowepower.com mem/cache/tags/split_lru.cc 12911901Sjason@lowepower.com 13011901Sjason@lowepower.com mem/cache/cache_builder.cc 13111901Sjason@lowepower.com 13211901Sjason@lowepower.com python/swig/debug_wrap.cc 13311901Sjason@lowepower.com python/swig/main_wrap.cc 13411901Sjason@lowepower.com 13511901Sjason@lowepower.com sim/builder.cc 13611901Sjason@lowepower.com sim/debug.cc 13711901Sjason@lowepower.com sim/eventq.cc 13811901Sjason@lowepower.com sim/faults.cc 13911901Sjason@lowepower.com sim/main.cc 14011901Sjason@lowepower.com sim/param.cc 14111901Sjason@lowepower.com sim/root.cc 14211901Sjason@lowepower.com sim/serialize.cc 14311901Sjason@lowepower.com sim/sim_events.cc 14411901Sjason@lowepower.com sim/sim_object.cc 14511901Sjason@lowepower.com sim/startup.cc 14611901Sjason@lowepower.com sim/stat_context.cc 14711901Sjason@lowepower.com sim/stat_control.cc 14811901Sjason@lowepower.com sim/system.cc 14911901Sjason@lowepower.com sim/trace_context.cc 15011901Sjason@lowepower.com ''') 15111901Sjason@lowepower.com 15211901Sjason@lowepower.comtrace_reader_sources = Split(''' 15311901Sjason@lowepower.com cpu/trace/reader/mem_trace_reader.cc 15411901Sjason@lowepower.com cpu/trace/reader/ibm_reader.cc 15511901Sjason@lowepower.com cpu/trace/reader/itx_reader.cc 15611901Sjason@lowepower.com cpu/trace/reader/m5_reader.cc 15711901Sjason@lowepower.com cpu/trace/opt_cpu.cc 15811901Sjason@lowepower.com cpu/trace/trace_cpu.cc 15911901Sjason@lowepower.com ''') 16011901Sjason@lowepower.com 16111901Sjason@lowepower.com 16211901Sjason@lowepower.com 16311901Sjason@lowepower.com# MySql sources 16411901Sjason@lowepower.commysql_sources = Split(''' 16511901Sjason@lowepower.com base/mysql.cc 16611901Sjason@lowepower.com base/stats/mysql.cc 16711901Sjason@lowepower.com ''') 16811901Sjason@lowepower.com 16911901Sjason@lowepower.com# Full-system sources 17011901Sjason@lowepower.comfull_system_sources = Split(''' 17111901Sjason@lowepower.com base/crc.cc 17211901Sjason@lowepower.com base/inet.cc 17311901Sjason@lowepower.com base/remote_gdb.cc 17411901Sjason@lowepower.com 17511901Sjason@lowepower.com cpu/intr_control.cc 17611901Sjason@lowepower.com cpu/profile.cc 17711901Sjason@lowepower.com 17811901Sjason@lowepower.com dev/uart.cc 17911901Sjason@lowepower.com dev/uart8250.cc 18011901Sjason@lowepower.com 18111901Sjason@lowepower.com mem/vport.cc 18211901Sjason@lowepower.com 18311901Sjason@lowepower.com sim/pseudo_inst.cc 18411901Sjason@lowepower.com ''') 18511901Sjason@lowepower.com #dev/sinic.cc 18611901Sjason@lowepower.com #dev/i8254xGBe.cc 18711901Sjason@lowepower.com 18811901Sjason@lowepower.comif env['TARGET_ISA'] == 'alpha': 18911921Spierre-yves.peneau@lirmm.fr full_system_sources += Split(''' 19011921Spierre-yves.peneau@lirmm.fr kern/tru64/dump_mbuf.cc 19111921Spierre-yves.peneau@lirmm.fr kern/tru64/printf.cc 19211921Spierre-yves.peneau@lirmm.fr kern/tru64/tru64_events.cc 19311921Spierre-yves.peneau@lirmm.fr kern/tru64/tru64_syscalls.cc 19411901Sjason@lowepower.com ''') 19511901Sjason@lowepower.com 19611901Sjason@lowepower.com# Syscall emulation (non-full-system) sources 19711901Sjason@lowepower.comsyscall_emulation_sources = Split(''' 19811901Sjason@lowepower.com mem/translating_port.cc 19911901Sjason@lowepower.com mem/page_table.cc 20011901Sjason@lowepower.com sim/process.cc 20111901Sjason@lowepower.com sim/syscall_emul.cc 20211901Sjason@lowepower.com ''') 20311901Sjason@lowepower.com 20411901Sjason@lowepower.com#if env['TARGET_ISA'] == 'alpha': 20511901Sjason@lowepower.com# syscall_emulation_sources += Split(''' 20611901Sjason@lowepower.com# kern/tru64/tru64.cc 20711901Sjason@lowepower.com# ''') 20811901Sjason@lowepower.com 20911901Sjason@lowepower.commemtest_sources = Split(''' 21011901Sjason@lowepower.com cpu/memtest/memtest.cc 21111901Sjason@lowepower.com ''') 21211901Sjason@lowepower.com 21311901Sjason@lowepower.com# Include file paths are rooted in this directory. SCons will 21411901Sjason@lowepower.com# automatically expand '.' to refer to both the source directory and 21511901Sjason@lowepower.com# the corresponding build directory to pick up generated include 21611901Sjason@lowepower.com# files. 21711901Sjason@lowepower.comenv.Append(CPPPATH=Dir('.')) 21811901Sjason@lowepower.com 21911901Sjason@lowepower.com# Add a flag defining what THE_ISA should be for all compilation 22011901Sjason@lowepower.comenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 22111901Sjason@lowepower.com 22211901Sjason@lowepower.comarch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env') 22311901Sjason@lowepower.com 22411901Sjason@lowepower.comcpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env') 22511901Sjason@lowepower.com 22611901Sjason@lowepower.comif env['FULL_SYSTEM']: 22711901Sjason@lowepower.com dev_sources = SConscript(os.path.join('dev', 'SConscript'), 22811901Sjason@lowepower.com exports = 'env') 22911901Sjason@lowepower.com full_system_sources += dev_sources 23011901Sjason@lowepower.com 23111901Sjason@lowepower.com kern_sources = SConscript(os.path.join('kern', 'SConscript'), 23211901Sjason@lowepower.com exports = 'env') 23311901Sjason@lowepower.com full_system_sources += kern_sources 23411901Sjason@lowepower.com 23511901Sjason@lowepower.com# Set up complete list of sources based on configuration. 23611901Sjason@lowepower.comsources = base_sources + arch_sources + cpu_sources 23711901Sjason@lowepower.com 23811901Sjason@lowepower.com# encumbered should be last because we're adding to some of the other groups 23911901Sjason@lowepower.comif isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')): 24011901Sjason@lowepower.com sources += SConscript('encumbered/SConscript', exports = 'env') 24111901Sjason@lowepower.com 24211901Sjason@lowepower.com 24311901Sjason@lowepower.comif env['FULL_SYSTEM']: 24411901Sjason@lowepower.com sources += full_system_sources 24511901Sjason@lowepower.comelse: 24611901Sjason@lowepower.com sources += syscall_emulation_sources 24711901Sjason@lowepower.com 24811901Sjason@lowepower.comif env['USE_MYSQL']: 24911901Sjason@lowepower.com sources += mysql_sources 25011901Sjason@lowepower.com 25111901Sjason@lowepower.comfor opt in env.ExportOptions: 25211901Sjason@lowepower.com env.ConfigFile(opt) 25311901Sjason@lowepower.com 25411901Sjason@lowepower.com################################################### 25511901Sjason@lowepower.com# 25611901Sjason@lowepower.com# Special build rules. 25711901Sjason@lowepower.com# 25811901Sjason@lowepower.com################################################### 25911901Sjason@lowepower.com 26011901Sjason@lowepower.com# base/traceflags.{cc,hh} are generated from base/traceflags.py. 26111901Sjason@lowepower.com# $TARGET.base will expand to "<build-dir>/base/traceflags". 26211901Sjason@lowepower.comenv.Command(Split('base/traceflags.hh base/traceflags.cc'), 26311901Sjason@lowepower.com 'base/traceflags.py', 26411901Sjason@lowepower.com 'python $SOURCE $TARGET.base') 26511901Sjason@lowepower.com 26611901Sjason@lowepower.comSConscript('python/SConscript', exports = ['env']) 26711901Sjason@lowepower.com 26811901Sjason@lowepower.com# This function adds the specified sources to the given build 26911901Sjason@lowepower.com# environment, and returns a list of all the corresponding SCons 27011901Sjason@lowepower.com# Object nodes (including an extra one for date.cc). We explicitly 27111901Sjason@lowepower.com# add the Object nodes so we can set up special dependencies for 27211901Sjason@lowepower.com# date.cc. 27311901Sjason@lowepower.comdef make_objs(sources, env): 27411901Sjason@lowepower.com objs = [env.Object(s) for s in sources] 27511901Sjason@lowepower.com # make date.cc depend on all other objects so it always gets 27611901Sjason@lowepower.com # recompiled whenever anything else does 27711901Sjason@lowepower.com date_obj = env.Object('base/date.cc') 27811901Sjason@lowepower.com env.Depends(date_obj, objs) 27911901Sjason@lowepower.com objs.append(date_obj) 28011901Sjason@lowepower.com return objs 28111901Sjason@lowepower.com 28211901Sjason@lowepower.com################################################### 28311901Sjason@lowepower.com# 28411901Sjason@lowepower.com# Define binaries. Each different build type (debug, opt, etc.) gets 28511901Sjason@lowepower.com# a slightly different build environment. 28611901Sjason@lowepower.com# 28711901Sjason@lowepower.com################################################### 28811901Sjason@lowepower.com 28911901Sjason@lowepower.com# List of constructed environments to pass back to SConstruct 29011901Sjason@lowepower.comenvList = [] 29111901Sjason@lowepower.com 29211901Sjason@lowepower.com# Function to create a new build environment as clone of current 29311901Sjason@lowepower.com# environment 'env' with modified object suffix and optional stripped 29411901Sjason@lowepower.com# binary. Additional keyword arguments are appended to corresponding 29511901Sjason@lowepower.com# build environment vars. 29611901Sjason@lowepower.comdef makeEnv(label, objsfx, strip = False, **kwargs): 29711901Sjason@lowepower.com newEnv = env.Copy(OBJSUFFIX=objsfx) 29811901Sjason@lowepower.com newEnv.Label = label 29911901Sjason@lowepower.com newEnv.Append(**kwargs) 30011901Sjason@lowepower.com exe = 'm5.' + label # final executable 30111901Sjason@lowepower.com bin = exe + '.bin' # executable w/o appended Python zip archive 30211901Sjason@lowepower.com newEnv.Program(bin, make_objs(sources, newEnv)) 30311901Sjason@lowepower.com if strip: 30411901Sjason@lowepower.com stripped_bin = bin + '.stripped' 30511901Sjason@lowepower.com newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET') 30611901Sjason@lowepower.com bin = stripped_bin 30711901Sjason@lowepower.com targets = newEnv.Concat(exe, [bin, 'python/m5py.zip']) 30811901Sjason@lowepower.com newEnv.M5Binary = targets[0] 30911901Sjason@lowepower.com envList.append(newEnv) 31011901Sjason@lowepower.com 31111901Sjason@lowepower.com# Debug binary 31211901Sjason@lowepower.com# Solaris seems to have some issue with DWARF2 debugging information, it's ok 31311901Sjason@lowepower.com# with stabs though 31411901Sjason@lowepower.comif sys.platform == 'sunos5': 31511901Sjason@lowepower.com debug_flag = '-gstabs+' 31611901Sjason@lowepower.comelse: 31711901Sjason@lowepower.com debug_flag = '-ggdb3' 31811901Sjason@lowepower.com 31911901Sjason@lowepower.commakeEnv('debug', '.do', 32011901Sjason@lowepower.com CCFLAGS = Split('%s -O0' % debug_flag), 32111901Sjason@lowepower.com CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 32211901Sjason@lowepower.com 32311901Sjason@lowepower.com# Optimized binary 32411901Sjason@lowepower.commakeEnv('opt', '.o', 32511901Sjason@lowepower.com CCFLAGS = Split('-g -O3'), 32611901Sjason@lowepower.com CPPDEFINES = ['TRACING_ON=1']) 32711901Sjason@lowepower.com 32811901Sjason@lowepower.com# "Fast" binary 32911901Sjason@lowepower.commakeEnv('fast', '.fo', strip = True, 33011901Sjason@lowepower.com CCFLAGS = Split('-O3'), 33111901Sjason@lowepower.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 33211901Sjason@lowepower.com 33311901Sjason@lowepower.com# Profiled binary 33411901Sjason@lowepower.commakeEnv('prof', '.po', 33511901Sjason@lowepower.com CCFLAGS = Split('-O3 -g -pg'), 33611901Sjason@lowepower.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 33711901Sjason@lowepower.com LINKFLAGS = '-pg') 338 339Return('envList') 340