SConscript revision 3624
12155SN/A# -*- mode:python -*- 22155SN/A 32155SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 42155SN/A# All rights reserved. 52155SN/A# 62155SN/A# Redistribution and use in source and binary forms, with or without 72155SN/A# modification, are permitted provided that the following conditions are 82155SN/A# met: redistributions of source code must retain the above copyright 92155SN/A# notice, this list of conditions and the following disclaimer; 102155SN/A# redistributions in binary form must reproduce the above copyright 112155SN/A# notice, this list of conditions and the following disclaimer in the 122155SN/A# documentation and/or other materials provided with the distribution; 132155SN/A# neither the name of the copyright holders nor the names of its 142155SN/A# contributors may be used to endorse or promote products derived from 152155SN/A# this software without specific prior written permission. 162155SN/A# 172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302155SN/A 314202Sbinkertn@umich.eduimport os 322155SN/Aimport sys 337768SAli.Saidi@ARM.comfrom os.path import isfile, join as joinpath 347768SAli.Saidi@ARM.com 357768SAli.Saidi@ARM.com# This file defines how to build a particular configuration of M5 362178SN/A# based on variable settings in the 'env' build environment. 372178SN/A 382178SN/A# Import build environment variable from SConstruct. 392178SN/AImport('env') 402178SN/A 412178SN/A################################################### 422178SN/A# 432178SN/A# Define needed sources. 442178SN/A# 452178SN/A################################################### 462178SN/A 472155SN/A# Base sources used by all configurations. 485865Sksewell@umich.edu 496181Sksewell@umich.edubase_sources = Split(''' 506181Sksewell@umich.edu base/annotate.cc 515865Sksewell@umich.edu base/circlebuf.cc 523918Ssaidi@eecs.umich.edu base/cprintf.cc 535865Sksewell@umich.edu base/fast_alloc.cc 542623SN/A base/fifo_buffer.cc 553918Ssaidi@eecs.umich.edu base/hostinfo.cc 562155SN/A base/hybrid_pred.cc 572155SN/A base/inifile.cc 582292SN/A base/intmath.cc 596181Sksewell@umich.edu base/match.cc 606181Sksewell@umich.edu base/misc.cc 613918Ssaidi@eecs.umich.edu base/output.cc 622292SN/A base/pollevent.cc 632292SN/A base/range.cc 642292SN/A base/random.cc 653918Ssaidi@eecs.umich.edu base/sat_counter.cc 662292SN/A base/socket.cc 672292SN/A base/statistics.cc 682766Sktlim@umich.edu base/str.cc 692766Sktlim@umich.edu base/time.cc 702766Sktlim@umich.edu base/trace.cc 712921Sktlim@umich.edu base/traceflags.cc 722921Sktlim@umich.edu base/userinfo.cc 732766Sktlim@umich.edu base/compression/lzss_compression.cc 742766Sktlim@umich.edu base/loader/aout_object.cc 755529Snate@binkert.org base/loader/ecoff_object.cc 762766Sktlim@umich.edu base/loader/elf_object.cc 774762Snate@binkert.org base/loader/raw_object.cc 782155SN/A base/loader/object_file.cc 792155SN/A base/loader/symtab.cc 802155SN/A base/stats/events.cc 812155SN/A base/stats/statdb.cc 822155SN/A base/stats/visit.cc 832155SN/A base/stats/text.cc 842766Sktlim@umich.edu 852155SN/A cpu/activity.cc 865865Sksewell@umich.edu cpu/base.cc 872155SN/A cpu/cpuevent.cc 882155SN/A cpu/exetrace.cc 892155SN/A cpu/func_unit.cc 902155SN/A cpu/op_class.cc 912178SN/A cpu/pc_event.cc 922178SN/A cpu/quiesce_event.cc 937756SAli.Saidi@ARM.com cpu/static_inst.cc 942766Sktlim@umich.edu cpu/simple_thread.cc 952178SN/A cpu/thread_state.cc 962178SN/A 976994Snate@binkert.org mem/bridge.cc 982178SN/A mem/bus.cc 992766Sktlim@umich.edu mem/dram.cc 1002766Sktlim@umich.edu mem/mem_object.cc 1012766Sktlim@umich.edu mem/packet.cc 1022788Sktlim@umich.edu mem/physical.cc 1032178SN/A mem/port.cc 1042733Sktlim@umich.edu mem/tport.cc 1052733Sktlim@umich.edu 1062817Sksewell@umich.edu mem/cache/base_cache.cc 1072733Sktlim@umich.edu mem/cache/cache.cc 1084486Sbinkertn@umich.edu mem/cache/coherence/coherence_protocol.cc 1094486Sbinkertn@umich.edu mem/cache/coherence/uni_coherence.cc 1104776Sgblack@eecs.umich.edu mem/cache/miss/blocking_buffer.cc 1114776Sgblack@eecs.umich.edu mem/cache/miss/miss_queue.cc 1126365Sgblack@eecs.umich.edu mem/cache/miss/mshr.cc 1134486Sbinkertn@umich.edu mem/cache/miss/mshr_queue.cc 1144202Sbinkertn@umich.edu mem/cache/prefetch/base_prefetcher.cc 1154202Sbinkertn@umich.edu mem/cache/prefetch/ghb_prefetcher.cc 1164202Sbinkertn@umich.edu mem/cache/prefetch/prefetcher.cc 1174202Sbinkertn@umich.edu mem/cache/prefetch/stride_prefetcher.cc 1184202Sbinkertn@umich.edu mem/cache/prefetch/tagged_prefetcher.cc 1194776Sgblack@eecs.umich.edu mem/cache/tags/base_tags.cc 1206365Sgblack@eecs.umich.edu mem/cache/tags/cache_tags.cc 1214202Sbinkertn@umich.edu mem/cache/tags/fa_lru.cc 1224202Sbinkertn@umich.edu mem/cache/tags/iic.cc 1234202Sbinkertn@umich.edu mem/cache/tags/lru.cc 1244202Sbinkertn@umich.edu mem/cache/tags/repl/gen.cc 1255217Ssaidi@eecs.umich.edu mem/cache/tags/repl/repl.cc 1264202Sbinkertn@umich.edu mem/cache/tags/split.cc 1272155SN/A mem/cache/tags/split_lifo.cc 1284202Sbinkertn@umich.edu mem/cache/tags/split_lru.cc 1294486Sbinkertn@umich.edu 1304486Sbinkertn@umich.edu mem/cache/cache_builder.cc 1314202Sbinkertn@umich.edu 1324202Sbinkertn@umich.edu python/swig/main_wrap.cc 1332821Sktlim@umich.edu 1344776Sgblack@eecs.umich.edu sim/builder.cc 1354776Sgblack@eecs.umich.edu sim/debug.cc 1364776Sgblack@eecs.umich.edu sim/eventq.cc 1374776Sgblack@eecs.umich.edu sim/faults.cc 1382766Sktlim@umich.edu sim/main.cc 1394202Sbinkertn@umich.edu sim/param.cc 1405192Ssaidi@eecs.umich.edu sim/root.cc 1412733Sktlim@umich.edu sim/serialize.cc 1422733Sktlim@umich.edu sim/sim_events.cc 1432733Sktlim@umich.edu sim/sim_object.cc 1442733Sktlim@umich.edu sim/startup.cc 1452733Sktlim@umich.edu sim/stat_context.cc 1462874Sktlim@umich.edu sim/stat_control.cc 1472874Sktlim@umich.edu sim/system.cc 1482874Sktlim@umich.edu sim/trace_context.cc 1494202Sbinkertn@umich.edu ''') 1502733Sktlim@umich.edu 1515192Ssaidi@eecs.umich.edutrace_reader_sources = Split(''' 1525192Ssaidi@eecs.umich.edu cpu/trace/reader/mem_trace_reader.cc 1535192Ssaidi@eecs.umich.edu cpu/trace/reader/ibm_reader.cc 1545217Ssaidi@eecs.umich.edu cpu/trace/reader/itx_reader.cc 1555192Ssaidi@eecs.umich.edu cpu/trace/reader/m5_reader.cc 1565192Ssaidi@eecs.umich.edu cpu/trace/opt_cpu.cc 1575192Ssaidi@eecs.umich.edu cpu/trace/trace_cpu.cc 1585192Ssaidi@eecs.umich.edu ''') 1595192Ssaidi@eecs.umich.edu 1606667Ssteve.reinhardt@amd.com 1615192Ssaidi@eecs.umich.edu 1625192Ssaidi@eecs.umich.edu# MySql sources 1635192Ssaidi@eecs.umich.edumysql_sources = Split(''' 1645192Ssaidi@eecs.umich.edu base/mysql.cc 1655192Ssaidi@eecs.umich.edu base/stats/mysql.cc 1665192Ssaidi@eecs.umich.edu ''') 1675192Ssaidi@eecs.umich.edu 1685192Ssaidi@eecs.umich.edu# Full-system sources 1695784Sgblack@eecs.umich.edufull_system_sources = Split(''' 1705784Sgblack@eecs.umich.edu base/crc.cc 1718300Schander.sudanthi@arm.com base/inet.cc 1728300Schander.sudanthi@arm.com base/remote_gdb.cc 1738300Schander.sudanthi@arm.com 1745192Ssaidi@eecs.umich.edu cpu/intr_control.cc 1755192Ssaidi@eecs.umich.edu cpu/profile.cc 1765192Ssaidi@eecs.umich.edu 1775192Ssaidi@eecs.umich.edu dev/uart.cc 1785192Ssaidi@eecs.umich.edu dev/uart8250.cc 1798232Snate@binkert.org 1808232Snate@binkert.org mem/vport.cc 1818232Snate@binkert.org 1828300Schander.sudanthi@arm.com sim/pseudo_inst.cc 1838300Schander.sudanthi@arm.com ''') 1845192Ssaidi@eecs.umich.edu #dev/sinic.cc 1858300Schander.sudanthi@arm.com #dev/i8254xGBe.cc 1868300Schander.sudanthi@arm.com 1876036Sksewell@umich.eduif env['TARGET_ISA'] == 'alpha': 1888300Schander.sudanthi@arm.com full_system_sources += Split(''' 1898300Schander.sudanthi@arm.com kern/tru64/dump_mbuf.cc 190 kern/tru64/printf.cc 191 kern/tru64/tru64_events.cc 192 kern/tru64/tru64_syscalls.cc 193 ''') 194 195# Syscall emulation (non-full-system) sources 196syscall_emulation_sources = Split(''' 197 mem/translating_port.cc 198 mem/page_table.cc 199 sim/process.cc 200 sim/syscall_emul.cc 201 ''') 202 203#if env['TARGET_ISA'] == 'alpha': 204# syscall_emulation_sources += Split(''' 205# kern/tru64/tru64.cc 206# ''') 207 208memtest_sources = Split(''' 209 cpu/memtest/memtest.cc 210 ''') 211 212# Include file paths are rooted in this directory. SCons will 213# automatically expand '.' to refer to both the source directory and 214# the corresponding build directory to pick up generated include 215# files. 216env.Append(CPPPATH=Dir('.')) 217 218# Add a flag defining what THE_ISA should be for all compilation 219env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 220 221arch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env') 222 223cpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env') 224 225if env['FULL_SYSTEM']: 226 dev_sources = SConscript(os.path.join('dev', 'SConscript'), 227 exports = 'env') 228 full_system_sources += dev_sources 229 230 kern_sources = SConscript(os.path.join('kern', 'SConscript'), 231 exports = 'env') 232 full_system_sources += kern_sources 233 234# Set up complete list of sources based on configuration. 235sources = base_sources + arch_sources + cpu_sources 236 237# encumbered should be last because we're adding to some of the other groups 238if isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')): 239 sources += SConscript('encumbered/SConscript', exports = 'env') 240 241 242if env['FULL_SYSTEM']: 243 sources += full_system_sources 244else: 245 sources += syscall_emulation_sources 246 247if env['USE_MYSQL']: 248 sources += mysql_sources 249 250for opt in env.ExportOptions: 251 env.ConfigFile(opt) 252 253################################################### 254# 255# Special build rules. 256# 257################################################### 258 259# base/traceflags.{cc,hh} are generated from base/traceflags.py. 260# $TARGET.base will expand to "<build-dir>/base/traceflags". 261env.Command(Split('base/traceflags.hh base/traceflags.cc'), 262 'base/traceflags.py', 263 'python $SOURCE $TARGET.base') 264 265SConscript('python/SConscript', exports = ['env']) 266 267# This function adds the specified sources to the given build 268# environment, and returns a list of all the corresponding SCons 269# Object nodes (including an extra one for date.cc). We explicitly 270# add the Object nodes so we can set up special dependencies for 271# date.cc. 272def make_objs(sources, env): 273 objs = [env.Object(s) for s in sources] 274 # make date.cc depend on all other objects so it always gets 275 # recompiled whenever anything else does 276 date_obj = env.Object('base/date.cc') 277 env.Depends(date_obj, objs) 278 objs.append(date_obj) 279 return objs 280 281################################################### 282# 283# Define binaries. Each different build type (debug, opt, etc.) gets 284# a slightly different build environment. 285# 286################################################### 287 288# List of constructed environments to pass back to SConstruct 289envList = [] 290 291# Function to create a new build environment as clone of current 292# environment 'env' with modified object suffix and optional stripped 293# binary. Additional keyword arguments are appended to corresponding 294# build environment vars. 295def makeEnv(label, objsfx, strip = False, **kwargs): 296 newEnv = env.Copy(OBJSUFFIX=objsfx) 297 newEnv.Label = label 298 newEnv.Append(**kwargs) 299 exe = 'm5.' + label # final executable 300 bin = exe + '.bin' # executable w/o appended Python zip archive 301 newEnv.Program(bin, make_objs(sources, newEnv)) 302 if strip: 303 stripped_bin = bin + '.stripped' 304 newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET') 305 bin = stripped_bin 306 targets = newEnv.Concat(exe, [bin, 'python/m5py.zip']) 307 newEnv.M5Binary = targets[0] 308 envList.append(newEnv) 309 310# Debug binary 311# Solaris seems to have some issue with DWARF2 debugging information, it's ok 312# with stabs though 313if sys.platform == 'sunos5': 314 debug_flag = '-gstabs+' 315else: 316 debug_flag = '-ggdb3' 317 318makeEnv('debug', '.do', 319 CCFLAGS = Split('%s -O0' % debug_flag), 320 CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 321 322# Optimized binary 323makeEnv('opt', '.o', 324 CCFLAGS = Split('-g -O3'), 325 CPPDEFINES = ['TRACING_ON=1']) 326 327# "Fast" binary 328makeEnv('fast', '.fo', strip = True, 329 CCFLAGS = Split('-O3'), 330 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 331 332# Profiled binary 333makeEnv('prof', '.po', 334 CCFLAGS = Split('-O3 -g -pg'), 335 LINKFLAGS = '-pg') 336 337Return('envList') 338