SConscript revision 9646
12SN/A# -*- mode:python -*- 21762SN/A 32SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 42SN/A# All rights reserved. 52SN/A# 62SN/A# Redistribution and use in source and binary forms, with or without 72SN/A# modification, are permitted provided that the following conditions are 82SN/A# met: redistributions of source code must retain the above copyright 92SN/A# notice, this list of conditions and the following disclaimer; 102SN/A# redistributions in binary form must reproduce the above copyright 112SN/A# notice, this list of conditions and the following disclaimer in the 122SN/A# documentation and/or other materials provided with the distribution; 132SN/A# neither the name of the copyright holders nor the names of its 142SN/A# contributors may be used to endorse or promote products derived from 152SN/A# this software without specific prior written permission. 162SN/A# 172SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert 302665Ssaidi@eecs.umich.edu 312SN/Aimport array 322SN/Aimport bisect 332SN/Aimport imp 342SN/Aimport marshal 352SN/Aimport os 362655Sstever@eecs.umich.eduimport re 372655Sstever@eecs.umich.eduimport sys 382SN/Aimport zlib 392SN/A 401399SN/Afrom os.path import basename, dirname, exists, isdir, isfile, join as joinpath 411396SN/A 422SN/Aimport SCons 432SN/A 442729Ssaidi@eecs.umich.edu# This file defines how to build a particular configuration of gem5 452SN/A# based on variable settings in the 'env' build environment. 461310SN/A 472SN/AImport('*') 482SN/A 492SN/A# Children need to see the environment 502667Sstever@eecs.umich.eduExport('env') 5156SN/A 52146SN/Abuild_env = [(opt, env[opt]) for opt in export_vars] 531388SN/A 5456SN/Afrom m5.util import code_formatter, compareVersions 5556SN/A 561311SN/A######################################################################## 57400SN/A# Code for adding source files of various types 583356Sbinkertn@umich.edu# 591717SN/A# When specifying a source file of some type, a set of guards can be 601717SN/A# specified for that file. When get() is used to find the files, if 612738Sstever@eecs.umich.edu# get specifies a set of filters, only files that match those filters 622738Sstever@eecs.umich.edu# will be accepted (unspecified filters on files are assumed to be 633868Sbinkertn@umich.edu# false). Current filters are: 64146SN/A# main -- specifies the gem5 main() function 65146SN/A# skip_lib -- do not put this file into the gem5 library 66146SN/A# <unittest> -- unit tests use filters based on the unit test name 672797Sktlim@umich.edu# 6856SN/A# A parent can now be specified for a source file and default filter 6956SN/A# values will be retrieved recursively from parents (children override 7056SN/A# parents). 713202Shsul@eecs.umich.edu# 72695SN/Aclass SourceMeta(type): 73695SN/A '''Meta class for source files that keeps track of all files of a 741696SN/A particular type and has a get function for finding all functions 752SN/A of a certain type that match a set of guards''' 762SN/A def __init__(cls, name, bases, dict): 772SN/A super(SourceMeta, cls).__init__(name, bases, dict) 782SN/A cls.all = [] 792SN/A 802SN/A def get(cls, **guards): 81329SN/A '''Find all files that match the specified guards. If a source 822SN/A file does not specify a flag, the default is False''' 832SN/A for src in cls.all: 842SN/A for flag,value in guards.iteritems(): 852SN/A # if the flag is found and has a different value, skip 862SN/A # this file 872SN/A if src.all_guards.get(flag, False) != value: 882SN/A break 892SN/A else: 902SN/A yield src 912SN/A 922SN/Aclass SourceFile(object): 932SN/A '''Base object that encapsulates the notion of a source file. 94329SN/A This includes, the source node, target node, various manipulations 95329SN/A of those. A source file also specifies a set of guards which 96329SN/A describing which builds the source file applies to. A parent can 97329SN/A also be specified to get default guards from''' 98329SN/A __metaclass__ = SourceMeta 99329SN/A def __init__(self, source, parent=None, **guards): 100329SN/A self.guards = guards 1012SN/A self.parent = parent 1022SN/A 1032SN/A tnode = source 1042SN/A if not isinstance(source, SCons.Node.FS.File): 1052SN/A tnode = File(source) 1062SN/A 1072SN/A self.tnode = tnode 1082SN/A self.snode = tnode.srcnode() 109764SN/A 110764SN/A for base in type(self).__mro__: 111764SN/A if issubclass(base, SourceFile): 112764SN/A base.all.append(self) 113764SN/A 114764SN/A @property 115764SN/A def filename(self): 116764SN/A return str(self.tnode) 117764SN/A 118764SN/A @property 119764SN/A def dirname(self): 120764SN/A return dirname(self.filename) 1212SN/A 1222SN/A @property 1232SN/A def basename(self): 1242SN/A return basename(self.filename) 1252SN/A 126329SN/A @property 127329SN/A def extname(self): 128329SN/A index = self.basename.rfind('.') 129764SN/A if index <= 0: 1302SN/A # dot files aren't extensions 1312655Sstever@eecs.umich.edu return self.basename, None 1322667Sstever@eecs.umich.edu 1332667Sstever@eecs.umich.edu return self.basename[:index], self.basename[index+1:] 1342889Sbinkertn@umich.edu 1352889Sbinkertn@umich.edu @property 1362889Sbinkertn@umich.edu def all_guards(self): 1372889Sbinkertn@umich.edu '''find all guards for this object getting default values 1382667Sstever@eecs.umich.edu recursively from its parents''' 1392667Sstever@eecs.umich.edu guards = {} 1402667Sstever@eecs.umich.edu if self.parent: 1412889Sbinkertn@umich.edu guards.update(self.parent.guards) 1422889Sbinkertn@umich.edu guards.update(self.guards) 1432667Sstever@eecs.umich.edu return guards 1442667Sstever@eecs.umich.edu 1452889Sbinkertn@umich.edu def __lt__(self, other): return self.filename < other.filename 1462667Sstever@eecs.umich.edu def __le__(self, other): return self.filename <= other.filename 1472667Sstever@eecs.umich.edu def __gt__(self, other): return self.filename > other.filename 1483356Sbinkertn@umich.edu def __ge__(self, other): return self.filename >= other.filename 1493356Sbinkertn@umich.edu def __eq__(self, other): return self.filename == other.filename 1503356Sbinkertn@umich.edu def __ne__(self, other): return self.filename != other.filename 1513356Sbinkertn@umich.edu 1523356Sbinkertn@umich.educlass Source(SourceFile): 1532667Sstever@eecs.umich.edu '''Add a c/c++ source file to the build''' 1542655Sstever@eecs.umich.edu def __init__(self, source, Werror=True, swig=False, **guards): 1552655Sstever@eecs.umich.edu '''specify the source file, and any guards''' 1561311SN/A super(Source, self).__init__(source, **guards) 1573645Sbinkertn@umich.edu 1583868Sbinkertn@umich.edu self.Werror = Werror 1591703SN/A self.swig = swig 1603102Sstever@eecs.umich.edu 1613102Sstever@eecs.umich.educlass PySource(SourceFile): 1622667Sstever@eecs.umich.edu '''Add a python source file to the named package''' 1632667Sstever@eecs.umich.edu invalid_sym_char = re.compile('[^A-z0-9_]') 1642655Sstever@eecs.umich.edu modules = {} 1652667Sstever@eecs.umich.edu tnodes = {} 1661388SN/A symnames = {} 1672762Sstever@eecs.umich.edu 1682762Sstever@eecs.umich.edu def __init__(self, package, source, **guards): 1692762Sstever@eecs.umich.edu '''specify the python package, the source file, and any guards''' 1702762Sstever@eecs.umich.edu super(PySource, self).__init__(source, **guards) 1712762Sstever@eecs.umich.edu 1722762Sstever@eecs.umich.edu modname,ext = self.extname 1732762Sstever@eecs.umich.edu assert ext == 'py' 1742762Sstever@eecs.umich.edu 1752738Sstever@eecs.umich.edu if package: 1762667Sstever@eecs.umich.edu path = package.split('.') 1772738Sstever@eecs.umich.edu else: 1782738Sstever@eecs.umich.edu path = [] 1792738Sstever@eecs.umich.edu 1802738Sstever@eecs.umich.edu modpath = path[:] 1812738Sstever@eecs.umich.edu if modname != '__init__': 1822738Sstever@eecs.umich.edu modpath += [ modname ] 1832738Sstever@eecs.umich.edu modpath = '.'.join(modpath) 1842738Sstever@eecs.umich.edu 1852738Sstever@eecs.umich.edu arcpath = path + [ self.basename ] 1862738Sstever@eecs.umich.edu abspath = self.snode.abspath 1872738Sstever@eecs.umich.edu if not exists(abspath): 1882738Sstever@eecs.umich.edu abspath = self.tnode.abspath 1892738Sstever@eecs.umich.edu 1902738Sstever@eecs.umich.edu self.package = package 1912738Sstever@eecs.umich.edu self.modname = modname 1922738Sstever@eecs.umich.edu self.modpath = modpath 1932738Sstever@eecs.umich.edu self.arcname = joinpath(*arcpath) 1942738Sstever@eecs.umich.edu self.abspath = abspath 1952738Sstever@eecs.umich.edu self.compiled = File(self.filename + 'c') 1962738Sstever@eecs.umich.edu self.cpp = File(self.filename + '.cc') 1972738Sstever@eecs.umich.edu self.symname = PySource.invalid_sym_char.sub('_', modpath) 1982738Sstever@eecs.umich.edu 1992738Sstever@eecs.umich.edu PySource.modules[modpath] = self 2002738Sstever@eecs.umich.edu PySource.tnodes[self.tnode] = self 2012738Sstever@eecs.umich.edu PySource.symnames[self.symname] = self 2022738Sstever@eecs.umich.edu 2032738Sstever@eecs.umich.educlass SimObject(PySource): 2042738Sstever@eecs.umich.edu '''Add a SimObject python file as a python source object and add 2052738Sstever@eecs.umich.edu it to a list of sim object modules''' 2062738Sstever@eecs.umich.edu 2072738Sstever@eecs.umich.edu fixed = False 2082738Sstever@eecs.umich.edu modnames = [] 2092738Sstever@eecs.umich.edu 2102738Sstever@eecs.umich.edu def __init__(self, source, **guards): 2112738Sstever@eecs.umich.edu '''Specify the source file and any guards (automatically in 2122738Sstever@eecs.umich.edu the m5.objects package)''' 2132738Sstever@eecs.umich.edu super(SimObject, self).__init__('m5.objects', source, **guards) 2142738Sstever@eecs.umich.edu if self.fixed: 2152738Sstever@eecs.umich.edu raise AttributeError, "Too late to call SimObject now." 2162738Sstever@eecs.umich.edu 2172667Sstever@eecs.umich.edu bisect.insort_right(SimObject.modnames, self.modname) 2182738Sstever@eecs.umich.edu 2192667Sstever@eecs.umich.educlass SwigSource(SourceFile): 2202738Sstever@eecs.umich.edu '''Add a swig file to build''' 2212655Sstever@eecs.umich.edu 2221388SN/A def __init__(self, package, source, **guards): 2232SN/A '''Specify the python package, the source file, and any guards''' 2242928Sktlim@umich.edu super(SwigSource, self).__init__(source, **guards) 2252SN/A 2261388SN/A modname,ext = self.extname 2271388SN/A assert ext == 'i' 2282738Sstever@eecs.umich.edu 2292SN/A self.module = modname 2301310SN/A cc_file = joinpath(self.dirname, modname + '_wrap.cc') 2312738Sstever@eecs.umich.edu py_file = joinpath(self.dirname, modname + '.py') 2322738Sstever@eecs.umich.edu 2332738Sstever@eecs.umich.edu self.cc_source = Source(cc_file, swig=True, parent=self) 2342738Sstever@eecs.umich.edu self.py_source = PySource(package, py_file, parent=self) 2352738Sstever@eecs.umich.edu 2362738Sstever@eecs.umich.educlass ProtoBuf(SourceFile): 2372738Sstever@eecs.umich.edu '''Add a Protocol Buffer to build''' 2382738Sstever@eecs.umich.edu 2392738Sstever@eecs.umich.edu def __init__(self, source, **guards): 2402738Sstever@eecs.umich.edu '''Specify the source file, and any guards''' 2412738Sstever@eecs.umich.edu super(ProtoBuf, self).__init__(source, **guards) 2422738Sstever@eecs.umich.edu 2432738Sstever@eecs.umich.edu # Get the file name and the extension 2442738Sstever@eecs.umich.edu modname,ext = self.extname 2452738Sstever@eecs.umich.edu assert ext == 'proto' 2462738Sstever@eecs.umich.edu 2472738Sstever@eecs.umich.edu # Currently, we stick to generating the C++ headers, so we 2482738Sstever@eecs.umich.edu # only need to track the source and header. 2492738Sstever@eecs.umich.edu self.cc_file = File(joinpath(self.dirname, modname + '.pb.cc')) 2502738Sstever@eecs.umich.edu self.hh_file = File(joinpath(self.dirname, modname + '.pb.h')) 2512738Sstever@eecs.umich.edu 2522738Sstever@eecs.umich.educlass UnitTest(object): 2532738Sstever@eecs.umich.edu '''Create a UnitTest''' 2542738Sstever@eecs.umich.edu 2552738Sstever@eecs.umich.edu all = [] 2562738Sstever@eecs.umich.edu def __init__(self, target, *sources, **kwargs): 2572738Sstever@eecs.umich.edu '''Specify the target name and any sources. Sources that are 2582738Sstever@eecs.umich.edu not SourceFiles are evalued with Source(). All files are 2592738Sstever@eecs.umich.edu guarded with a guard of the same name as the UnitTest 2602738Sstever@eecs.umich.edu target.''' 2612738Sstever@eecs.umich.edu 2622738Sstever@eecs.umich.edu srcs = [] 2632738Sstever@eecs.umich.edu for src in sources: 2642738Sstever@eecs.umich.edu if not isinstance(src, SourceFile): 2652738Sstever@eecs.umich.edu src = Source(src, skip_lib=True) 2662738Sstever@eecs.umich.edu src.guards[target] = True 2672738Sstever@eecs.umich.edu srcs.append(src) 2682738Sstever@eecs.umich.edu 2692738Sstever@eecs.umich.edu self.sources = srcs 2702738Sstever@eecs.umich.edu self.target = target 2712738Sstever@eecs.umich.edu self.main = kwargs.get('main', False) 2722738Sstever@eecs.umich.edu UnitTest.all.append(self) 2732738Sstever@eecs.umich.edu 2742738Sstever@eecs.umich.edu# Children should have access 2752738Sstever@eecs.umich.eduExport('Source') 2762738Sstever@eecs.umich.eduExport('PySource') 2772738Sstever@eecs.umich.eduExport('SimObject') 2781388SN/AExport('SwigSource') 2791388SN/AExport('ProtoBuf') 2801388SN/AExport('UnitTest') 2811388SN/A 2822667Sstever@eecs.umich.edu######################################################################## 2831104SN/A# 2842SN/A# Debug Flags 2851127SN/A# 2861127SN/Adebug_flags = {} 2871127SN/Adef DebugFlag(name, desc=None): 2882SN/A if name in debug_flags: 2892738Sstever@eecs.umich.edu raise AttributeError, "Flag %s already specified" % name 2902SN/A debug_flags[name] = (name, (), desc) 2912738Sstever@eecs.umich.edu 2922SN/Adef CompoundFlag(name, flags, desc=None): 2932SN/A if name in debug_flags: 2942SN/A raise AttributeError, "Flag %s already specified" % name 2952SN/A 296729SN/A compound = tuple(flags) 2972SN/A debug_flags[name] = (name, compound, desc) 298395SN/A 299729SN/AExport('DebugFlag') 300395SN/AExport('CompoundFlag') 3011127SN/A 3022667Sstever@eecs.umich.edu######################################################################## 3032667Sstever@eecs.umich.edu# 3042667Sstever@eecs.umich.edu# Set some compiler variables 3052667Sstever@eecs.umich.edu# 3062667Sstever@eecs.umich.edu 3072667Sstever@eecs.umich.edu# Include file paths are rooted in this directory. SCons will 3082667Sstever@eecs.umich.edu# automatically expand '.' to refer to both the source directory and 3092667Sstever@eecs.umich.edu# the corresponding build directory to pick up generated include 3102667Sstever@eecs.umich.edu# files. 3113511Shsul@eecs.umich.eduenv.Append(CPPPATH=Dir('.')) 3122667Sstever@eecs.umich.edu 3132667Sstever@eecs.umich.edufor extra_dir in extras_dir_list: 3142667Sstever@eecs.umich.edu env.Append(CPPPATH=Dir(extra_dir)) 3153511Shsul@eecs.umich.edu 3163511Shsul@eecs.umich.edu# Workaround for bug in SCons version > 0.97d20071212 3173511Shsul@eecs.umich.edu# Scons bug id: 2006 gem5 Bug id: 308 3182667Sstever@eecs.umich.edufor root, dirs, files in os.walk(base_dir, topdown=True): 3192667Sstever@eecs.umich.edu Dir(root[len(base_dir) + 1:]) 3202667Sstever@eecs.umich.edu 3212667Sstever@eecs.umich.edu######################################################################## 3223144Shsul@eecs.umich.edu# 3233144Shsul@eecs.umich.edu# Walk the tree and execute all SConscripts in subdirectories 3242667Sstever@eecs.umich.edu# 3252667Sstever@eecs.umich.edu 3262667Sstever@eecs.umich.eduhere = Dir('.').srcnode().abspath 3272667Sstever@eecs.umich.edufor root, dirs, files in os.walk(base_dir, topdown=True): 3282667Sstever@eecs.umich.edu if root == here: 3292SN/A # we don't want to recurse back into this SConscript 3302SN/A continue 3312SN/A 3322SN/A if 'SConscript' in files: 3332SN/A build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:]) 3342SN/A SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3352667Sstever@eecs.umich.edu 3362667Sstever@eecs.umich.edufor extra_dir in extras_dir_list: 3372667Sstever@eecs.umich.edu prefix_len = len(dirname(extra_dir)) + 1 3382667Sstever@eecs.umich.edu for root, dirs, files in os.walk(extra_dir, topdown=True): 3392667Sstever@eecs.umich.edu # if build lives in the extras directory, don't walk down it 3402667Sstever@eecs.umich.edu if 'build' in dirs: 3412667Sstever@eecs.umich.edu dirs.remove('build') 3422667Sstever@eecs.umich.edu 3432667Sstever@eecs.umich.edu if 'SConscript' in files: 3442667Sstever@eecs.umich.edu build_dir = joinpath(env['BUILDDIR'], root[prefix_len:]) 3452667Sstever@eecs.umich.edu SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3462667Sstever@eecs.umich.edu 3472667Sstever@eecs.umich.edufor opt in export_vars: 3482667Sstever@eecs.umich.edu env.ConfigFile(opt) 3492667Sstever@eecs.umich.edu 3502667Sstever@eecs.umich.edudef makeTheISA(source, target, env): 3512667Sstever@eecs.umich.edu isas = [ src.get_contents() for src in source ] 3522SN/A target_isa = env['TARGET_ISA'] 3532SN/A def define(isa): 3542SN/A return isa.upper() + '_ISA' 3552SN/A 3562SN/A def namespace(isa): 357294SN/A return isa[0].upper() + isa[1:].lower() + 'ISA' 358729SN/A 359294SN/A 3602SN/A code = code_formatter() 3612SN/A code('''\ 362329SN/A#ifndef __CONFIG_THE_ISA_HH__ 363329SN/A#define __CONFIG_THE_ISA_HH__ 364329SN/A 365729SN/A''') 366329SN/A 367329SN/A for i,isa in enumerate(isas): 368329SN/A code('#define $0 $1', define(isa), i + 1) 3692SN/A 3702SN/A code(''' 3712667Sstever@eecs.umich.edu 3722SN/A#define THE_ISA ${{define(target_isa)}} 3732SN/A#define TheISA ${{namespace(target_isa)}} 3742SN/A#define THE_ISA_STR "${{target_isa}}" 3752SN/A 3762SN/A#endif // __CONFIG_THE_ISA_HH__''') 3772SN/A 3782SN/A code.write(str(target[0])) 3792SN/A 3802SN/Aenv.Command('config/the_isa.hh', map(Value, all_isa_list), 3812SN/A MakeAction(makeTheISA, Transform("CFG ISA", 0))) 3822667Sstever@eecs.umich.edu 3832667Sstever@eecs.umich.edu######################################################################## 3842SN/A# 3852797Sktlim@umich.edu# Prevent any SimObjects from being added after this point, they 3862839Sktlim@umich.edu# should all have been added in the SConscripts above 3872797Sktlim@umich.edu# 3882839Sktlim@umich.eduSimObject.fixed = True 3892797Sktlim@umich.edu 3902797Sktlim@umich.educlass DictImporter(object): 3912797Sktlim@umich.edu '''This importer takes a dictionary of arbitrary module names that 3922839Sktlim@umich.edu map to arbitrary filenames.''' 3932797Sktlim@umich.edu def __init__(self, modules): 3942839Sktlim@umich.edu self.modules = modules 3952839Sktlim@umich.edu self.installed = set() 3962797Sktlim@umich.edu 3972839Sktlim@umich.edu def __del__(self): 3982839Sktlim@umich.edu self.unload() 3992797Sktlim@umich.edu 4002797Sktlim@umich.edu def unload(self): 4012797Sktlim@umich.edu import sys 4022797Sktlim@umich.edu for module in self.installed: 4032797Sktlim@umich.edu del sys.modules[module] 4042797Sktlim@umich.edu self.installed = set() 4052868Sktlim@umich.edu 4062797Sktlim@umich.edu def find_module(self, fullname, path): 4072868Sktlim@umich.edu if fullname == 'm5.defines': 4082797Sktlim@umich.edu return self 4092797Sktlim@umich.edu 4102797Sktlim@umich.edu if fullname == 'm5.objects': 4112868Sktlim@umich.edu return self 4122797Sktlim@umich.edu 4132868Sktlim@umich.edu if fullname.startswith('m5.internal'): 4142797Sktlim@umich.edu return None 4152797Sktlim@umich.edu 4162667Sstever@eecs.umich.edu source = self.modules.get(fullname, None) 4172667Sstever@eecs.umich.edu if source is not None and fullname.startswith('m5.objects'): 4182667Sstever@eecs.umich.edu return self 4193132Sbinkertn@umich.edu 4203132Sbinkertn@umich.edu return None 4213132Sbinkertn@umich.edu 4223132Sbinkertn@umich.edu def load_module(self, fullname): 4233132Sbinkertn@umich.edu mod = imp.new_module(fullname) 4243132Sbinkertn@umich.edu sys.modules[fullname] = mod 4252667Sstever@eecs.umich.edu self.installed.add(fullname) 4262667Sstever@eecs.umich.edu 4272667Sstever@eecs.umich.edu mod.__loader__ = self 4282667Sstever@eecs.umich.edu if fullname == 'm5.objects': 4292667Sstever@eecs.umich.edu mod.__path__ = fullname.split('.') 4302667Sstever@eecs.umich.edu return mod 4312667Sstever@eecs.umich.edu 4323132Sbinkertn@umich.edu if fullname == 'm5.defines': 4332SN/A mod.__dict__['buildEnv'] = m5.util.SmartDict(build_env) 4342667Sstever@eecs.umich.edu return mod 4352797Sktlim@umich.edu 4362797Sktlim@umich.edu source = self.modules[fullname] 4372797Sktlim@umich.edu if source.modname == '__init__': 4382797Sktlim@umich.edu mod.__path__ = source.modpath 4392797Sktlim@umich.edu mod.__file__ = source.abspath 4402797Sktlim@umich.edu 4412797Sktlim@umich.edu exec file(source.abspath, 'r') in mod.__dict__ 4422797Sktlim@umich.edu 4432797Sktlim@umich.edu return mod 4442797Sktlim@umich.edu 4453202Shsul@eecs.umich.eduimport m5.SimObject 4463202Shsul@eecs.umich.eduimport m5.params 4473202Shsul@eecs.umich.edufrom m5.util import code_formatter 4483202Shsul@eecs.umich.edu 4493202Shsul@eecs.umich.edum5.SimObject.clear() 4503202Shsul@eecs.umich.edum5.params.clear() 4513202Shsul@eecs.umich.edu 4523202Shsul@eecs.umich.edu# install the python importer so we can grab stuff from the source 4533202Shsul@eecs.umich.edu# tree itself. We can't have SimObjects added after this point or 4543202Shsul@eecs.umich.edu# else we won't know about them for the rest of the stuff. 4553202Shsul@eecs.umich.eduimporter = DictImporter(PySource.modules) 4562667Sstever@eecs.umich.edusys.meta_path[0:0] = [ importer ] 4572667Sstever@eecs.umich.edu 4582667Sstever@eecs.umich.edu# import all sim objects so we can populate the all_objects list 4592667Sstever@eecs.umich.edu# make sure that we're working with a list, then let's sort it 4602667Sstever@eecs.umich.edufor modname in SimObject.modnames: 4612667Sstever@eecs.umich.edu exec('from m5.objects import %s' % modname) 4622667Sstever@eecs.umich.edu 4633132Sbinkertn@umich.edu# we need to unload all of the currently imported modules so that they 4643132Sbinkertn@umich.edu# will be re-imported the next time the sconscript is run 4652667Sstever@eecs.umich.eduimporter.unload() 4662667Sstever@eecs.umich.edusys.meta_path.remove(importer) 4672667Sstever@eecs.umich.edu 4682667Sstever@eecs.umich.edusim_objects = m5.SimObject.allClasses 4692667Sstever@eecs.umich.eduall_enums = m5.params.allEnums 4702667Sstever@eecs.umich.edu 4712667Sstever@eecs.umich.eduif m5.SimObject.noCxxHeader: 4722667Sstever@eecs.umich.edu print >> sys.stderr, \ 473 "warning: At least one SimObject lacks a header specification. " \ 474 "This can cause unexpected results in the generated SWIG " \ 475 "wrappers." 476 477# Find param types that need to be explicitly wrapped with swig. 478# These will be recognized because the ParamDesc will have a 479# swig_decl() method. Most param types are based on types that don't 480# need this, either because they're based on native types (like Int) 481# or because they're SimObjects (which get swigged independently). 482# For now the only things handled here are VectorParam types. 483params_to_swig = {} 484for name,obj in sorted(sim_objects.iteritems()): 485 for param in obj._params.local.values(): 486 # load the ptype attribute now because it depends on the 487 # current version of SimObject.allClasses, but when scons 488 # actually uses the value, all versions of 489 # SimObject.allClasses will have been loaded 490 param.ptype 491 492 if not hasattr(param, 'swig_decl'): 493 continue 494 pname = param.ptype_str 495 if pname not in params_to_swig: 496 params_to_swig[pname] = param 497 498######################################################################## 499# 500# calculate extra dependencies 501# 502module_depends = ["m5", "m5.SimObject", "m5.params"] 503depends = [ PySource.modules[dep].snode for dep in module_depends ] 504 505######################################################################## 506# 507# Commands for the basic automatically generated python files 508# 509 510# Generate Python file containing a dict specifying the current 511# buildEnv flags. 512def makeDefinesPyFile(target, source, env): 513 build_env = source[0].get_contents() 514 515 code = code_formatter() 516 code(""" 517import m5.internal 518import m5.util 519 520buildEnv = m5.util.SmartDict($build_env) 521 522compileDate = m5.internal.core.compileDate 523_globals = globals() 524for key,val in m5.internal.core.__dict__.iteritems(): 525 if key.startswith('flag_'): 526 flag = key[5:] 527 _globals[flag] = val 528del _globals 529""") 530 code.write(target[0].abspath) 531 532defines_info = Value(build_env) 533# Generate a file with all of the compile options in it 534env.Command('python/m5/defines.py', defines_info, 535 MakeAction(makeDefinesPyFile, Transform("DEFINES", 0))) 536PySource('m5', 'python/m5/defines.py') 537 538# Generate python file containing info about the M5 source code 539def makeInfoPyFile(target, source, env): 540 code = code_formatter() 541 for src in source: 542 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 543 code('$src = ${{repr(data)}}') 544 code.write(str(target[0])) 545 546# Generate a file that wraps the basic top level files 547env.Command('python/m5/info.py', 548 [ '#/COPYING', '#/LICENSE', '#/README', ], 549 MakeAction(makeInfoPyFile, Transform("INFO"))) 550PySource('m5', 'python/m5/info.py') 551 552######################################################################## 553# 554# Create all of the SimObject param headers and enum headers 555# 556 557def createSimObjectParamStruct(target, source, env): 558 assert len(target) == 1 and len(source) == 1 559 560 name = str(source[0].get_contents()) 561 obj = sim_objects[name] 562 563 code = code_formatter() 564 obj.cxx_param_decl(code) 565 code.write(target[0].abspath) 566 567def createParamSwigWrapper(target, source, env): 568 assert len(target) == 1 and len(source) == 1 569 570 name = str(source[0].get_contents()) 571 param = params_to_swig[name] 572 573 code = code_formatter() 574 param.swig_decl(code) 575 code.write(target[0].abspath) 576 577def createEnumStrings(target, source, env): 578 assert len(target) == 1 and len(source) == 1 579 580 name = str(source[0].get_contents()) 581 obj = all_enums[name] 582 583 code = code_formatter() 584 obj.cxx_def(code) 585 code.write(target[0].abspath) 586 587def createEnumDecls(target, source, env): 588 assert len(target) == 1 and len(source) == 1 589 590 name = str(source[0].get_contents()) 591 obj = all_enums[name] 592 593 code = code_formatter() 594 obj.cxx_decl(code) 595 code.write(target[0].abspath) 596 597def createEnumSwigWrapper(target, source, env): 598 assert len(target) == 1 and len(source) == 1 599 600 name = str(source[0].get_contents()) 601 obj = all_enums[name] 602 603 code = code_formatter() 604 obj.swig_decl(code) 605 code.write(target[0].abspath) 606 607def createSimObjectSwigWrapper(target, source, env): 608 name = source[0].get_contents() 609 obj = sim_objects[name] 610 611 code = code_formatter() 612 obj.swig_decl(code) 613 code.write(target[0].abspath) 614 615# Generate all of the SimObject param C++ struct header files 616params_hh_files = [] 617for name,simobj in sorted(sim_objects.iteritems()): 618 py_source = PySource.modules[simobj.__module__] 619 extra_deps = [ py_source.tnode ] 620 621 hh_file = File('params/%s.hh' % name) 622 params_hh_files.append(hh_file) 623 env.Command(hh_file, Value(name), 624 MakeAction(createSimObjectParamStruct, Transform("SO PARAM"))) 625 env.Depends(hh_file, depends + extra_deps) 626 627# Generate any needed param SWIG wrapper files 628params_i_files = [] 629for name,param in params_to_swig.iteritems(): 630 i_file = File('python/m5/internal/%s.i' % (param.swig_module_name())) 631 params_i_files.append(i_file) 632 env.Command(i_file, Value(name), 633 MakeAction(createParamSwigWrapper, Transform("SW PARAM"))) 634 env.Depends(i_file, depends) 635 SwigSource('m5.internal', i_file) 636 637# Generate all enum header files 638for name,enum in sorted(all_enums.iteritems()): 639 py_source = PySource.modules[enum.__module__] 640 extra_deps = [ py_source.tnode ] 641 642 cc_file = File('enums/%s.cc' % name) 643 env.Command(cc_file, Value(name), 644 MakeAction(createEnumStrings, Transform("ENUM STR"))) 645 env.Depends(cc_file, depends + extra_deps) 646 Source(cc_file) 647 648 hh_file = File('enums/%s.hh' % name) 649 env.Command(hh_file, Value(name), 650 MakeAction(createEnumDecls, Transform("ENUMDECL"))) 651 env.Depends(hh_file, depends + extra_deps) 652 653 i_file = File('python/m5/internal/enum_%s.i' % name) 654 env.Command(i_file, Value(name), 655 MakeAction(createEnumSwigWrapper, Transform("ENUMSWIG"))) 656 env.Depends(i_file, depends + extra_deps) 657 SwigSource('m5.internal', i_file) 658 659# Generate SimObject SWIG wrapper files 660for name,simobj in sim_objects.iteritems(): 661 py_source = PySource.modules[simobj.__module__] 662 extra_deps = [ py_source.tnode ] 663 664 i_file = File('python/m5/internal/param_%s.i' % name) 665 env.Command(i_file, Value(name), 666 MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG"))) 667 env.Depends(i_file, depends + extra_deps) 668 SwigSource('m5.internal', i_file) 669 670# Generate the main swig init file 671def makeEmbeddedSwigInit(target, source, env): 672 code = code_formatter() 673 module = source[0].get_contents() 674 code('''\ 675#include "sim/init.hh" 676 677extern "C" { 678 void init_${module}(); 679} 680 681EmbeddedSwig embed_swig_${module}(init_${module}); 682''') 683 code.write(str(target[0])) 684 685# Build all swig modules 686for swig in SwigSource.all: 687 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, 688 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 689 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG"))) 690 cc_file = str(swig.tnode) 691 init_file = '%s/%s_init.cc' % (dirname(cc_file), basename(cc_file)) 692 env.Command(init_file, Value(swig.module), 693 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW"))) 694 Source(init_file, **swig.guards) 695 696# Build all protocol buffers if we have got protoc and protobuf available 697if env['HAVE_PROTOBUF']: 698 for proto in ProtoBuf.all: 699 # Use both the source and header as the target, and the .proto 700 # file as the source. When executing the protoc compiler, also 701 # specify the proto_path to avoid having the generated files 702 # include the path. 703 env.Command([proto.cc_file, proto.hh_file], proto.tnode, 704 MakeAction('$PROTOC --cpp_out ${TARGET.dir} ' 705 '--proto_path ${SOURCE.dir} $SOURCE', 706 Transform("PROTOC"))) 707 708 # Add the C++ source file 709 Source(proto.cc_file, **proto.guards) 710elif ProtoBuf.all: 711 print 'Got protobuf to build, but lacks support!' 712 Exit(1) 713 714# 715# Handle debug flags 716# 717def makeDebugFlagCC(target, source, env): 718 assert(len(target) == 1 and len(source) == 1) 719 720 val = eval(source[0].get_contents()) 721 name, compound, desc = val 722 compound = list(sorted(compound)) 723 724 code = code_formatter() 725 726 # file header 727 code(''' 728/* 729 * DO NOT EDIT THIS FILE! Automatically generated 730 */ 731 732#include "base/debug.hh" 733''') 734 735 for flag in compound: 736 code('#include "debug/$flag.hh"') 737 code() 738 code('namespace Debug {') 739 code() 740 741 if not compound: 742 code('SimpleFlag $name("$name", "$desc");') 743 else: 744 code('CompoundFlag $name("$name", "$desc",') 745 code.indent() 746 last = len(compound) - 1 747 for i,flag in enumerate(compound): 748 if i != last: 749 code('$flag,') 750 else: 751 code('$flag);') 752 code.dedent() 753 754 code() 755 code('} // namespace Debug') 756 757 code.write(str(target[0])) 758 759def makeDebugFlagHH(target, source, env): 760 assert(len(target) == 1 and len(source) == 1) 761 762 val = eval(source[0].get_contents()) 763 name, compound, desc = val 764 765 code = code_formatter() 766 767 # file header boilerplate 768 code('''\ 769/* 770 * DO NOT EDIT THIS FILE! 771 * 772 * Automatically generated by SCons 773 */ 774 775#ifndef __DEBUG_${name}_HH__ 776#define __DEBUG_${name}_HH__ 777 778namespace Debug { 779''') 780 781 if compound: 782 code('class CompoundFlag;') 783 code('class SimpleFlag;') 784 785 if compound: 786 code('extern CompoundFlag $name;') 787 for flag in compound: 788 code('extern SimpleFlag $flag;') 789 else: 790 code('extern SimpleFlag $name;') 791 792 code(''' 793} 794 795#endif // __DEBUG_${name}_HH__ 796''') 797 798 code.write(str(target[0])) 799 800for name,flag in sorted(debug_flags.iteritems()): 801 n, compound, desc = flag 802 assert n == name 803 804 env.Command('debug/%s.hh' % name, Value(flag), 805 MakeAction(makeDebugFlagHH, Transform("TRACING", 0))) 806 env.Command('debug/%s.cc' % name, Value(flag), 807 MakeAction(makeDebugFlagCC, Transform("TRACING", 0))) 808 Source('debug/%s.cc' % name) 809 810# Embed python files. All .py files that have been indicated by a 811# PySource() call in a SConscript need to be embedded into the M5 812# library. To do that, we compile the file to byte code, marshal the 813# byte code, compress it, and then generate a c++ file that 814# inserts the result into an array. 815def embedPyFile(target, source, env): 816 def c_str(string): 817 if string is None: 818 return "0" 819 return '"%s"' % string 820 821 '''Action function to compile a .py into a code object, marshal 822 it, compress it, and stick it into an asm file so the code appears 823 as just bytes with a label in the data section''' 824 825 src = file(str(source[0]), 'r').read() 826 827 pysource = PySource.tnodes[source[0]] 828 compiled = compile(src, pysource.abspath, 'exec') 829 marshalled = marshal.dumps(compiled) 830 compressed = zlib.compress(marshalled) 831 data = compressed 832 sym = pysource.symname 833 834 code = code_formatter() 835 code('''\ 836#include "sim/init.hh" 837 838namespace { 839 840const uint8_t data_${sym}[] = { 841''') 842 code.indent() 843 step = 16 844 for i in xrange(0, len(data), step): 845 x = array.array('B', data[i:i+step]) 846 code(''.join('%d,' % d for d in x)) 847 code.dedent() 848 849 code('''}; 850 851EmbeddedPython embedded_${sym}( 852 ${{c_str(pysource.arcname)}}, 853 ${{c_str(pysource.abspath)}}, 854 ${{c_str(pysource.modpath)}}, 855 data_${sym}, 856 ${{len(data)}}, 857 ${{len(marshalled)}}); 858 859} // anonymous namespace 860''') 861 code.write(str(target[0])) 862 863for source in PySource.all: 864 env.Command(source.cpp, source.tnode, 865 MakeAction(embedPyFile, Transform("EMBED PY"))) 866 Source(source.cpp) 867 868######################################################################## 869# 870# Define binaries. Each different build type (debug, opt, etc.) gets 871# a slightly different build environment. 872# 873 874# List of constructed environments to pass back to SConstruct 875envList = [] 876 877date_source = Source('base/date.cc', skip_lib=True) 878 879# Function to create a new build environment as clone of current 880# environment 'env' with modified object suffix and optional stripped 881# binary. Additional keyword arguments are appended to corresponding 882# build environment vars. 883def makeEnv(label, objsfx, strip = False, **kwargs): 884 # SCons doesn't know to append a library suffix when there is a '.' in the 885 # name. Use '_' instead. 886 libname = 'gem5_' + label 887 exename = 'gem5.' + label 888 secondary_exename = 'm5.' + label 889 890 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 891 new_env.Label = label 892 new_env.Append(**kwargs) 893 894 swig_env = new_env.Clone() 895 896 # Both gcc and clang have issues with unused labels and values in 897 # the SWIG generated code 898 swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value']) 899 900 # Add additional warnings here that should not be applied to 901 # the SWIG generated code 902 new_env.Append(CXXFLAGS='-Wmissing-declarations') 903 904 if env['GCC']: 905 # Depending on the SWIG version, we also need to supress 906 # warnings about uninitialized variables and missing field 907 # initializers. 908 swig_env.Append(CCFLAGS=['-Wno-uninitialized', 909 '-Wno-missing-field-initializers']) 910 911 if compareVersions(env['GCC_VERSION'], '4.6') >= 0: 912 swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable') 913 914 # If gcc supports it, also warn for deletion of derived 915 # classes with non-virtual desctructors. For gcc >= 4.7 we 916 # also have to disable warnings about the SWIG code having 917 # potentially uninitialized variables. 918 if compareVersions(env['GCC_VERSION'], '4.7') >= 0: 919 new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor') 920 swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized') 921 if env['CLANG']: 922 # Always enable the warning for deletion of derived classes 923 # with non-virtual destructors 924 new_env.Append(CXXFLAGS=['-Wdelete-non-virtual-dtor']) 925 926 werror_env = new_env.Clone() 927 werror_env.Append(CCFLAGS='-Werror') 928 929 def make_obj(source, static, extra_deps = None): 930 '''This function adds the specified source to the correct 931 build environment, and returns the corresponding SCons Object 932 nodes''' 933 934 if source.swig: 935 env = swig_env 936 elif source.Werror: 937 env = werror_env 938 else: 939 env = new_env 940 941 if static: 942 obj = env.StaticObject(source.tnode) 943 else: 944 obj = env.SharedObject(source.tnode) 945 946 if extra_deps: 947 env.Depends(obj, extra_deps) 948 949 return obj 950 951 static_objs = \ 952 [ make_obj(s, True) for s in Source.get(main=False, skip_lib=False) ] 953 shared_objs = \ 954 [ make_obj(s, False) for s in Source.get(main=False, skip_lib=False) ] 955 956 static_date = make_obj(date_source, static=True, extra_deps=static_objs) 957 static_objs.append(static_date) 958 959 shared_date = make_obj(date_source, static=False, extra_deps=shared_objs) 960 shared_objs.append(shared_date) 961 962 # First make a library of everything but main() so other programs can 963 # link against m5. 964 static_lib = new_env.StaticLibrary(libname, static_objs) 965 shared_lib = new_env.SharedLibrary(libname, shared_objs) 966 967 # Now link a stub with main() and the static library. 968 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 969 970 for test in UnitTest.all: 971 flags = { test.target : True } 972 test_sources = Source.get(**flags) 973 test_objs = [ make_obj(s, static=True) for s in test_sources ] 974 if test.main: 975 test_objs += main_objs 976 testname = "unittest/%s.%s" % (test.target, label) 977 new_env.Program(testname, test_objs + static_objs) 978 979 progname = exename 980 if strip: 981 progname += '.unstripped' 982 983 targets = new_env.Program(progname, main_objs + static_objs) 984 985 if strip: 986 if sys.platform == 'sunos5': 987 cmd = 'cp $SOURCE $TARGET; strip $TARGET' 988 else: 989 cmd = 'strip $SOURCE -o $TARGET' 990 targets = new_env.Command(exename, progname, 991 MakeAction(cmd, Transform("STRIP"))) 992 993 new_env.Command(secondary_exename, exename, 994 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 995 996 new_env.M5Binary = targets[0] 997 envList.append(new_env) 998 999# Start out with the compiler flags common to all compilers, 1000# i.e. they all use -g for opt and -g -pg for prof 1001ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 1002 'perf' : ['-g']} 1003 1004# Start out with the linker flags common to all linkers, i.e. -pg for 1005# prof, and -lprofiler for perf. The -lprofile flag is surrounded by 1006# no-as-needed and as-needed as the binutils linker is too clever and 1007# simply doesn't link to the library otherwise. 1008ldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg'], 1009 'perf' : ['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']} 1010 1011# For Link Time Optimization, the optimisation flags used to compile 1012# individual files are decoupled from those used at link time 1013# (i.e. you can compile with -O3 and perform LTO with -O0), so we need 1014# to also update the linker flags based on the target. 1015if env['GCC']: 1016 if sys.platform == 'sunos5': 1017 ccflags['debug'] += ['-gstabs+'] 1018 else: 1019 ccflags['debug'] += ['-ggdb3'] 1020 ldflags['debug'] += ['-O0'] 1021 # opt, fast, prof and perf all share the same cc flags, also add 1022 # the optimization to the ldflags as LTO defers the optimization 1023 # to link time 1024 for target in ['opt', 'fast', 'prof', 'perf']: 1025 ccflags[target] += ['-O3'] 1026 ldflags[target] += ['-O3'] 1027 1028 ccflags['fast'] += env['LTO_CCFLAGS'] 1029 ldflags['fast'] += env['LTO_LDFLAGS'] 1030elif env['CLANG']: 1031 ccflags['debug'] += ['-g', '-O0'] 1032 # opt, fast, prof and perf all share the same cc flags 1033 for target in ['opt', 'fast', 'prof', 'perf']: 1034 ccflags[target] += ['-O3'] 1035else: 1036 print 'Unknown compiler, please fix compiler options' 1037 Exit(1) 1038 1039 1040# To speed things up, we only instantiate the build environments we 1041# need. We try to identify the needed environment for each target; if 1042# we can't, we fall back on instantiating all the environments just to 1043# be safe. 1044target_types = ['debug', 'opt', 'fast', 'prof', 'perf'] 1045obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof', 1046 'gpo' : 'perf'} 1047 1048def identifyTarget(t): 1049 ext = t.split('.')[-1] 1050 if ext in target_types: 1051 return ext 1052 if obj2target.has_key(ext): 1053 return obj2target[ext] 1054 match = re.search(r'/tests/([^/]+)/', t) 1055 if match and match.group(1) in target_types: 1056 return match.group(1) 1057 return 'all' 1058 1059needed_envs = [identifyTarget(target) for target in BUILD_TARGETS] 1060if 'all' in needed_envs: 1061 needed_envs += target_types 1062 1063# Debug binary 1064if 'debug' in needed_envs: 1065 makeEnv('debug', '.do', 1066 CCFLAGS = Split(ccflags['debug']), 1067 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 1068 LINKFLAGS = Split(ldflags['debug'])) 1069 1070# Optimized binary 1071if 'opt' in needed_envs: 1072 makeEnv('opt', '.o', 1073 CCFLAGS = Split(ccflags['opt']), 1074 CPPDEFINES = ['TRACING_ON=1'], 1075 LINKFLAGS = Split(ldflags['opt'])) 1076 1077# "Fast" binary 1078if 'fast' in needed_envs: 1079 makeEnv('fast', '.fo', strip = True, 1080 CCFLAGS = Split(ccflags['fast']), 1081 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1082 LINKFLAGS = Split(ldflags['fast'])) 1083 1084# Profiled binary using gprof 1085if 'prof' in needed_envs: 1086 makeEnv('prof', '.po', 1087 CCFLAGS = Split(ccflags['prof']), 1088 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1089 LINKFLAGS = Split(ldflags['prof'])) 1090 1091# Profiled binary using google-pprof 1092if 'perf' in needed_envs: 1093 makeEnv('perf', '.gpo', 1094 CCFLAGS = Split(ccflags['perf']), 1095 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1096 LINKFLAGS = Split(ldflags['perf'])) 1097 1098Return('envList') 1099