SConstruct revision 8881
1955SN/A# -*- mode:python -*- 2955SN/A 39812Sandreas.hansson@arm.com# Copyright (c) 2011 Advanced Micro Devices, Inc. 49812Sandreas.hansson@arm.com# Copyright (c) 2009 The Hewlett-Packard Development Company 59812Sandreas.hansson@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 69812Sandreas.hansson@arm.com# All rights reserved. 79812Sandreas.hansson@arm.com# 89812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 99812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 109812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 129812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 139812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 149812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 157816Ssteve.reinhardt@amd.com# neither the name of the copyright holders nor the names of its 165871Snate@binkert.org# contributors may be used to endorse or promote products derived from 171762SN/A# this software without specific prior written permission. 18955SN/A# 19955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30955SN/A# 31955SN/A# Authors: Steve Reinhardt 32955SN/A# Nathan Binkert 33955SN/A 34955SN/A################################################### 35955SN/A# 36955SN/A# SCons top-level build description (SConstruct) file. 37955SN/A# 38955SN/A# While in this directory ('gem5'), just type 'scons' to build the default 39955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 40955SN/A# to build some other configuration (e.g., 'build/ALPHA/gem5.opt' for 41955SN/A# the optimized full-system version). 422665Ssaidi@eecs.umich.edu# 432665Ssaidi@eecs.umich.edu# You can build gem5 in a different directory as long as there is a 445863Snate@binkert.org# 'build/<CONFIG>' somewhere along the target path. The build system 45955SN/A# expects that all configs under the same build directory are being 46955SN/A# built for the same host system. 47955SN/A# 48955SN/A# Examples: 49955SN/A# 508878Ssteve.reinhardt@amd.com# The following two commands are equivalent. The '-u' option tells 512632Sstever@eecs.umich.edu# scons to search up the directory tree for this SConstruct file. 528878Ssteve.reinhardt@amd.com# % cd <path-to-src>/gem5 ; scons build/ALPHA/gem5.debug 532632Sstever@eecs.umich.edu# % cd <path-to-src>/gem5/build/ALPHA; scons -u gem5.debug 54955SN/A# 558878Ssteve.reinhardt@amd.com# The following two commands are equivalent and demonstrate building 562632Sstever@eecs.umich.edu# in a directory outside of the source tree. The '-C' option tells 572761Sstever@eecs.umich.edu# scons to chdir to the specified directory to find this SConstruct 582632Sstever@eecs.umich.edu# file. 592632Sstever@eecs.umich.edu# % cd <path-to-src>/gem5 ; scons /local/foo/build/ALPHA/gem5.debug 602632Sstever@eecs.umich.edu# % cd /local/foo/build/ALPHA; scons -C <path-to-src>/gem5 gem5.debug 612761Sstever@eecs.umich.edu# 622761Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options. If you're in this 632761Sstever@eecs.umich.edu# 'gem5' directory (or use -u or -C to tell scons where to find this 648878Ssteve.reinhardt@amd.com# file), you can use 'scons -h' to print all the gem5-specific build 658878Ssteve.reinhardt@amd.com# options as well. 662761Sstever@eecs.umich.edu# 672761Sstever@eecs.umich.edu################################################### 682761Sstever@eecs.umich.edu 692761Sstever@eecs.umich.edu# Check for recent-enough Python and SCons versions. 702761Sstever@eecs.umich.edutry: 718878Ssteve.reinhardt@amd.com # Really old versions of scons only take two options for the 728878Ssteve.reinhardt@amd.com # function, so check once without the revision and once with the 732632Sstever@eecs.umich.edu # revision, the first instance will fail for stuff other than 742632Sstever@eecs.umich.edu # 0.98, and the second will fail for 0.98.0 758878Ssteve.reinhardt@amd.com EnsureSConsVersion(0, 98) 768878Ssteve.reinhardt@amd.com EnsureSConsVersion(0, 98, 1) 772632Sstever@eecs.umich.eduexcept SystemExit, e: 78955SN/A print """ 79955SN/AFor more details, see: 80955SN/A http://gem5.org/Dependencies 815863Snate@binkert.org""" 825863Snate@binkert.org raise 835863Snate@binkert.org 845863Snate@binkert.org# We ensure the python version early because we have stuff that 855863Snate@binkert.org# requires python 2.4 865863Snate@binkert.orgtry: 875863Snate@binkert.org EnsurePythonVersion(2, 4) 885863Snate@binkert.orgexcept SystemExit, e: 895863Snate@binkert.org print """ 905863Snate@binkert.orgYou can use a non-default installation of the Python interpreter by 915863Snate@binkert.orgeither (1) rearranging your PATH so that scons finds the non-default 928878Ssteve.reinhardt@amd.com'python' first or (2) explicitly invoking an alternative interpreter 935863Snate@binkert.orgon the scons script. 945863Snate@binkert.org 955863Snate@binkert.orgFor more details, see: 969812Sandreas.hansson@arm.com http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation 979812Sandreas.hansson@arm.com""" 985863Snate@binkert.org raise 999812Sandreas.hansson@arm.com 1005863Snate@binkert.org# Global Python includes 1015863Snate@binkert.orgimport os 1025863Snate@binkert.orgimport re 1039812Sandreas.hansson@arm.comimport subprocess 1049812Sandreas.hansson@arm.comimport sys 1055863Snate@binkert.org 1065863Snate@binkert.orgfrom os import mkdir, environ 1078878Ssteve.reinhardt@amd.comfrom os.path import abspath, basename, dirname, expanduser, normpath 1085863Snate@binkert.orgfrom os.path import exists, isdir, isfile 1095863Snate@binkert.orgfrom os.path import join as joinpath, split as splitpath 1105863Snate@binkert.org 1116654Snate@binkert.org# SCons includes 112955SN/Aimport SCons 1135396Ssaidi@eecs.umich.eduimport SCons.Node 1145863Snate@binkert.org 1155863Snate@binkert.orgextra_python_paths = [ 1164202Sbinkertn@umich.edu Dir('src/python').srcnode().abspath, # gem5 includes 1175863Snate@binkert.org Dir('ext/ply').srcnode().abspath, # ply is used by several files 1185863Snate@binkert.org ] 1195863Snate@binkert.org 1205863Snate@binkert.orgsys.path[1:1] = extra_python_paths 121955SN/A 1226654Snate@binkert.orgfrom m5.util import compareVersions, readCommand 1235273Sstever@gmail.com 1245871Snate@binkert.orghelp_texts = { 1255273Sstever@gmail.com "options" : "", 1266655Snate@binkert.org "global_vars" : "", 1278878Ssteve.reinhardt@amd.com "local_vars" : "" 1286655Snate@binkert.org} 1296655Snate@binkert.org 1309219Spower.jg@gmail.comExport("help_texts") 1316655Snate@binkert.org 1325871Snate@binkert.org 1336654Snate@binkert.org# There's a bug in scons in that (1) by default, the help texts from 1348947Sandreas.hansson@arm.com# AddOption() are supposed to be displayed when you type 'scons -h' 1355396Ssaidi@eecs.umich.edu# and (2) you can override the help displayed by 'scons -h' using the 1368120Sgblack@eecs.umich.edu# Help() function, but these two features are incompatible: once 1378120Sgblack@eecs.umich.edu# you've overridden the help text using Help(), there's no way to get 1388120Sgblack@eecs.umich.edu# at the help texts from AddOptions. See: 1398120Sgblack@eecs.umich.edu# http://scons.tigris.org/issues/show_bug.cgi?id=2356 1408120Sgblack@eecs.umich.edu# http://scons.tigris.org/issues/show_bug.cgi?id=2611 1418120Sgblack@eecs.umich.edu# This hack lets us extract the help text from AddOptions and 1428120Sgblack@eecs.umich.edu# re-inject it via Help(). Ideally someday this bug will be fixed and 1438120Sgblack@eecs.umich.edu# we can just use AddOption directly. 1448879Ssteve.reinhardt@amd.comdef AddLocalOption(*args, **kwargs): 1458879Ssteve.reinhardt@amd.com col_width = 30 1468879Ssteve.reinhardt@amd.com 1478879Ssteve.reinhardt@amd.com help = " " + ", ".join(args) 1488879Ssteve.reinhardt@amd.com if "help" in kwargs: 1498879Ssteve.reinhardt@amd.com length = len(help) 1508879Ssteve.reinhardt@amd.com if length >= col_width: 1518879Ssteve.reinhardt@amd.com help += "\n" + " " * col_width 1528879Ssteve.reinhardt@amd.com else: 1538879Ssteve.reinhardt@amd.com help += " " * (col_width - length) 1548879Ssteve.reinhardt@amd.com help += kwargs["help"] 1558879Ssteve.reinhardt@amd.com help_texts["options"] += help + "\n" 1568879Ssteve.reinhardt@amd.com 1578120Sgblack@eecs.umich.edu AddOption(*args, **kwargs) 1588120Sgblack@eecs.umich.edu 1598120Sgblack@eecs.umich.eduAddLocalOption('--colors', dest='use_colors', action='store_true', 1608120Sgblack@eecs.umich.edu help="Add color to abbreviated scons output") 1618120Sgblack@eecs.umich.eduAddLocalOption('--no-colors', dest='use_colors', action='store_false', 1628120Sgblack@eecs.umich.edu help="Don't add color to abbreviated scons output") 1638120Sgblack@eecs.umich.eduAddLocalOption('--default', dest='default', type='string', action='store', 1648120Sgblack@eecs.umich.edu help='Override which build_opts file to use for defaults') 1658120Sgblack@eecs.umich.eduAddLocalOption('--ignore-style', dest='ignore_style', action='store_true', 1668120Sgblack@eecs.umich.edu help='Disable style checking hooks') 1678120Sgblack@eecs.umich.eduAddLocalOption('--update-ref', dest='update_ref', action='store_true', 1688120Sgblack@eecs.umich.edu help='Update test reference outputs') 1698120Sgblack@eecs.umich.eduAddLocalOption('--verbose', dest='verbose', action='store_true', 1708120Sgblack@eecs.umich.edu help='Print full tool command lines') 1718879Ssteve.reinhardt@amd.com 1728879Ssteve.reinhardt@amd.comuse_colors = GetOption('use_colors') 1738879Ssteve.reinhardt@amd.comif use_colors: 1748879Ssteve.reinhardt@amd.com from m5.util.terminal import termcap 1758879Ssteve.reinhardt@amd.comelif use_colors is None: 1768879Ssteve.reinhardt@amd.com # option unspecified; default behavior is to use colors iff isatty 1778879Ssteve.reinhardt@amd.com from m5.util.terminal import tty_termcap as termcap 1788879Ssteve.reinhardt@amd.comelse: 1799227Sandreas.hansson@arm.com from m5.util.terminal import no_termcap as termcap 1809227Sandreas.hansson@arm.com 1818879Ssteve.reinhardt@amd.com######################################################################## 1828879Ssteve.reinhardt@amd.com# 1838879Ssteve.reinhardt@amd.com# Set up the main build environment. 1848879Ssteve.reinhardt@amd.com# 1858120Sgblack@eecs.umich.edu######################################################################## 1868947Sandreas.hansson@arm.comuse_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH', 1877816Ssteve.reinhardt@amd.com 'PYTHONPATH', 'RANLIB' ]) 1885871Snate@binkert.org 1895871Snate@binkert.orguse_env = {} 1906121Snate@binkert.orgfor key,val in os.environ.iteritems(): 1915871Snate@binkert.org if key in use_vars or key.startswith("M5"): 1925871Snate@binkert.org use_env[key] = val 1939119Sandreas.hansson@arm.com 1949396Sandreas.hansson@arm.commain = Environment(ENV=use_env) 1959396Sandreas.hansson@arm.commain.Decider('MD5-timestamp') 196955SN/Amain.SetOption('implicit_cache', 1) 1979416SAndreas.Sandberg@ARM.commain.root = Dir(".") # The current directory (where this file lives). 1989416SAndreas.Sandberg@ARM.commain.srcdir = Dir("src") # The source directory 1999416SAndreas.Sandberg@ARM.com 2009416SAndreas.Sandberg@ARM.com# add useful python code PYTHONPATH so it can be used by subprocesses 2019416SAndreas.Sandberg@ARM.com# as well 2029416SAndreas.Sandberg@ARM.commain.AppendENVPath('PYTHONPATH', extra_python_paths) 2039416SAndreas.Sandberg@ARM.com 2045871Snate@binkert.org######################################################################## 2055871Snate@binkert.org# 2069416SAndreas.Sandberg@ARM.com# Mercurial Stuff. 2079416SAndreas.Sandberg@ARM.com# 2085871Snate@binkert.org# If the gem5 directory is a mercurial repository, we should do some 209955SN/A# extra things. 2106121Snate@binkert.org# 2118881Smarc.orr@gmail.com######################################################################## 2126121Snate@binkert.org 2136121Snate@binkert.orghgdir = main.root.Dir(".hg") 2141533SN/A 2159239Sandreas.hansson@arm.commercurial_style_message = """ 2169239Sandreas.hansson@arm.comYou're missing the gem5 style hook, which automatically checks your code 2179239Sandreas.hansson@arm.comagainst the gem5 style rules on hg commit and qrefresh commands. This 2189239Sandreas.hansson@arm.comscript will now install the hook in your .hg/hgrc file. 2199239Sandreas.hansson@arm.comPress enter to continue, or ctrl-c to abort: """ 2209239Sandreas.hansson@arm.com 2219239Sandreas.hansson@arm.commercurial_style_hook = """ 2229239Sandreas.hansson@arm.com# The following lines were automatically added by gem5/SConstruct 2239239Sandreas.hansson@arm.com# to provide the gem5 style-checking hooks 2249239Sandreas.hansson@arm.com[extensions] 2259239Sandreas.hansson@arm.comstyle = %s/util/style.py 2269239Sandreas.hansson@arm.com 2276655Snate@binkert.org[hooks] 2286655Snate@binkert.orgpretxncommit.style = python:style.check_style 2296655Snate@binkert.orgpre-qrefresh.style = python:style.check_style 2306655Snate@binkert.org# End of SConstruct additions 2315871Snate@binkert.org 2325871Snate@binkert.org""" % (main.root.abspath) 2335863Snate@binkert.org 2345871Snate@binkert.orgmercurial_lib_not_found = """ 2358878Ssteve.reinhardt@amd.comMercurial libraries cannot be found, ignoring style hook. If 2365871Snate@binkert.orgyou are a gem5 developer, please fix this and run the style 2375871Snate@binkert.orghook. It is important. 2385871Snate@binkert.org""" 2395863Snate@binkert.org 2406121Snate@binkert.org# Check for style hook and prompt for installation if it's not there. 2415863Snate@binkert.org# Skip this if --ignore-style was specified, there's no .hg dir to 2425871Snate@binkert.org# install a hook in, or there's no interactive terminal to prompt. 2438336Ssteve.reinhardt@amd.comif not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty(): 2448336Ssteve.reinhardt@amd.com style_hook = True 2458336Ssteve.reinhardt@amd.com try: 2468336Ssteve.reinhardt@amd.com from mercurial import ui 2474678Snate@binkert.org ui = ui.ui() 2488336Ssteve.reinhardt@amd.com ui.readconfig(hgdir.File('hgrc').abspath) 2498336Ssteve.reinhardt@amd.com style_hook = ui.config('hooks', 'pretxncommit.style', None) and \ 2508336Ssteve.reinhardt@amd.com ui.config('hooks', 'pre-qrefresh.style', None) 2514678Snate@binkert.org except ImportError: 2524678Snate@binkert.org print mercurial_lib_not_found 2534678Snate@binkert.org 2544678Snate@binkert.org if not style_hook: 2557827Snate@binkert.org print mercurial_style_message, 2567827Snate@binkert.org # continue unless user does ctrl-c/ctrl-d etc. 2578336Ssteve.reinhardt@amd.com try: 2584678Snate@binkert.org raw_input() 2598336Ssteve.reinhardt@amd.com except: 2608336Ssteve.reinhardt@amd.com print "Input exception, exiting scons.\n" 2618336Ssteve.reinhardt@amd.com sys.exit(1) 2628336Ssteve.reinhardt@amd.com hgrc_path = '%s/.hg/hgrc' % main.root.abspath 2638336Ssteve.reinhardt@amd.com print "Adding style hook to", hgrc_path, "\n" 2648336Ssteve.reinhardt@amd.com try: 2655871Snate@binkert.org hgrc = open(hgrc_path, 'a') 2665871Snate@binkert.org hgrc.write(mercurial_style_hook) 2678336Ssteve.reinhardt@amd.com hgrc.close() 2688336Ssteve.reinhardt@amd.com except: 2698336Ssteve.reinhardt@amd.com print "Error updating", hgrc_path 2708336Ssteve.reinhardt@amd.com sys.exit(1) 2718336Ssteve.reinhardt@amd.com 2725871Snate@binkert.org 2738336Ssteve.reinhardt@amd.com################################################### 2748336Ssteve.reinhardt@amd.com# 2758336Ssteve.reinhardt@amd.com# Figure out which configurations to set up based on the path(s) of 2768336Ssteve.reinhardt@amd.com# the target(s). 2778336Ssteve.reinhardt@amd.com# 2784678Snate@binkert.org################################################### 2795871Snate@binkert.org 2804678Snate@binkert.org# Find default configuration & binary. 2818336Ssteve.reinhardt@amd.comDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA/gem5.debug')) 2828336Ssteve.reinhardt@amd.com 2838336Ssteve.reinhardt@amd.com# helper function: find last occurrence of element in list 2848336Ssteve.reinhardt@amd.comdef rfind(l, elt, offs = -1): 2858336Ssteve.reinhardt@amd.com for i in range(len(l)+offs, 0, -1): 2868336Ssteve.reinhardt@amd.com if l[i] == elt: 2878336Ssteve.reinhardt@amd.com return i 2888336Ssteve.reinhardt@amd.com raise ValueError, "element not found" 2898336Ssteve.reinhardt@amd.com 2908336Ssteve.reinhardt@amd.com# Take a list of paths (or SCons Nodes) and return a list with all 2918336Ssteve.reinhardt@amd.com# paths made absolute and ~-expanded. Paths will be interpreted 2928336Ssteve.reinhardt@amd.com# relative to the launch directory unless a different root is provided 2938336Ssteve.reinhardt@amd.comdef makePathListAbsolute(path_list, root=GetLaunchDir()): 2948336Ssteve.reinhardt@amd.com return [abspath(joinpath(root, expanduser(str(p)))) 2958336Ssteve.reinhardt@amd.com for p in path_list] 2968336Ssteve.reinhardt@amd.com 2978336Ssteve.reinhardt@amd.com# Each target must have 'build' in the interior of the path; the 2985871Snate@binkert.org# directory below this will determine the build parameters. For 2996121Snate@binkert.org# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 300955SN/A# recognize that ALPHA_SE specifies the configuration because it 301955SN/A# follow 'build' in the build path. 3022632Sstever@eecs.umich.edu 3032632Sstever@eecs.umich.edu# The funky assignment to "[:]" is needed to replace the list contents 304955SN/A# in place rather than reassign the symbol to a new list, which 305955SN/A# doesn't work (obviously!). 306955SN/ABUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) 307955SN/A 3088878Ssteve.reinhardt@amd.com# Generate a list of the unique build roots and configs that the 309955SN/A# collected targets reference. 3102632Sstever@eecs.umich.eduvariant_paths = [] 3112632Sstever@eecs.umich.edubuild_root = None 3122632Sstever@eecs.umich.edufor t in BUILD_TARGETS: 3132632Sstever@eecs.umich.edu path_dirs = t.split('/') 3142632Sstever@eecs.umich.edu try: 3152632Sstever@eecs.umich.edu build_top = rfind(path_dirs, 'build', -2) 3162632Sstever@eecs.umich.edu except: 3178268Ssteve.reinhardt@amd.com print "Error: no non-leaf 'build' dir found on target path", t 3188268Ssteve.reinhardt@amd.com Exit(1) 3198268Ssteve.reinhardt@amd.com this_build_root = joinpath('/',*path_dirs[:build_top+1]) 3208268Ssteve.reinhardt@amd.com if not build_root: 3218268Ssteve.reinhardt@amd.com build_root = this_build_root 3228268Ssteve.reinhardt@amd.com else: 3238268Ssteve.reinhardt@amd.com if this_build_root != build_root: 3242632Sstever@eecs.umich.edu print "Error: build targets not under same build root\n"\ 3252632Sstever@eecs.umich.edu " %s\n %s" % (build_root, this_build_root) 3262632Sstever@eecs.umich.edu Exit(1) 3272632Sstever@eecs.umich.edu variant_path = joinpath('/',*path_dirs[:build_top+2]) 3288268Ssteve.reinhardt@amd.com if variant_path not in variant_paths: 3292632Sstever@eecs.umich.edu variant_paths.append(variant_path) 3308268Ssteve.reinhardt@amd.com 3318268Ssteve.reinhardt@amd.com# Make sure build_root exists (might not if this is the first build there) 3328268Ssteve.reinhardt@amd.comif not isdir(build_root): 3338268Ssteve.reinhardt@amd.com mkdir(build_root) 3343718Sstever@eecs.umich.edumain['BUILDROOT'] = build_root 3352634Sstever@eecs.umich.edu 3362634Sstever@eecs.umich.eduExport('main') 3375863Snate@binkert.org 3382638Sstever@eecs.umich.edumain.SConsignFile(joinpath(build_root, "sconsign")) 3398268Ssteve.reinhardt@amd.com 3402632Sstever@eecs.umich.edu# Default duplicate option is to use hard links, but this messes up 3412632Sstever@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves 3422632Sstever@eecs.umich.edu# file to file~ then copies to file, breaking the link. Symbolic 3432632Sstever@eecs.umich.edu# (soft) links work better. 3442632Sstever@eecs.umich.edumain.SetOption('duplicate', 'soft-copy') 3451858SN/A 3463716Sstever@eecs.umich.edu# 3472638Sstever@eecs.umich.edu# Set up global sticky variables... these are common to an entire build 3482638Sstever@eecs.umich.edu# tree (not specific to a particular build like ALPHA_SE) 3492638Sstever@eecs.umich.edu# 3502638Sstever@eecs.umich.edu 3512638Sstever@eecs.umich.eduglobal_vars_file = joinpath(build_root, 'variables.global') 3522638Sstever@eecs.umich.edu 3532638Sstever@eecs.umich.eduglobal_vars = Variables(global_vars_file, args=ARGUMENTS) 3545863Snate@binkert.org 3555863Snate@binkert.orgglobal_vars.AddVariables( 3565863Snate@binkert.org ('CC', 'C compiler', environ.get('CC', main['CC'])), 357955SN/A ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), 3585341Sstever@gmail.com ('BATCH', 'Use batch pool for build and tests', False), 3595341Sstever@gmail.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 3605863Snate@binkert.org ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), 3617756SAli.Saidi@ARM.com ('EXTRAS', 'Add extra directories to the compilation', '') 3625341Sstever@gmail.com ) 3636121Snate@binkert.org 3644494Ssaidi@eecs.umich.edu# Update main environment with values from ARGUMENTS & global_vars_file 3656121Snate@binkert.orgglobal_vars.Update(main) 3661105SN/Ahelp_texts["global_vars"] += global_vars.GenerateHelpText(main) 3672667Sstever@eecs.umich.edu 3682667Sstever@eecs.umich.edu# Save sticky variable settings back to current variables file 3692667Sstever@eecs.umich.eduglobal_vars.Save(global_vars_file, main) 3702667Sstever@eecs.umich.edu 3716121Snate@binkert.org# Parse EXTRAS variable to build list of all directories where we're 3722667Sstever@eecs.umich.edu# look for sources etc. This list is exported as extras_dir_list. 3735341Sstever@gmail.combase_dir = main.srcdir.abspath 3745863Snate@binkert.orgif main['EXTRAS']: 3755341Sstever@gmail.com extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':')) 3765341Sstever@gmail.comelse: 3775341Sstever@gmail.com extras_dir_list = [] 3788120Sgblack@eecs.umich.edu 3795341Sstever@gmail.comExport('base_dir') 3808120Sgblack@eecs.umich.eduExport('extras_dir_list') 3815341Sstever@gmail.com 3828120Sgblack@eecs.umich.edu# the ext directory should be on the #includes path 3836121Snate@binkert.orgmain.Append(CPPPATH=[Dir('ext')]) 3846121Snate@binkert.org 3858980Ssteve.reinhardt@amd.comdef strip_build_path(path, env): 3869396Sandreas.hansson@arm.com path = str(path) 3875397Ssaidi@eecs.umich.edu variant_base = env['BUILDROOT'] + os.path.sep 3885397Ssaidi@eecs.umich.edu if path.startswith(variant_base): 3897727SAli.Saidi@ARM.com path = path[len(variant_base):] 3908268Ssteve.reinhardt@amd.com elif path.startswith('build/'): 3916168Snate@binkert.org path = path[6:] 3925341Sstever@gmail.com return path 3938120Sgblack@eecs.umich.edu 3948120Sgblack@eecs.umich.edu# Generate a string of the form: 3958120Sgblack@eecs.umich.edu# common/path/prefix/src1, src2 -> tgt1, tgt2 3966814Sgblack@eecs.umich.edu# to print while building. 3975863Snate@binkert.orgclass Transform(object): 3988120Sgblack@eecs.umich.edu # all specific color settings should be here and nowhere else 3995341Sstever@gmail.com tool_color = termcap.Normal 4005863Snate@binkert.org pfx_color = termcap.Yellow 4018268Ssteve.reinhardt@amd.com srcs_color = termcap.Yellow + termcap.Bold 4026121Snate@binkert.org arrow_color = termcap.Blue + termcap.Bold 4036121Snate@binkert.org tgts_color = termcap.Yellow + termcap.Bold 4048268Ssteve.reinhardt@amd.com 4055742Snate@binkert.org def __init__(self, tool, max_sources=99): 4065742Snate@binkert.org self.format = self.tool_color + (" [%8s] " % tool) \ 4075341Sstever@gmail.com + self.pfx_color + "%s" \ 4085742Snate@binkert.org + self.srcs_color + "%s" \ 4095742Snate@binkert.org + self.arrow_color + " -> " \ 4105341Sstever@gmail.com + self.tgts_color + "%s" \ 4116017Snate@binkert.org + termcap.Normal 4126121Snate@binkert.org self.max_sources = max_sources 4136017Snate@binkert.org 4147816Ssteve.reinhardt@amd.com def __call__(self, target, source, env, for_signature=None): 4157756SAli.Saidi@ARM.com # truncate source list according to max_sources param 4167756SAli.Saidi@ARM.com source = source[0:self.max_sources] 4177756SAli.Saidi@ARM.com def strip(f): 4187756SAli.Saidi@ARM.com return strip_build_path(str(f), env) 4197756SAli.Saidi@ARM.com if len(source) > 0: 4207756SAli.Saidi@ARM.com srcs = map(strip, source) 4217756SAli.Saidi@ARM.com else: 4227756SAli.Saidi@ARM.com srcs = [''] 4237816Ssteve.reinhardt@amd.com tgts = map(strip, target) 4247816Ssteve.reinhardt@amd.com # surprisingly, os.path.commonprefix is a dumb char-by-char string 4257816Ssteve.reinhardt@amd.com # operation that has nothing to do with paths. 4267816Ssteve.reinhardt@amd.com com_pfx = os.path.commonprefix(srcs + tgts) 4277816Ssteve.reinhardt@amd.com com_pfx_len = len(com_pfx) 4287816Ssteve.reinhardt@amd.com if com_pfx: 4297816Ssteve.reinhardt@amd.com # do some cleanup and sanity checking on common prefix 4307816Ssteve.reinhardt@amd.com if com_pfx[-1] == ".": 4317816Ssteve.reinhardt@amd.com # prefix matches all but file extension: ok 4327816Ssteve.reinhardt@amd.com # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 4337756SAli.Saidi@ARM.com com_pfx = com_pfx[0:-1] 4347816Ssteve.reinhardt@amd.com elif com_pfx[-1] == "/": 4357816Ssteve.reinhardt@amd.com # common prefix is directory path: OK 4367816Ssteve.reinhardt@amd.com pass 4377816Ssteve.reinhardt@amd.com else: 4387816Ssteve.reinhardt@amd.com src0_len = len(srcs[0]) 4397816Ssteve.reinhardt@amd.com tgt0_len = len(tgts[0]) 4407816Ssteve.reinhardt@amd.com if src0_len == com_pfx_len: 4417816Ssteve.reinhardt@amd.com # source is a substring of target, OK 4427816Ssteve.reinhardt@amd.com pass 4437816Ssteve.reinhardt@amd.com elif tgt0_len == com_pfx_len: 4447816Ssteve.reinhardt@amd.com # target is a substring of source, need to back up to 4457816Ssteve.reinhardt@amd.com # avoid empty string on RHS of arrow 4467816Ssteve.reinhardt@amd.com sep_idx = com_pfx.rfind(".") 4477816Ssteve.reinhardt@amd.com if sep_idx != -1: 4487816Ssteve.reinhardt@amd.com com_pfx = com_pfx[0:sep_idx] 4497816Ssteve.reinhardt@amd.com else: 4507816Ssteve.reinhardt@amd.com com_pfx = '' 4517816Ssteve.reinhardt@amd.com elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 4527816Ssteve.reinhardt@amd.com # still splitting at file extension: ok 4537816Ssteve.reinhardt@amd.com pass 4547816Ssteve.reinhardt@amd.com else: 4557816Ssteve.reinhardt@amd.com # probably a fluke; ignore it 4567816Ssteve.reinhardt@amd.com com_pfx = '' 4577816Ssteve.reinhardt@amd.com # recalculate length in case com_pfx was modified 4587816Ssteve.reinhardt@amd.com com_pfx_len = len(com_pfx) 4597816Ssteve.reinhardt@amd.com def fmt(files): 4607816Ssteve.reinhardt@amd.com f = map(lambda s: s[com_pfx_len:], files) 4617816Ssteve.reinhardt@amd.com return ', '.join(f) 4627816Ssteve.reinhardt@amd.com return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 4637816Ssteve.reinhardt@amd.com 4647816Ssteve.reinhardt@amd.comExport('Transform') 4657816Ssteve.reinhardt@amd.com 4667816Ssteve.reinhardt@amd.com 4677816Ssteve.reinhardt@amd.comif GetOption('verbose'): 4687816Ssteve.reinhardt@amd.com def MakeAction(action, string, *args, **kwargs): 4697816Ssteve.reinhardt@amd.com return Action(action, *args, **kwargs) 4707816Ssteve.reinhardt@amd.comelse: 4717816Ssteve.reinhardt@amd.com MakeAction = Action 4727816Ssteve.reinhardt@amd.com main['CCCOMSTR'] = Transform("CC") 4737816Ssteve.reinhardt@amd.com main['CXXCOMSTR'] = Transform("CXX") 4747816Ssteve.reinhardt@amd.com main['ASCOMSTR'] = Transform("AS") 4757816Ssteve.reinhardt@amd.com main['SWIGCOMSTR'] = Transform("SWIG") 4767816Ssteve.reinhardt@amd.com main['ARCOMSTR'] = Transform("AR", 0) 4777816Ssteve.reinhardt@amd.com main['LINKCOMSTR'] = Transform("LINK", 0) 4787816Ssteve.reinhardt@amd.com main['RANLIBCOMSTR'] = Transform("RANLIB", 0) 4797816Ssteve.reinhardt@amd.com main['M4COMSTR'] = Transform("M4") 4807816Ssteve.reinhardt@amd.com main['SHCCCOMSTR'] = Transform("SHCC") 4817816Ssteve.reinhardt@amd.com main['SHCXXCOMSTR'] = Transform("SHCXX") 4827816Ssteve.reinhardt@amd.comExport('MakeAction') 4837816Ssteve.reinhardt@amd.com 4847816Ssteve.reinhardt@amd.comCXX_version = readCommand([main['CXX'],'--version'], exception=False) 4857816Ssteve.reinhardt@amd.comCXX_V = readCommand([main['CXX'],'-V'], exception=False) 4867816Ssteve.reinhardt@amd.com 4877816Ssteve.reinhardt@amd.commain['GCC'] = CXX_version and CXX_version.find('g++') >= 0 4887816Ssteve.reinhardt@amd.commain['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0 4897816Ssteve.reinhardt@amd.commain['ICC'] = CXX_V and CXX_V.find('Intel') >= 0 4907816Ssteve.reinhardt@amd.commain['CLANG'] = CXX_V and CXX_V.find('clang') >= 0 4917816Ssteve.reinhardt@amd.comif main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1: 4927816Ssteve.reinhardt@amd.com print 'Error: How can we have two at the same time?' 4937816Ssteve.reinhardt@amd.com Exit(1) 4947816Ssteve.reinhardt@amd.com 4958947Sandreas.hansson@arm.com# Set up default C++ compiler flags 4968947Sandreas.hansson@arm.comif main['GCC']: 4977756SAli.Saidi@ARM.com main.Append(CCFLAGS=['-pipe']) 4988120Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-fno-strict-aliasing']) 4997756SAli.Saidi@ARM.com main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 5007756SAli.Saidi@ARM.com main.Append(CXXFLAGS=['-Wno-deprecated']) 5017756SAli.Saidi@ARM.com # Read the GCC version to check for versions with bugs 5027756SAli.Saidi@ARM.com # Note CCVERSION doesn't work here because it is run with the CC 5037816Ssteve.reinhardt@amd.com # before we override it from the command line 5047816Ssteve.reinhardt@amd.com gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) 5057816Ssteve.reinhardt@amd.com main['GCC_VERSION'] = gcc_version 5067816Ssteve.reinhardt@amd.com if not compareVersions(gcc_version, '4.4.1') or \ 5077816Ssteve.reinhardt@amd.com not compareVersions(gcc_version, '4.4.2'): 5087816Ssteve.reinhardt@amd.com print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' 5097816Ssteve.reinhardt@amd.com main.Append(CCFLAGS=['-fno-tree-vectorize']) 5107816Ssteve.reinhardt@amd.comelif main['ICC']: 5117816Ssteve.reinhardt@amd.com pass #Fix me... add warning flags once we clean up icc warnings 5127816Ssteve.reinhardt@amd.comelif main['SUNCC']: 5137756SAli.Saidi@ARM.com main.Append(CCFLAGS=['-Qoption ccfe']) 5147756SAli.Saidi@ARM.com main.Append(CCFLAGS=['-features=gcc']) 5159227Sandreas.hansson@arm.com main.Append(CCFLAGS=['-features=extensions']) 5169227Sandreas.hansson@arm.com main.Append(CCFLAGS=['-library=stlport4']) 5179227Sandreas.hansson@arm.com main.Append(CCFLAGS=['-xar']) 5189227Sandreas.hansson@arm.com #main.Append(CCFLAGS=['-instances=semiexplicit']) 5199590Sandreas@sandberg.pp.seelif main['CLANG']: 5209590Sandreas@sandberg.pp.se clang_version_re = re.compile(".* version (\d+\.\d+)") 5219590Sandreas@sandberg.pp.se clang_version_match = clang_version_re.match(CXX_version) 5229590Sandreas@sandberg.pp.se if (clang_version_match): 5239590Sandreas@sandberg.pp.se clang_version = clang_version_match.groups()[0] 5249590Sandreas@sandberg.pp.se if compareVersions(clang_version, "2.9") < 0: 5256654Snate@binkert.org print 'Error: clang version 2.9 or newer required.' 5266654Snate@binkert.org print ' Installed version:', clang_version 5275871Snate@binkert.org Exit(1) 5286121Snate@binkert.org else: 5298946Sandreas.hansson@arm.com print 'Error: Unable to determine clang version.' 5309419Sandreas.hansson@arm.com Exit(1) 5313940Ssaidi@eecs.umich.edu 5323918Ssaidi@eecs.umich.edu main.Append(CCFLAGS=['-pipe']) 5333918Ssaidi@eecs.umich.edu main.Append(CCFLAGS=['-fno-strict-aliasing']) 5341858SN/A main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 5359556Sandreas.hansson@arm.com main.Append(CCFLAGS=['-Wno-tautological-compare']) 5369556Sandreas.hansson@arm.com main.Append(CCFLAGS=['-Wno-self-assign']) 5379556Sandreas.hansson@arm.comelse: 5389556Sandreas.hansson@arm.com print 'Error: Don\'t know what compiler options to use for your compiler.' 5399556Sandreas.hansson@arm.com print ' Please fix SConstruct and src/SConscript and try again.' 5409556Sandreas.hansson@arm.com Exit(1) 5419556Sandreas.hansson@arm.com 5429556Sandreas.hansson@arm.com# Set up common yacc/bison flags (needed for Ruby) 5439556Sandreas.hansson@arm.commain['YACCFLAGS'] = '-d' 5449556Sandreas.hansson@arm.commain['YACCHXXFILESUFFIX'] = '.hh' 5459556Sandreas.hansson@arm.com 5469556Sandreas.hansson@arm.com# Do this after we save setting back, or else we'll tack on an 5479556Sandreas.hansson@arm.com# extra 'qdo' every time we run scons. 5489556Sandreas.hansson@arm.comif main['BATCH']: 5499556Sandreas.hansson@arm.com main['CC'] = main['BATCH_CMD'] + ' ' + main['CC'] 5509556Sandreas.hansson@arm.com main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX'] 5519556Sandreas.hansson@arm.com main['AS'] = main['BATCH_CMD'] + ' ' + main['AS'] 5529556Sandreas.hansson@arm.com main['AR'] = main['BATCH_CMD'] + ' ' + main['AR'] 5539556Sandreas.hansson@arm.com main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB'] 5549556Sandreas.hansson@arm.com 5559556Sandreas.hansson@arm.comif sys.platform == 'cygwin': 5569556Sandreas.hansson@arm.com # cygwin has some header file issues... 5579556Sandreas.hansson@arm.com main.Append(CCFLAGS=["-Wno-uninitialized"]) 5589556Sandreas.hansson@arm.com 5599556Sandreas.hansson@arm.com# Check for SWIG 5609556Sandreas.hansson@arm.comif not main.has_key('SWIG'): 5619556Sandreas.hansson@arm.com print 'Error: SWIG utility not found.' 5629556Sandreas.hansson@arm.com print ' Please install (see http://www.swig.org) and retry.' 5639556Sandreas.hansson@arm.com Exit(1) 5649556Sandreas.hansson@arm.com 5659556Sandreas.hansson@arm.com# Check for appropriate SWIG version 5669556Sandreas.hansson@arm.comswig_version = readCommand(('swig', '-version'), exception='').split() 5676121Snate@binkert.org# First 3 words should be "SWIG Version x.y.z" 5689420Sandreas.hansson@arm.comif len(swig_version) < 3 or \ 5699420Sandreas.hansson@arm.com swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 5709420Sandreas.hansson@arm.com print 'Error determining SWIG version.' 5719420Sandreas.hansson@arm.com Exit(1) 5729420Sandreas.hansson@arm.com 5739420Sandreas.hansson@arm.commin_swig_version = '1.3.28' 5749420Sandreas.hansson@arm.comif compareVersions(swig_version[2], min_swig_version) < 0: 5759420Sandreas.hansson@arm.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 5769420Sandreas.hansson@arm.com print ' Installed version:', swig_version[2] 5779420Sandreas.hansson@arm.com Exit(1) 5789420Sandreas.hansson@arm.com 5797618SAli.Saidi@arm.com# Set up SWIG flags & scanner 5807618SAli.Saidi@arm.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 5817618SAli.Saidi@arm.commain.Append(SWIGFLAGS=swig_flags) 5827739Sgblack@eecs.umich.edu 5839227Sandreas.hansson@arm.com# filter out all existing swig scanners, they mess up the dependency 5849227Sandreas.hansson@arm.com# stuff for some reason 5859227Sandreas.hansson@arm.comscanners = [] 5869227Sandreas.hansson@arm.comfor scanner in main['SCANNERS']: 5879227Sandreas.hansson@arm.com skeys = scanner.skeys 5889227Sandreas.hansson@arm.com if skeys == '.i': 5899227Sandreas.hansson@arm.com continue 5909227Sandreas.hansson@arm.com 5919227Sandreas.hansson@arm.com if isinstance(skeys, (list, tuple)) and '.i' in skeys: 5929227Sandreas.hansson@arm.com continue 5939227Sandreas.hansson@arm.com 5949227Sandreas.hansson@arm.com scanners.append(scanner) 5959227Sandreas.hansson@arm.com 5969227Sandreas.hansson@arm.com# add the new swig scanner that we like better 5979227Sandreas.hansson@arm.comfrom SCons.Scanner import ClassicCPP as CPPScanner 5989227Sandreas.hansson@arm.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 5999227Sandreas.hansson@arm.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 6009227Sandreas.hansson@arm.com 6019590Sandreas@sandberg.pp.se# replace the scanners list that has what we want 6029590Sandreas@sandberg.pp.semain['SCANNERS'] = scanners 6039590Sandreas@sandberg.pp.se 6048737Skoansin.tan@gmail.com# Add a custom Check function to the Configure context so that we can 6059420Sandreas.hansson@arm.com# figure out if the compiler adds leading underscores to global 6069420Sandreas.hansson@arm.com# variables. This is needed for the autogenerated asm files that we 6079420Sandreas.hansson@arm.com# use for embedding the python code. 6088737Skoansin.tan@gmail.comdef CheckLeading(context): 6098737Skoansin.tan@gmail.com context.Message("Checking for leading underscore in global variables...") 6108737Skoansin.tan@gmail.com # 1) Define a global variable called x from asm so the C compiler 6118737Skoansin.tan@gmail.com # won't change the symbol at all. 6128737Skoansin.tan@gmail.com # 2) Declare that variable. 6138737Skoansin.tan@gmail.com # 3) Use the variable 6148737Skoansin.tan@gmail.com # 6158737Skoansin.tan@gmail.com # If the compiler prepends an underscore, this will successfully 6168737Skoansin.tan@gmail.com # link because the external symbol 'x' will be called '_x' which 6178737Skoansin.tan@gmail.com # was defined by the asm statement. If the compiler does not 6188737Skoansin.tan@gmail.com # prepend an underscore, this will not successfully link because 6198737Skoansin.tan@gmail.com # '_x' will have been defined by assembly, while the C portion of 6209556Sandreas.hansson@arm.com # the code will be trying to use 'x' 6219556Sandreas.hansson@arm.com ret = context.TryLink(''' 6229556Sandreas.hansson@arm.com asm(".globl _x; _x: .byte 0"); 6239556Sandreas.hansson@arm.com extern int x; 6249556Sandreas.hansson@arm.com int main() { return x; } 6259556Sandreas.hansson@arm.com ''', extension=".c") 6269556Sandreas.hansson@arm.com context.env.Append(LEADING_UNDERSCORE=ret) 6279556Sandreas.hansson@arm.com context.Result(ret) 6289556Sandreas.hansson@arm.com return ret 6299556Sandreas.hansson@arm.com 6309590Sandreas@sandberg.pp.se# Platform-specific configuration. Note again that we assume that all 6319590Sandreas@sandberg.pp.se# builds under a given build root run on the same host platform. 6329420Sandreas.hansson@arm.comconf = Configure(main, 6339846Sandreas.hansson@arm.com conf_dir = joinpath(build_root, '.scons_config'), 6349846Sandreas.hansson@arm.com log_file = joinpath(build_root, 'scons_config.log'), 6359846Sandreas.hansson@arm.com custom_tests = { 'CheckLeading' : CheckLeading }) 6369846Sandreas.hansson@arm.com 6378946Sandreas.hansson@arm.com# Check for leading underscores. Don't really need to worry either 6383918Ssaidi@eecs.umich.edu# way so don't need to check the return code. 6399068SAli.Saidi@ARM.comconf.CheckLeading() 6409068SAli.Saidi@ARM.com 6419068SAli.Saidi@ARM.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin 6429068SAli.Saidi@ARM.comtry: 6439068SAli.Saidi@ARM.com import platform 6449068SAli.Saidi@ARM.com uname = platform.uname() 6459068SAli.Saidi@ARM.com if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 6469068SAli.Saidi@ARM.com if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 6479068SAli.Saidi@ARM.com main.Append(CCFLAGS=['-arch', 'x86_64']) 6489419Sandreas.hansson@arm.com main.Append(CFLAGS=['-arch', 'x86_64']) 6499068SAli.Saidi@ARM.com main.Append(LINKFLAGS=['-arch', 'x86_64']) 6509068SAli.Saidi@ARM.com main.Append(ASFLAGS=['-arch', 'x86_64']) 6519068SAli.Saidi@ARM.comexcept: 6529068SAli.Saidi@ARM.com pass 6539068SAli.Saidi@ARM.com 6549068SAli.Saidi@ARM.com# Recent versions of scons substitute a "Null" object for Configure() 6553918Ssaidi@eecs.umich.edu# when configuration isn't necessary, e.g., if the "--help" option is 6563918Ssaidi@eecs.umich.edu# present. Unfortuantely this Null object always returns false, 6576157Snate@binkert.org# breaking all our configuration checks. We replace it with our own 6586157Snate@binkert.org# more optimistic null object that returns True instead. 6596157Snate@binkert.orgif not conf: 6606157Snate@binkert.org def NullCheck(*args, **kwargs): 6615397Ssaidi@eecs.umich.edu return True 6625397Ssaidi@eecs.umich.edu 6636121Snate@binkert.org class NullConf: 6646121Snate@binkert.org def __init__(self, env): 6656121Snate@binkert.org self.env = env 6666121Snate@binkert.org def Finish(self): 6676121Snate@binkert.org return self.env 6686121Snate@binkert.org def __getattr__(self, mname): 6695397Ssaidi@eecs.umich.edu return NullCheck 6701851SN/A 6711851SN/A conf = NullConf(main) 6727739Sgblack@eecs.umich.edu 673955SN/A# Find Python include and library directories for embedding the 6749396Sandreas.hansson@arm.com# interpreter. For consistency, we will use the same Python 6759396Sandreas.hansson@arm.com# installation used to run scons (and thus this script). If you want 6769396Sandreas.hansson@arm.com# to link in an alternate version, see above for instructions on how 6779396Sandreas.hansson@arm.com# to invoke scons with a different copy of the Python interpreter. 6789396Sandreas.hansson@arm.comfrom distutils import sysconfig 6799396Sandreas.hansson@arm.com 6809396Sandreas.hansson@arm.compy_getvar = sysconfig.get_config_var 6819396Sandreas.hansson@arm.com 6829396Sandreas.hansson@arm.compy_debug = getattr(sys, 'pydebug', False) 6839396Sandreas.hansson@arm.compy_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "") 6849396Sandreas.hansson@arm.com 6859396Sandreas.hansson@arm.compy_general_include = sysconfig.get_python_inc() 6869396Sandreas.hansson@arm.compy_platform_include = sysconfig.get_python_inc(plat_specific=True) 6879396Sandreas.hansson@arm.compy_includes = [ py_general_include ] 6889396Sandreas.hansson@arm.comif py_platform_include != py_general_include: 6899396Sandreas.hansson@arm.com py_includes.append(py_platform_include) 6909477Sandreas.hansson@arm.com 6919477Sandreas.hansson@arm.compy_lib_path = [ py_getvar('LIBDIR') ] 6929477Sandreas.hansson@arm.com# add the prefix/lib/pythonX.Y/config dir, but only if there is no 6939477Sandreas.hansson@arm.com# shared library in prefix/lib/. 6949477Sandreas.hansson@arm.comif not py_getvar('Py_ENABLE_SHARED'): 6959477Sandreas.hansson@arm.com py_lib_path.append(py_getvar('LIBPL')) 6969477Sandreas.hansson@arm.com 6979477Sandreas.hansson@arm.compy_libs = [] 6989477Sandreas.hansson@arm.comfor lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): 6999477Sandreas.hansson@arm.com if not lib.startswith('-l'): 7009477Sandreas.hansson@arm.com # Python requires some special flags to link (e.g. -framework 7019477Sandreas.hansson@arm.com # common on OS X systems), assume appending preserves order 7029477Sandreas.hansson@arm.com main.Append(LINKFLAGS=[lib]) 7039477Sandreas.hansson@arm.com else: 7049477Sandreas.hansson@arm.com lib = lib[2:] 7059477Sandreas.hansson@arm.com if lib not in py_libs: 7069477Sandreas.hansson@arm.com py_libs.append(lib) 7079477Sandreas.hansson@arm.compy_libs.append(py_version) 7089477Sandreas.hansson@arm.com 7099477Sandreas.hansson@arm.commain.Append(CPPPATH=py_includes) 7109477Sandreas.hansson@arm.commain.Append(LIBPATH=py_lib_path) 7119477Sandreas.hansson@arm.com 7129396Sandreas.hansson@arm.com# Cache build files in the supplied directory. 7133053Sstever@eecs.umich.eduif main['M5_BUILD_CACHE']: 7146121Snate@binkert.org print 'Using build cache located at', main['M5_BUILD_CACHE'] 7153053Sstever@eecs.umich.edu CacheDir(main['M5_BUILD_CACHE']) 7163053Sstever@eecs.umich.edu 7173053Sstever@eecs.umich.edu 7183053Sstever@eecs.umich.edu# verify that this stuff works 7193053Sstever@eecs.umich.eduif not conf.CheckHeader('Python.h', '<>'): 7209072Sandreas.hansson@arm.com print "Error: can't find Python.h header in", py_includes 7213053Sstever@eecs.umich.edu Exit(1) 7224742Sstever@eecs.umich.edu 7234742Sstever@eecs.umich.edufor lib in py_libs: 7243053Sstever@eecs.umich.edu if not conf.CheckLib(lib): 7253053Sstever@eecs.umich.edu print "Error: can't find library %s required by python" % lib 7263053Sstever@eecs.umich.edu Exit(1) 7278960Ssteve.reinhardt@amd.com 7286654Snate@binkert.org# On Solaris you need to use libsocket for socket ops 7293053Sstever@eecs.umich.eduif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7303053Sstever@eecs.umich.edu if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7313053Sstever@eecs.umich.edu print "Can't find library with socket calls (e.g. accept())" 7323053Sstever@eecs.umich.edu Exit(1) 7339877Sandreas.hansson@arm.com 7349877Sandreas.hansson@arm.com# Check for zlib. If the check passes, libz will be automatically 7359877Sandreas.hansson@arm.com# added to the LIBS environment variable. 7369877Sandreas.hansson@arm.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 7379877Sandreas.hansson@arm.com print 'Error: did not find needed zlib compression library '\ 7389585Sandreas@sandberg.pp.se 'and/or zlib.h header file.' 7399877Sandreas.hansson@arm.com print ' Please install zlib and try again.' 7409585Sandreas@sandberg.pp.se Exit(1) 7419877Sandreas.hansson@arm.com 7429877Sandreas.hansson@arm.com# Check for librt. 7439585Sandreas@sandberg.pp.sehave_posix_clock = \ 7442667Sstever@eecs.umich.edu conf.CheckLibWithHeader(None, 'time.h', 'C', 7454554Sbinkertn@umich.edu 'clock_nanosleep(0,0,NULL,NULL);') or \ 7466121Snate@binkert.org conf.CheckLibWithHeader('rt', 'time.h', 'C', 7472667Sstever@eecs.umich.edu 'clock_nanosleep(0,0,NULL,NULL);') 7484554Sbinkertn@umich.edu 7494554Sbinkertn@umich.eduif not have_posix_clock: 7504554Sbinkertn@umich.edu print "Can't find library for POSIX clocks." 7516121Snate@binkert.org 7524554Sbinkertn@umich.edu# Check for <fenv.h> (C99 FP environment control) 7534554Sbinkertn@umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>') 7544554Sbinkertn@umich.eduif not have_fenv: 7554781Snate@binkert.org print "Warning: Header file <fenv.h> not found." 7564554Sbinkertn@umich.edu print " This host has no IEEE FP rounding mode control." 7574554Sbinkertn@umich.edu 7582667Sstever@eecs.umich.edu###################################################################### 7594554Sbinkertn@umich.edu# 7604554Sbinkertn@umich.edu# Finish the configuration 7614554Sbinkertn@umich.edu# 7624554Sbinkertn@umich.edumain = conf.Finish() 7632667Sstever@eecs.umich.edu 7644554Sbinkertn@umich.edu###################################################################### 7652667Sstever@eecs.umich.edu# 7664554Sbinkertn@umich.edu# Collect all non-global variables 7676121Snate@binkert.org# 7682667Sstever@eecs.umich.edu 7695522Snate@binkert.org# Define the universe of supported ISAs 7705522Snate@binkert.orgall_isa_list = [ ] 7715522Snate@binkert.orgExport('all_isa_list') 7725522Snate@binkert.org 7735522Snate@binkert.orgclass CpuModel(object): 7745522Snate@binkert.org '''The CpuModel class encapsulates everything the ISA parser needs to 7755522Snate@binkert.org know about a particular CPU model.''' 7765522Snate@binkert.org 7775522Snate@binkert.org # Dict of available CPU model objects. Accessible as CpuModel.dict. 7785522Snate@binkert.org dict = {} 7795522Snate@binkert.org list = [] 7805522Snate@binkert.org defaults = [] 7815522Snate@binkert.org 7825522Snate@binkert.org # Constructor. Automatically adds models to CpuModel.dict. 7835522Snate@binkert.org def __init__(self, name, filename, includes, strings, default=False): 7845522Snate@binkert.org self.name = name # name of model 7855522Snate@binkert.org self.filename = filename # filename for output exec code 7865522Snate@binkert.org self.includes = includes # include files needed in exec file 7875522Snate@binkert.org # The 'strings' dict holds all the per-CPU symbols we can 7885522Snate@binkert.org # substitute into templates etc. 7895522Snate@binkert.org self.strings = strings 7905522Snate@binkert.org 7915522Snate@binkert.org # This cpu is enabled by default 7925522Snate@binkert.org self.default = default 7935522Snate@binkert.org 7945522Snate@binkert.org # Add self to dict 7952638Sstever@eecs.umich.edu if name in CpuModel.dict: 7962638Sstever@eecs.umich.edu raise AttributeError, "CpuModel '%s' already registered" % name 7976121Snate@binkert.org CpuModel.dict[name] = self 7983716Sstever@eecs.umich.edu CpuModel.list.append(name) 7995522Snate@binkert.org 8009420Sandreas.hansson@arm.comExport('CpuModel') 8015522Snate@binkert.org 8025522Snate@binkert.org# Sticky variables get saved in the variables file so they persist from 8035522Snate@binkert.org# one invocation to the next (unless overridden, in which case the new 8045522Snate@binkert.org# value becomes sticky). 8051858SN/Asticky_vars = Variables(args=ARGUMENTS) 8065227Ssaidi@eecs.umich.eduExport('sticky_vars') 8075227Ssaidi@eecs.umich.edu 8085227Ssaidi@eecs.umich.edu# Sticky variables that should be exported 8095227Ssaidi@eecs.umich.eduexport_vars = [] 8106654Snate@binkert.orgExport('export_vars') 8116654Snate@binkert.org 8127769SAli.Saidi@ARM.com# Walk the tree and execute all SConsopts scripts that wil add to the 8137769SAli.Saidi@ARM.com# above variables 8147769SAli.Saidi@ARM.comif not GetOption('verbose'): 8157769SAli.Saidi@ARM.com print "Reading SConsopts" 8165227Ssaidi@eecs.umich.edufor bdir in [ base_dir ] + extras_dir_list: 8175227Ssaidi@eecs.umich.edu if not isdir(bdir): 8185227Ssaidi@eecs.umich.edu print "Error: directory '%s' does not exist" % bdir 8195204Sstever@gmail.com Exit(1) 8205204Sstever@gmail.com for root, dirs, files in os.walk(bdir): 8215204Sstever@gmail.com if 'SConsopts' in files: 8225204Sstever@gmail.com if GetOption('verbose'): 8235204Sstever@gmail.com print "Reading", joinpath(root, 'SConsopts') 8245204Sstever@gmail.com SConscript(joinpath(root, 'SConsopts')) 8255204Sstever@gmail.com 8265204Sstever@gmail.comall_isa_list.sort() 8275204Sstever@gmail.com 8285204Sstever@gmail.comsticky_vars.AddVariables( 8295204Sstever@gmail.com EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 8305204Sstever@gmail.com ListVariable('CPU_MODELS', 'CPU models', 8315204Sstever@gmail.com sorted(n for n,m in CpuModel.dict.iteritems() if m.default), 8325204Sstever@gmail.com sorted(CpuModel.list)), 8335204Sstever@gmail.com BoolVariable('NO_FAST_ALLOC', 'Disable fast object allocator', False), 8345204Sstever@gmail.com BoolVariable('FORCE_FAST_ALLOC', 8355204Sstever@gmail.com 'Enable fast object allocator, even for gem5.debug', False), 8366121Snate@binkert.org BoolVariable('FAST_ALLOC_STATS', 'Enable fast object allocator statistics', 8375204Sstever@gmail.com False), 8387727SAli.Saidi@ARM.com BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', 8397727SAli.Saidi@ARM.com False), 8407727SAli.Saidi@ARM.com BoolVariable('SS_COMPATIBLE_FP', 8417727SAli.Saidi@ARM.com 'Make floating-point results compatible with SimpleScalar', 8427727SAli.Saidi@ARM.com False), 8439812Sandreas.hansson@arm.com BoolVariable('USE_SSE2', 8449812Sandreas.hansson@arm.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 8459812Sandreas.hansson@arm.com False), 8469812Sandreas.hansson@arm.com BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock), 8479812Sandreas.hansson@arm.com BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 8489812Sandreas.hansson@arm.com BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False), 8499812Sandreas.hansson@arm.com BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False), 8509812Sandreas.hansson@arm.com ) 8519812Sandreas.hansson@arm.com 8529812Sandreas.hansson@arm.com# These variables get exported to #defines in config/*.hh (see src/SConscript). 8539812Sandreas.hansson@arm.comexport_vars += ['USE_FENV', 'NO_FAST_ALLOC', 'FORCE_FAST_ALLOC', 8549812Sandreas.hansson@arm.com 'FAST_ALLOC_STATS', 'SS_COMPATIBLE_FP', 'USE_CHECKER', 8559812Sandreas.hansson@arm.com 'TARGET_ISA', 'CP_ANNOTATE', 'USE_POSIX_CLOCK' ] 8569812Sandreas.hansson@arm.com 8579812Sandreas.hansson@arm.com################################################### 8589812Sandreas.hansson@arm.com# 8599812Sandreas.hansson@arm.com# Define a SCons builder for configuration flag headers. 8609812Sandreas.hansson@arm.com# 8619812Sandreas.hansson@arm.com################################################### 8629812Sandreas.hansson@arm.com 8639812Sandreas.hansson@arm.com# This function generates a config header file that #defines the 8649812Sandreas.hansson@arm.com# variable symbol to the current variable setting (0 or 1). The source 8659812Sandreas.hansson@arm.com# operands are the name of the variable and a Value node containing the 8669812Sandreas.hansson@arm.com# value of the variable. 8677727SAli.Saidi@ARM.comdef build_config_file(target, source, env): 8685863Snate@binkert.org (variable, value) = [s.get_contents() for s in source] 8693118Sstever@eecs.umich.edu f = file(str(target[0]), 'w') 8705863Snate@binkert.org print >> f, '#define', variable, value 8719239Sandreas.hansson@arm.com f.close() 8723118Sstever@eecs.umich.edu return None 8733118Sstever@eecs.umich.edu 8745863Snate@binkert.org# Combine the two functions into a scons Action object. 8755863Snate@binkert.orgconfig_action = MakeAction(build_config_file, Transform("CONFIG H", 2)) 8765863Snate@binkert.org 8775863Snate@binkert.org# The emitter munges the source & target node lists to reflect what 8783118Sstever@eecs.umich.edu# we're really doing. 8793483Ssaidi@eecs.umich.edudef config_emitter(target, source, env): 8803494Ssaidi@eecs.umich.edu # extract variable name from Builder arg 8813494Ssaidi@eecs.umich.edu variable = str(target[0]) 8823483Ssaidi@eecs.umich.edu # True target is config header file 8833483Ssaidi@eecs.umich.edu target = joinpath('config', variable.lower() + '.hh') 8843483Ssaidi@eecs.umich.edu val = env[variable] 8853053Sstever@eecs.umich.edu if isinstance(val, bool): 8863053Sstever@eecs.umich.edu # Force value to 0/1 8873918Ssaidi@eecs.umich.edu val = int(val) 8883053Sstever@eecs.umich.edu elif isinstance(val, str): 8893053Sstever@eecs.umich.edu val = '"' + val + '"' 8903053Sstever@eecs.umich.edu 8913053Sstever@eecs.umich.edu # Sources are variable name & value (packaged in SCons Value nodes) 8923053Sstever@eecs.umich.edu return ([target], [Value(variable), Value(val)]) 8939396Sandreas.hansson@arm.com 8949396Sandreas.hansson@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 8959396Sandreas.hansson@arm.com 8969396Sandreas.hansson@arm.commain.Append(BUILDERS = { 'ConfigFile' : config_builder }) 8979396Sandreas.hansson@arm.com 8989396Sandreas.hansson@arm.com# libelf build is shared across all configs in the build root. 8999396Sandreas.hansson@arm.commain.SConscript('ext/libelf/SConscript', 9009396Sandreas.hansson@arm.com variant_dir = joinpath(build_root, 'libelf')) 9019396Sandreas.hansson@arm.com 9029477Sandreas.hansson@arm.com# gzstream build is shared across all configs in the build root. 9039396Sandreas.hansson@arm.commain.SConscript('ext/gzstream/SConscript', 9049477Sandreas.hansson@arm.com variant_dir = joinpath(build_root, 'gzstream')) 9059477Sandreas.hansson@arm.com 9069477Sandreas.hansson@arm.com################################################### 9079477Sandreas.hansson@arm.com# 9089396Sandreas.hansson@arm.com# This function is used to set up a directory with switching headers 9097840Snate@binkert.org# 9107865Sgblack@eecs.umich.edu################################################### 9117865Sgblack@eecs.umich.edu 9127865Sgblack@eecs.umich.edumain['ALL_ISA_LIST'] = all_isa_list 9137865Sgblack@eecs.umich.edudef make_switching_dir(dname, switch_headers, env): 9147865Sgblack@eecs.umich.edu # Generate the header. target[0] is the full path of the output 9157840Snate@binkert.org # header to generate. 'source' is a dummy variable, since we get the 9169591Sandreas@sandberg.pp.se # list of ISAs from env['ALL_ISA_LIST']. 9179591Sandreas@sandberg.pp.se def gen_switch_hdr(target, source, env): 9189591Sandreas@sandberg.pp.se fname = str(target[0]) 9199590Sandreas@sandberg.pp.se f = open(fname, 'w') 9209590Sandreas@sandberg.pp.se isa = env['TARGET_ISA'].lower() 9219045SAli.Saidi@ARM.com print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) 9229045SAli.Saidi@ARM.com f.close() 9239071Sandreas.hansson@arm.com 9249071Sandreas.hansson@arm.com # Build SCons Action object. 'varlist' specifies env vars that this 9259045SAli.Saidi@ARM.com # action depends on; when env['ALL_ISA_LIST'] changes these actions 9267840Snate@binkert.org # should get re-executed. 9277840Snate@binkert.org switch_hdr_action = MakeAction(gen_switch_hdr, 9287840Snate@binkert.org Transform("GENERATE"), varlist=['ALL_ISA_LIST']) 9291858SN/A 9301858SN/A # Instantiate actions for each header 9311858SN/A for hdr in switch_headers: 9321858SN/A env.Command(hdr, [], switch_hdr_action) 9331858SN/AExport('make_switching_dir') 9341858SN/A 9359651SAndreas.Sandberg@ARM.com################################################### 9369651SAndreas.Sandberg@ARM.com# 9379651SAndreas.Sandberg@ARM.com# Define build environments for selected configurations. 9389651SAndreas.Sandberg@ARM.com# 9399651SAndreas.Sandberg@ARM.com################################################### 9409651SAndreas.Sandberg@ARM.com 9419651SAndreas.Sandberg@ARM.comfor variant_path in variant_paths: 9429651SAndreas.Sandberg@ARM.com print "Building in", variant_path 9439651SAndreas.Sandberg@ARM.com 9449657Sandreas.sandberg@arm.com # Make a copy of the build-root environment to use for this config. 9459651SAndreas.Sandberg@ARM.com env = main.Clone() 9469651SAndreas.Sandberg@ARM.com env['BUILDDIR'] = variant_path 9479651SAndreas.Sandberg@ARM.com 9489651SAndreas.Sandberg@ARM.com # variant_dir is the tail component of build path, and is used to 9499651SAndreas.Sandberg@ARM.com # determine the build parameters (e.g., 'ALPHA_SE') 9509651SAndreas.Sandberg@ARM.com (build_root, variant_dir) = splitpath(variant_path) 9519651SAndreas.Sandberg@ARM.com 9529651SAndreas.Sandberg@ARM.com # Set env variables according to the build directory config. 9539651SAndreas.Sandberg@ARM.com sticky_vars.files = [] 9549651SAndreas.Sandberg@ARM.com # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in 9559651SAndreas.Sandberg@ARM.com # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke 9565863Snate@binkert.org # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings. 9575863Snate@binkert.org current_vars_file = joinpath(build_root, 'variables', variant_dir) 9585863Snate@binkert.org if isfile(current_vars_file): 9595863Snate@binkert.org sticky_vars.files.append(current_vars_file) 9606121Snate@binkert.org print "Using saved variables file %s" % current_vars_file 9611858SN/A else: 9625863Snate@binkert.org # Build dir-specific variables file doesn't exist. 9635863Snate@binkert.org 9645863Snate@binkert.org # Make sure the directory is there so we can create it later 9655863Snate@binkert.org opt_dir = dirname(current_vars_file) 9665863Snate@binkert.org if not isdir(opt_dir): 9672139SN/A mkdir(opt_dir) 9684202Sbinkertn@umich.edu 9694202Sbinkertn@umich.edu # Get default build variables from source tree. Variables are 9702139SN/A # normally determined by name of $VARIANT_DIR, but can be 9716994Snate@binkert.org # overridden by '--default=' arg on command line. 9726994Snate@binkert.org default = GetOption('default') 9736994Snate@binkert.org opts_dir = joinpath(main.root.abspath, 'build_opts') 9746994Snate@binkert.org if default: 9756994Snate@binkert.org default_vars_files = [joinpath(build_root, 'variables', default), 9766994Snate@binkert.org joinpath(opts_dir, default)] 9776994Snate@binkert.org else: 9786994Snate@binkert.org default_vars_files = [joinpath(opts_dir, variant_dir)] 9796994Snate@binkert.org existing_files = filter(isfile, default_vars_files) 9806994Snate@binkert.org if existing_files: 9816994Snate@binkert.org default_vars_file = existing_files[0] 9826994Snate@binkert.org sticky_vars.files.append(default_vars_file) 9836994Snate@binkert.org print "Variables file %s not found,\n using defaults in %s" \ 9846994Snate@binkert.org % (current_vars_file, default_vars_file) 9856994Snate@binkert.org else: 9866994Snate@binkert.org print "Error: cannot find variables file %s or " \ 9876994Snate@binkert.org "default file(s) %s" \ 9886994Snate@binkert.org % (current_vars_file, ' or '.join(default_vars_files)) 9896994Snate@binkert.org Exit(1) 9906994Snate@binkert.org 9916994Snate@binkert.org # Apply current variable settings to env 9926994Snate@binkert.org sticky_vars.Update(env) 9936994Snate@binkert.org 9946994Snate@binkert.org help_texts["local_vars"] += \ 9956994Snate@binkert.org "Build variables for %s:\n" % variant_dir \ 9966994Snate@binkert.org + sticky_vars.GenerateHelpText(env) 9976994Snate@binkert.org 9986994Snate@binkert.org # Process variable settings. 9992155SN/A 10005863Snate@binkert.org if not have_fenv and env['USE_FENV']: 10011869SN/A print "Warning: <fenv.h> not available; " \ 10021869SN/A "forcing USE_FENV to False in", variant_dir + "." 10035863Snate@binkert.org env['USE_FENV'] = False 10045863Snate@binkert.org 10054202Sbinkertn@umich.edu if not env['USE_FENV']: 10066108Snate@binkert.org print "Warning: No IEEE FP rounding mode control in", variant_dir + "." 10076108Snate@binkert.org print " FP results may deviate slightly from other platforms." 10086108Snate@binkert.org 10096108Snate@binkert.org if env['EFENCE']: 10109219Spower.jg@gmail.com env.Append(LIBS=['efence']) 10119219Spower.jg@gmail.com 10129219Spower.jg@gmail.com # Save sticky variable settings back to current variables file 10139219Spower.jg@gmail.com sticky_vars.Save(current_vars_file, env) 10149219Spower.jg@gmail.com 10159219Spower.jg@gmail.com if env['USE_SSE2']: 10169219Spower.jg@gmail.com env.Append(CCFLAGS=['-msse2']) 10179219Spower.jg@gmail.com 10184202Sbinkertn@umich.edu # The src/SConscript file sets up the build rules in 'env' according 10195863Snate@binkert.org # to the configured variables. It returns a list of environments, 10208474Sgblack@eecs.umich.edu # one for each variant build (debug, opt, etc.) 10218474Sgblack@eecs.umich.edu envList = SConscript('src/SConscript', variant_dir = variant_path, 10225742Snate@binkert.org exports = 'env') 10238268Ssteve.reinhardt@amd.com 10248268Ssteve.reinhardt@amd.com # Set up the regression tests for each build. 10258268Ssteve.reinhardt@amd.com for e in envList: 10265742Snate@binkert.org SConscript('tests/SConscript', 10275341Sstever@gmail.com variant_dir = joinpath(variant_path, 'tests', e.Label), 10288474Sgblack@eecs.umich.edu exports = { 'env' : e }, duplicate = False) 10298474Sgblack@eecs.umich.edu 10305342Sstever@gmail.com# base help text 10314202Sbinkertn@umich.eduHelp(''' 10324202Sbinkertn@umich.eduUsage: scons [scons options] [build variables] [target(s)] 10334202Sbinkertn@umich.edu 10345863Snate@binkert.orgExtra scons options: 10355863Snate@binkert.org%(options)s 10366994Snate@binkert.org 10376994Snate@binkert.orgGlobal build variables: 10386994Snate@binkert.org%(global_vars)s 10395863Snate@binkert.org 10405863Snate@binkert.org%(local_vars)s 10415863Snate@binkert.org''' % help_texts) 10425863Snate@binkert.org