SConstruct revision 9926:45a013c50eff
15409Sgblack@eecs.umich.edu# -*- mode:python -*- 24519Sgblack@eecs.umich.edu 34519Sgblack@eecs.umich.edu# Copyright (c) 2013 ARM Limited 47087Snate@binkert.org# All rights reserved. 57087Snate@binkert.org# 67087Snate@binkert.org# The license below extends only to copyright in the software and shall 77087Snate@binkert.org# not be construed as granting a license to any other intellectual 87087Snate@binkert.org# property including but not limited to intellectual property relating 97087Snate@binkert.org# to a hardware implementation of the functionality of the software 107087Snate@binkert.org# licensed hereunder. You may use the software subject to the license 117087Snate@binkert.org# terms below provided that you ensure that this notice is replicated 124519Sgblack@eecs.umich.edu# unmodified and in its entirety in all distributions of the software, 137087Snate@binkert.org# modified or unmodified, in source code or in binary form. 147087Snate@binkert.org# 157087Snate@binkert.org# Copyright (c) 2011 Advanced Micro Devices, Inc. 167087Snate@binkert.org# Copyright (c) 2009 The Hewlett-Packard Development Company 177087Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan 187087Snate@binkert.org# All rights reserved. 197087Snate@binkert.org# 207087Snate@binkert.org# Redistribution and use in source and binary forms, with or without 214519Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 227087Snate@binkert.org# met: redistributions of source code must retain the above copyright 234519Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 244519Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 254519Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 264519Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 274519Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 284519Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 294519Sgblack@eecs.umich.edu# this software without specific prior written permission. 304519Sgblack@eecs.umich.edu# 314519Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 324519Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 334519Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 344519Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 354519Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 364519Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 374519Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 384519Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 394519Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 404519Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 414519Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 424519Sgblack@eecs.umich.edu# 434519Sgblack@eecs.umich.edu# Authors: Steve Reinhardt 444519Sgblack@eecs.umich.edu# Nathan Binkert 454519Sgblack@eecs.umich.edu 464519Sgblack@eecs.umich.edu################################################### 474519Sgblack@eecs.umich.edu# 484519Sgblack@eecs.umich.edu# SCons top-level build description (SConstruct) file. 494519Sgblack@eecs.umich.edu# 504809Sgblack@eecs.umich.edu# While in this directory ('gem5'), just type 'scons' to build the default 514519Sgblack@eecs.umich.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 524519Sgblack@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA/gem5.opt' for 534688Sgblack@eecs.umich.edu# the optimized full-system version). 544688Sgblack@eecs.umich.edu# 554688Sgblack@eecs.umich.edu# You can build gem5 in a different directory as long as there is a 564688Sgblack@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path. The build system 574688Sgblack@eecs.umich.edu# expects that all configs under the same build directory are being 584688Sgblack@eecs.umich.edu# built for the same host system. 594708Sgblack@eecs.umich.edu# 604708Sgblack@eecs.umich.edu# Examples: 614708Sgblack@eecs.umich.edu# 624708Sgblack@eecs.umich.edu# The following two commands are equivalent. The '-u' option tells 634519Sgblack@eecs.umich.edu# scons to search up the directory tree for this SConstruct file. 644519Sgblack@eecs.umich.edu# % cd <path-to-src>/gem5 ; scons build/ALPHA/gem5.debug 654519Sgblack@eecs.umich.edu# % cd <path-to-src>/gem5/build/ALPHA; scons -u gem5.debug 664519Sgblack@eecs.umich.edu# 674519Sgblack@eecs.umich.edu# The following two commands are equivalent and demonstrate building 684519Sgblack@eecs.umich.edu# in a directory outside of the source tree. The '-C' option tells 694519Sgblack@eecs.umich.edu# scons to chdir to the specified directory to find this SConstruct 704519Sgblack@eecs.umich.edu# file. 714519Sgblack@eecs.umich.edu# % cd <path-to-src>/gem5 ; scons /local/foo/build/ALPHA/gem5.debug 724519Sgblack@eecs.umich.edu# % cd /local/foo/build/ALPHA; scons -C <path-to-src>/gem5 gem5.debug 734519Sgblack@eecs.umich.edu# 744951Sgblack@eecs.umich.edu# You can use 'scons -H' to print scons options. If you're in this 754519Sgblack@eecs.umich.edu# 'gem5' directory (or use -u or -C to tell scons where to find this 764519Sgblack@eecs.umich.edu# file), you can use 'scons -h' to print all the gem5-specific build 774519Sgblack@eecs.umich.edu# options as well. 784519Sgblack@eecs.umich.edu# 794519Sgblack@eecs.umich.edu################################################### 804519Sgblack@eecs.umich.edu 814688Sgblack@eecs.umich.edu# Check for recent-enough Python and SCons versions. 824688Sgblack@eecs.umich.edutry: 834688Sgblack@eecs.umich.edu # Really old versions of scons only take two options for the 844688Sgblack@eecs.umich.edu # function, so check once without the revision and once with the 854688Sgblack@eecs.umich.edu # revision, the first instance will fail for stuff other than 864688Sgblack@eecs.umich.edu # 0.98, and the second will fail for 0.98.0 874708Sgblack@eecs.umich.edu EnsureSConsVersion(0, 98) 884708Sgblack@eecs.umich.edu EnsureSConsVersion(0, 98, 1) 894708Sgblack@eecs.umich.eduexcept SystemExit, e: 904708Sgblack@eecs.umich.edu print """ 914519Sgblack@eecs.umich.eduFor more details, see: 924519Sgblack@eecs.umich.edu http://gem5.org/Dependencies 934519Sgblack@eecs.umich.edu""" 944519Sgblack@eecs.umich.edu raise 954519Sgblack@eecs.umich.edu 964519Sgblack@eecs.umich.edu# We ensure the python version early because because python-config 974519Sgblack@eecs.umich.edu# requires python 2.5 984519Sgblack@eecs.umich.edutry: 994519Sgblack@eecs.umich.edu EnsurePythonVersion(2, 5) 1004519Sgblack@eecs.umich.eduexcept SystemExit, e: 1014519Sgblack@eecs.umich.edu print """ 1024519Sgblack@eecs.umich.eduYou can use a non-default installation of the Python interpreter by 1034519Sgblack@eecs.umich.edurearranging your PATH so that scons finds the non-default 'python' and 1044519Sgblack@eecs.umich.edu'python-config' first. 1054519Sgblack@eecs.umich.edu 1064519Sgblack@eecs.umich.eduFor more details, see: 1074519Sgblack@eecs.umich.edu http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation 1084519Sgblack@eecs.umich.edu""" 1097620Sgblack@eecs.umich.edu raise 1106345Sgblack@eecs.umich.edu 1114712Sgblack@eecs.umich.edu# Global Python includes 1124519Sgblack@eecs.umich.eduimport os 1134519Sgblack@eecs.umich.eduimport re 1144519Sgblack@eecs.umich.eduimport subprocess 1156345Sgblack@eecs.umich.eduimport sys 1164712Sgblack@eecs.umich.edu 1174519Sgblack@eecs.umich.edufrom os import mkdir, environ 1184519Sgblack@eecs.umich.edufrom os.path import abspath, basename, dirname, expanduser, normpath 1194519Sgblack@eecs.umich.edufrom os.path import exists, isdir, isfile 1204519Sgblack@eecs.umich.edufrom os.path import join as joinpath, split as splitpath 1214519Sgblack@eecs.umich.edu 1224519Sgblack@eecs.umich.edu# SCons includes 1234519Sgblack@eecs.umich.eduimport SCons 1244951Sgblack@eecs.umich.eduimport SCons.Node 1254519Sgblack@eecs.umich.edu 1264519Sgblack@eecs.umich.eduextra_python_paths = [ 1274519Sgblack@eecs.umich.edu Dir('src/python').srcnode().abspath, # gem5 includes 1284519Sgblack@eecs.umich.edu Dir('ext/ply').srcnode().abspath, # ply is used by several files 1294519Sgblack@eecs.umich.edu ] 1304951Sgblack@eecs.umich.edu 1317620Sgblack@eecs.umich.edusys.path[1:1] = extra_python_paths 1326646Sgblack@eecs.umich.edu 1334712Sgblack@eecs.umich.edufrom m5.util import compareVersions, readCommand 1344519Sgblack@eecs.umich.edufrom m5.util.terminal import get_termcap 1354951Sgblack@eecs.umich.edu 1364519Sgblack@eecs.umich.eduhelp_texts = { 1376646Sgblack@eecs.umich.edu "options" : "", 1384712Sgblack@eecs.umich.edu "global_vars" : "", 1394519Sgblack@eecs.umich.edu "local_vars" : "" 1404519Sgblack@eecs.umich.edu} 1414519Sgblack@eecs.umich.edu 1424519Sgblack@eecs.umich.eduExport("help_texts") 1434519Sgblack@eecs.umich.edu 1444519Sgblack@eecs.umich.edu 1454519Sgblack@eecs.umich.edu# There's a bug in scons in that (1) by default, the help texts from 1464519Sgblack@eecs.umich.edu# AddOption() are supposed to be displayed when you type 'scons -h' 1474519Sgblack@eecs.umich.edu# and (2) you can override the help displayed by 'scons -h' using the 1484519Sgblack@eecs.umich.edu# Help() function, but these two features are incompatible: once 1494519Sgblack@eecs.umich.edu# you've overridden the help text using Help(), there's no way to get 1504519Sgblack@eecs.umich.edu# at the help texts from AddOptions. See: 1514519Sgblack@eecs.umich.edu# http://scons.tigris.org/issues/show_bug.cgi?id=2356 1524519Sgblack@eecs.umich.edu# http://scons.tigris.org/issues/show_bug.cgi?id=2611 1536345Sgblack@eecs.umich.edu# This hack lets us extract the help text from AddOptions and 1544712Sgblack@eecs.umich.edu# re-inject it via Help(). Ideally someday this bug will be fixed and 1557620Sgblack@eecs.umich.edu# we can just use AddOption directly. 1564688Sgblack@eecs.umich.edudef AddLocalOption(*args, **kwargs): 1574581Sgblack@eecs.umich.edu col_width = 30 1584519Sgblack@eecs.umich.edu 1594519Sgblack@eecs.umich.edu help = " " + ", ".join(args) 1604519Sgblack@eecs.umich.edu if "help" in kwargs: 1614519Sgblack@eecs.umich.edu length = len(help) 1624519Sgblack@eecs.umich.edu if length >= col_width: 1637620Sgblack@eecs.umich.edu help += "\n" + " " * col_width 1646345Sgblack@eecs.umich.edu else: 1654712Sgblack@eecs.umich.edu help += " " * (col_width - length) 1667620Sgblack@eecs.umich.edu help += kwargs["help"] 1674688Sgblack@eecs.umich.edu help_texts["options"] += help + "\n" 1684581Sgblack@eecs.umich.edu 1694519Sgblack@eecs.umich.edu AddOption(*args, **kwargs) 1704519Sgblack@eecs.umich.edu 1714519Sgblack@eecs.umich.eduAddLocalOption('--colors', dest='use_colors', action='store_true', 1724519Sgblack@eecs.umich.edu help="Add color to abbreviated scons output") 1734519Sgblack@eecs.umich.eduAddLocalOption('--no-colors', dest='use_colors', action='store_false', 1744519Sgblack@eecs.umich.edu help="Don't add color to abbreviated scons output") 1754519Sgblack@eecs.umich.eduAddLocalOption('--default', dest='default', type='string', action='store', 1764951Sgblack@eecs.umich.edu help='Override which build_opts file to use for defaults') 1774519Sgblack@eecs.umich.eduAddLocalOption('--ignore-style', dest='ignore_style', action='store_true', 1784519Sgblack@eecs.umich.edu help='Disable style checking hooks') 1794519Sgblack@eecs.umich.eduAddLocalOption('--no-lto', dest='no_lto', action='store_true', 1804519Sgblack@eecs.umich.edu help='Disable Link-Time Optimization for fast') 1814951Sgblack@eecs.umich.eduAddLocalOption('--update-ref', dest='update_ref', action='store_true', 1824519Sgblack@eecs.umich.edu help='Update test reference outputs') 1836646Sgblack@eecs.umich.eduAddLocalOption('--verbose', dest='verbose', action='store_true', 1844712Sgblack@eecs.umich.edu help='Print full tool command lines') 1857620Sgblack@eecs.umich.edu 1864688Sgblack@eecs.umich.edutermcap = get_termcap(GetOption('use_colors')) 1874581Sgblack@eecs.umich.edu 1884519Sgblack@eecs.umich.edu######################################################################## 1894519Sgblack@eecs.umich.edu# 1904519Sgblack@eecs.umich.edu# Set up the main build environment. 1914519Sgblack@eecs.umich.edu# 1924951Sgblack@eecs.umich.edu######################################################################## 1937620Sgblack@eecs.umich.edu 1946646Sgblack@eecs.umich.edu# export TERM so that clang reports errors in color 1954712Sgblack@eecs.umich.eduuse_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 1967620Sgblack@eecs.umich.edu 'LIBRARY_PATH', 'PATH', 'PKG_CONFIG_PATH', 'PYTHONPATH', 1974688Sgblack@eecs.umich.edu 'RANLIB', 'SWIG', 'TERM' ]) 1984581Sgblack@eecs.umich.edu 1994519Sgblack@eecs.umich.eduuse_prefixes = [ 2004519Sgblack@eecs.umich.edu "M5", # M5 configuration (e.g., path to kernels) 2014519Sgblack@eecs.umich.edu "DISTCC_", # distcc (distributed compiler wrapper) configuration 2024519Sgblack@eecs.umich.edu "CCACHE_", # ccache (caching compiler wrapper) configuration 2034519Sgblack@eecs.umich.edu "CCC_", # clang static analyzer configuration 2045075Sgblack@eecs.umich.edu ] 2055075Sgblack@eecs.umich.edu 2065075Sgblack@eecs.umich.eduuse_env = {} 2075075Sgblack@eecs.umich.edufor key,val in os.environ.iteritems(): 2085428Sgblack@eecs.umich.edu if key in use_vars or \ 2095428Sgblack@eecs.umich.edu any([key.startswith(prefix) for prefix in use_prefixes]): 2105674Sgblack@eecs.umich.edu use_env[key] = val 2115899Sgblack@eecs.umich.edu 2125936Sgblack@eecs.umich.edumain = Environment(ENV=use_env) 2135428Sgblack@eecs.umich.edumain.Decider('MD5-timestamp') 2145678Sgblack@eecs.umich.edumain.root = Dir(".") # The current directory (where this file lives). 2155678Sgblack@eecs.umich.edumain.srcdir = Dir("src") # The source directory 2165678Sgblack@eecs.umich.edu 2175678Sgblack@eecs.umich.edumain_dict_keys = main.Dictionary().keys() 2185678Sgblack@eecs.umich.edu 2195678Sgblack@eecs.umich.edu# Check that we have a C/C++ compiler 2205678Sgblack@eecs.umich.eduif not ('CC' in main_dict_keys and 'CXX' in main_dict_keys): 2215678Sgblack@eecs.umich.edu print "No C++ compiler installed (package g++ on Ubuntu and RedHat)" 2225678Sgblack@eecs.umich.edu Exit(1) 2235075Sgblack@eecs.umich.edu 2245075Sgblack@eecs.umich.edu# Check that swig is present 2255075Sgblack@eecs.umich.eduif not 'SWIG' in main_dict_keys: 2265075Sgblack@eecs.umich.edu print "swig is not installed (package swig on Ubuntu and RedHat)" 2275075Sgblack@eecs.umich.edu Exit(1) 2285075Sgblack@eecs.umich.edu 2295075Sgblack@eecs.umich.edu# add useful python code PYTHONPATH so it can be used by subprocesses 2305075Sgblack@eecs.umich.edu# as well 2315075Sgblack@eecs.umich.edumain.AppendENVPath('PYTHONPATH', extra_python_paths) 2325075Sgblack@eecs.umich.edu 2335075Sgblack@eecs.umich.edu######################################################################## 2345075Sgblack@eecs.umich.edu# 2355075Sgblack@eecs.umich.edu# Mercurial Stuff. 2365075Sgblack@eecs.umich.edu# 2375075Sgblack@eecs.umich.edu# If the gem5 directory is a mercurial repository, we should do some 2385075Sgblack@eecs.umich.edu# extra things. 2395075Sgblack@eecs.umich.edu# 2405075Sgblack@eecs.umich.edu######################################################################## 2415075Sgblack@eecs.umich.edu 2425075Sgblack@eecs.umich.eduhgdir = main.root.Dir(".hg") 2435075Sgblack@eecs.umich.edu 2445075Sgblack@eecs.umich.edumercurial_style_message = """ 2455075Sgblack@eecs.umich.eduYou're missing the gem5 style hook, which automatically checks your code 2465075Sgblack@eecs.umich.eduagainst the gem5 style rules on hg commit and qrefresh commands. This 2475075Sgblack@eecs.umich.eduscript will now install the hook in your .hg/hgrc file. 2485075Sgblack@eecs.umich.eduPress enter to continue, or ctrl-c to abort: """ 2495075Sgblack@eecs.umich.edu 2505075Sgblack@eecs.umich.edumercurial_style_hook = """ 2515075Sgblack@eecs.umich.edu# The following lines were automatically added by gem5/SConstruct 2525075Sgblack@eecs.umich.edu# to provide the gem5 style-checking hooks 2535075Sgblack@eecs.umich.edu[extensions] 2545075Sgblack@eecs.umich.edustyle = %s/util/style.py 2555075Sgblack@eecs.umich.edu 2565075Sgblack@eecs.umich.edu[hooks] 2575075Sgblack@eecs.umich.edupretxncommit.style = python:style.check_style 2584519Sgblack@eecs.umich.edupre-qrefresh.style = python:style.check_style 2595040Sgblack@eecs.umich.edu# End of SConstruct additions 2605040Sgblack@eecs.umich.edu 2615040Sgblack@eecs.umich.edu""" % (main.root.abspath) 2625040Sgblack@eecs.umich.edu 2635040Sgblack@eecs.umich.edumercurial_lib_not_found = """ 2645040Sgblack@eecs.umich.eduMercurial libraries cannot be found, ignoring style hook. If 2655040Sgblack@eecs.umich.eduyou are a gem5 developer, please fix this and run the style 2665040Sgblack@eecs.umich.eduhook. It is important. 2675040Sgblack@eecs.umich.edu""" 2685040Sgblack@eecs.umich.edu 2695040Sgblack@eecs.umich.edu# Check for style hook and prompt for installation if it's not there. 2705040Sgblack@eecs.umich.edu# Skip this if --ignore-style was specified, there's no .hg dir to 2715040Sgblack@eecs.umich.edu# install a hook in, or there's no interactive terminal to prompt. 2725040Sgblack@eecs.umich.eduif not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty(): 2735040Sgblack@eecs.umich.edu style_hook = True 2745040Sgblack@eecs.umich.edu try: 2755040Sgblack@eecs.umich.edu from mercurial import ui 2765040Sgblack@eecs.umich.edu ui = ui.ui() 2775040Sgblack@eecs.umich.edu ui.readconfig(hgdir.File('hgrc').abspath) 2785040Sgblack@eecs.umich.edu style_hook = ui.config('hooks', 'pretxncommit.style', None) and \ 2795040Sgblack@eecs.umich.edu ui.config('hooks', 'pre-qrefresh.style', None) 2805040Sgblack@eecs.umich.edu except ImportError: 2815040Sgblack@eecs.umich.edu print mercurial_lib_not_found 2825040Sgblack@eecs.umich.edu 2835040Sgblack@eecs.umich.edu if not style_hook: 2845040Sgblack@eecs.umich.edu print mercurial_style_message, 2855040Sgblack@eecs.umich.edu # continue unless user does ctrl-c/ctrl-d etc. 2865040Sgblack@eecs.umich.edu try: 2875040Sgblack@eecs.umich.edu raw_input() 2885040Sgblack@eecs.umich.edu except: 2895062Sgblack@eecs.umich.edu print "Input exception, exiting scons.\n" 2905062Sgblack@eecs.umich.edu sys.exit(1) 2915062Sgblack@eecs.umich.edu hgrc_path = '%s/.hg/hgrc' % main.root.abspath 2925062Sgblack@eecs.umich.edu print "Adding style hook to", hgrc_path, "\n" 2935062Sgblack@eecs.umich.edu try: 2945062Sgblack@eecs.umich.edu hgrc = open(hgrc_path, 'a') 2955062Sgblack@eecs.umich.edu hgrc.write(mercurial_style_hook) 2965040Sgblack@eecs.umich.edu hgrc.close() 2975062Sgblack@eecs.umich.edu except: 2985062Sgblack@eecs.umich.edu print "Error updating", hgrc_path 2995062Sgblack@eecs.umich.edu sys.exit(1) 3005062Sgblack@eecs.umich.edu 3016647Sgblack@eecs.umich.edu 3025040Sgblack@eecs.umich.edu################################################### 3036647Sgblack@eecs.umich.edu# 3046647Sgblack@eecs.umich.edu# Figure out which configurations to set up based on the path(s) of 3056647Sgblack@eecs.umich.edu# the target(s). 3066647Sgblack@eecs.umich.edu# 3075040Sgblack@eecs.umich.edu################################################### 3085040Sgblack@eecs.umich.edu 3095040Sgblack@eecs.umich.edu# Find default configuration & binary. 3105040Sgblack@eecs.umich.eduDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA/gem5.debug')) 3115239Sgblack@eecs.umich.edu 3125040Sgblack@eecs.umich.edu# helper function: find last occurrence of element in list 3135040Sgblack@eecs.umich.edudef rfind(l, elt, offs = -1): 3145040Sgblack@eecs.umich.edu for i in range(len(l)+offs, 0, -1): 3155040Sgblack@eecs.umich.edu if l[i] == elt: 3165040Sgblack@eecs.umich.edu return i 3175040Sgblack@eecs.umich.edu raise ValueError, "element not found" 3185040Sgblack@eecs.umich.edu 3195040Sgblack@eecs.umich.edu# Take a list of paths (or SCons Nodes) and return a list with all 3205061Sgblack@eecs.umich.edu# paths made absolute and ~-expanded. Paths will be interpreted 3215040Sgblack@eecs.umich.edu# relative to the launch directory unless a different root is provided 3225040Sgblack@eecs.umich.edudef makePathListAbsolute(path_list, root=GetLaunchDir()): 3235061Sgblack@eecs.umich.edu return [abspath(joinpath(root, expanduser(str(p)))) 3245061Sgblack@eecs.umich.edu for p in path_list] 3255061Sgblack@eecs.umich.edu 3265061Sgblack@eecs.umich.edu# Each target must have 'build' in the interior of the path; the 3275061Sgblack@eecs.umich.edu# directory below this will determine the build parameters. For 3285061Sgblack@eecs.umich.edu# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 3295061Sgblack@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it 3305061Sgblack@eecs.umich.edu# follow 'build' in the build path. 3316647Sgblack@eecs.umich.edu 3326647Sgblack@eecs.umich.edu# The funky assignment to "[:]" is needed to replace the list contents 3336647Sgblack@eecs.umich.edu# in place rather than reassign the symbol to a new list, which 3345040Sgblack@eecs.umich.edu# doesn't work (obviously!). 3355040Sgblack@eecs.umich.eduBUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) 3365040Sgblack@eecs.umich.edu 3375040Sgblack@eecs.umich.edu# Generate a list of the unique build roots and configs that the 3385040Sgblack@eecs.umich.edu# collected targets reference. 3395040Sgblack@eecs.umich.eduvariant_paths = [] 3406647Sgblack@eecs.umich.edubuild_root = None 3415040Sgblack@eecs.umich.edufor t in BUILD_TARGETS: 3425040Sgblack@eecs.umich.edu path_dirs = t.split('/') 3435040Sgblack@eecs.umich.edu try: 3445040Sgblack@eecs.umich.edu build_top = rfind(path_dirs, 'build', -2) 3455040Sgblack@eecs.umich.edu except: 3465040Sgblack@eecs.umich.edu print "Error: no non-leaf 'build' dir found on target path", t 3475040Sgblack@eecs.umich.edu Exit(1) 3485040Sgblack@eecs.umich.edu this_build_root = joinpath('/',*path_dirs[:build_top+1]) 3495040Sgblack@eecs.umich.edu if not build_root: 3505040Sgblack@eecs.umich.edu build_root = this_build_root 3515040Sgblack@eecs.umich.edu else: 3525040Sgblack@eecs.umich.edu if this_build_root != build_root: 3535040Sgblack@eecs.umich.edu print "Error: build targets not under same build root\n"\ 3545040Sgblack@eecs.umich.edu " %s\n %s" % (build_root, this_build_root) 3555040Sgblack@eecs.umich.edu Exit(1) 3565040Sgblack@eecs.umich.edu variant_path = joinpath('/',*path_dirs[:build_top+2]) 3575040Sgblack@eecs.umich.edu if variant_path not in variant_paths: 3585040Sgblack@eecs.umich.edu variant_paths.append(variant_path) 3594688Sgblack@eecs.umich.edu 3605040Sgblack@eecs.umich.edu# Make sure build_root exists (might not if this is the first build there) 3614688Sgblack@eecs.umich.eduif not isdir(build_root): 3624688Sgblack@eecs.umich.edu mkdir(build_root) 3634688Sgblack@eecs.umich.edumain['BUILDROOT'] = build_root 3644688Sgblack@eecs.umich.edu 3655040Sgblack@eecs.umich.eduExport('main') 3664688Sgblack@eecs.umich.edu 3675040Sgblack@eecs.umich.edumain.SConsignFile(joinpath(build_root, "sconsign")) 3685040Sgblack@eecs.umich.edu 3695040Sgblack@eecs.umich.edu# Default duplicate option is to use hard links, but this messes up 3705040Sgblack@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves 3715040Sgblack@eecs.umich.edu# file to file~ then copies to file, breaking the link. Symbolic 3725040Sgblack@eecs.umich.edu# (soft) links work better. 3735040Sgblack@eecs.umich.edumain.SetOption('duplicate', 'soft-copy') 3745040Sgblack@eecs.umich.edu 3755040Sgblack@eecs.umich.edu# 3765040Sgblack@eecs.umich.edu# Set up global sticky variables... these are common to an entire build 3775040Sgblack@eecs.umich.edu# tree (not specific to a particular build like ALPHA_SE) 3785040Sgblack@eecs.umich.edu# 3795040Sgblack@eecs.umich.edu 3805040Sgblack@eecs.umich.eduglobal_vars_file = joinpath(build_root, 'variables.global') 3815040Sgblack@eecs.umich.edu 3825040Sgblack@eecs.umich.eduglobal_vars = Variables(global_vars_file, args=ARGUMENTS) 3835040Sgblack@eecs.umich.edu 3845040Sgblack@eecs.umich.eduglobal_vars.AddVariables( 3855040Sgblack@eecs.umich.edu ('CC', 'C compiler', environ.get('CC', main['CC'])), 3865040Sgblack@eecs.umich.edu ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), 3875040Sgblack@eecs.umich.edu ('SWIG', 'SWIG tool', environ.get('SWIG', main['SWIG'])), 3885040Sgblack@eecs.umich.edu ('PROTOC', 'protoc tool', environ.get('PROTOC', 'protoc')), 3894688Sgblack@eecs.umich.edu ('BATCH', 'Use batch pool for build and tests', False), 3904688Sgblack@eecs.umich.edu ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 3915040Sgblack@eecs.umich.edu ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), 3925040Sgblack@eecs.umich.edu ('EXTRAS', 'Add extra directories to the compilation', '') 3935040Sgblack@eecs.umich.edu ) 3945040Sgblack@eecs.umich.edu 3954688Sgblack@eecs.umich.edu# Update main environment with values from ARGUMENTS & global_vars_file 3964688Sgblack@eecs.umich.eduglobal_vars.Update(main) 3975040Sgblack@eecs.umich.eduhelp_texts["global_vars"] += global_vars.GenerateHelpText(main) 3985040Sgblack@eecs.umich.edu 3995040Sgblack@eecs.umich.edu# Save sticky variable settings back to current variables file 4005040Sgblack@eecs.umich.eduglobal_vars.Save(global_vars_file, main) 4015040Sgblack@eecs.umich.edu 4025040Sgblack@eecs.umich.edu# Parse EXTRAS variable to build list of all directories where we're 4034519Sgblack@eecs.umich.edu# look for sources etc. This list is exported as extras_dir_list. 4044519Sgblack@eecs.umich.edubase_dir = main.srcdir.abspath 4055040Sgblack@eecs.umich.eduif main['EXTRAS']: 4064688Sgblack@eecs.umich.edu extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':')) 4074701Sgblack@eecs.umich.eduelse: 4084688Sgblack@eecs.umich.edu extras_dir_list = [] 4094688Sgblack@eecs.umich.edu 4104688Sgblack@eecs.umich.eduExport('base_dir') 4114688Sgblack@eecs.umich.eduExport('extras_dir_list') 4124688Sgblack@eecs.umich.edu 4134688Sgblack@eecs.umich.edu# the ext directory should be on the #includes path 4144688Sgblack@eecs.umich.edumain.Append(CPPPATH=[Dir('ext')]) 4154519Sgblack@eecs.umich.edu 4167620Sgblack@eecs.umich.edudef strip_build_path(path, env): 4175040Sgblack@eecs.umich.edu path = str(path) 4185040Sgblack@eecs.umich.edu variant_base = env['BUILDROOT'] + os.path.sep 4195040Sgblack@eecs.umich.edu if path.startswith(variant_base): 4207620Sgblack@eecs.umich.edu path = path[len(variant_base):] 4215040Sgblack@eecs.umich.edu elif path.startswith('build/'): 4224688Sgblack@eecs.umich.edu path = path[6:] 4235040Sgblack@eecs.umich.edu return path 4244519Sgblack@eecs.umich.edu 4255040Sgblack@eecs.umich.edu# Generate a string of the form: 4264519Sgblack@eecs.umich.edu# common/path/prefix/src1, src2 -> tgt1, tgt2 4274519Sgblack@eecs.umich.edu# to print while building. 4284519Sgblack@eecs.umich.educlass Transform(object): 4294539Sgblack@eecs.umich.edu # all specific color settings should be here and nowhere else 4304519Sgblack@eecs.umich.edu tool_color = termcap.Normal 4315040Sgblack@eecs.umich.edu pfx_color = termcap.Yellow 4324688Sgblack@eecs.umich.edu srcs_color = termcap.Yellow + termcap.Bold 4335040Sgblack@eecs.umich.edu arrow_color = termcap.Blue + termcap.Bold 4345040Sgblack@eecs.umich.edu tgts_color = termcap.Yellow + termcap.Bold 4355115Sgblack@eecs.umich.edu 4365040Sgblack@eecs.umich.edu def __init__(self, tool, max_sources=99): 4375040Sgblack@eecs.umich.edu self.format = self.tool_color + (" [%8s] " % tool) \ 4385040Sgblack@eecs.umich.edu + self.pfx_color + "%s" \ 4395115Sgblack@eecs.umich.edu + self.srcs_color + "%s" \ 4405040Sgblack@eecs.umich.edu + self.arrow_color + " -> " \ 4415040Sgblack@eecs.umich.edu + self.tgts_color + "%s" \ 4424519Sgblack@eecs.umich.edu + termcap.Normal 4435040Sgblack@eecs.umich.edu self.max_sources = max_sources 4445040Sgblack@eecs.umich.edu 4455040Sgblack@eecs.umich.edu def __call__(self, target, source, env, for_signature=None): 4465040Sgblack@eecs.umich.edu # truncate source list according to max_sources param 4474519Sgblack@eecs.umich.edu source = source[0:self.max_sources] 4485040Sgblack@eecs.umich.edu def strip(f): 4495040Sgblack@eecs.umich.edu return strip_build_path(str(f), env) 4505040Sgblack@eecs.umich.edu if len(source) > 0: 4515040Sgblack@eecs.umich.edu srcs = map(strip, source) 4524519Sgblack@eecs.umich.edu else: 4535040Sgblack@eecs.umich.edu srcs = [''] 4545040Sgblack@eecs.umich.edu tgts = map(strip, target) 4555083Sgblack@eecs.umich.edu # surprisingly, os.path.commonprefix is a dumb char-by-char string 4564519Sgblack@eecs.umich.edu # operation that has nothing to do with paths. 4575063Sgblack@eecs.umich.edu com_pfx = os.path.commonprefix(srcs + tgts) 4585063Sgblack@eecs.umich.edu com_pfx_len = len(com_pfx) 4595063Sgblack@eecs.umich.edu if com_pfx: 4605063Sgblack@eecs.umich.edu # do some cleanup and sanity checking on common prefix 4615063Sgblack@eecs.umich.edu if com_pfx[-1] == ".": 4626345Sgblack@eecs.umich.edu # prefix matches all but file extension: ok 4636345Sgblack@eecs.umich.edu # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 4645063Sgblack@eecs.umich.edu com_pfx = com_pfx[0:-1] 4655063Sgblack@eecs.umich.edu elif com_pfx[-1] == "/": 4665063Sgblack@eecs.umich.edu # common prefix is directory path: OK 4675063Sgblack@eecs.umich.edu pass 4686345Sgblack@eecs.umich.edu else: 4696345Sgblack@eecs.umich.edu src0_len = len(srcs[0]) 4705063Sgblack@eecs.umich.edu tgt0_len = len(tgts[0]) 4715040Sgblack@eecs.umich.edu if src0_len == com_pfx_len: 4725040Sgblack@eecs.umich.edu # source is a substring of target, OK 4734595Sgblack@eecs.umich.edu pass 4745040Sgblack@eecs.umich.edu elif tgt0_len == com_pfx_len: 4755040Sgblack@eecs.umich.edu # target is a substring of source, need to back up to 4764595Sgblack@eecs.umich.edu # avoid empty string on RHS of arrow 4775040Sgblack@eecs.umich.edu sep_idx = com_pfx.rfind(".") 4785040Sgblack@eecs.umich.edu if sep_idx != -1: 4794732Sgblack@eecs.umich.edu com_pfx = com_pfx[0:sep_idx] 4805138Sgblack@eecs.umich.edu else: 4815040Sgblack@eecs.umich.edu com_pfx = '' 4825040Sgblack@eecs.umich.edu elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 4835040Sgblack@eecs.umich.edu # still splitting at file extension: ok 4845040Sgblack@eecs.umich.edu pass 4854732Sgblack@eecs.umich.edu else: 4865138Sgblack@eecs.umich.edu # probably a fluke; ignore it 4875040Sgblack@eecs.umich.edu com_pfx = '' 4885040Sgblack@eecs.umich.edu # recalculate length in case com_pfx was modified 4895040Sgblack@eecs.umich.edu com_pfx_len = len(com_pfx) 4905040Sgblack@eecs.umich.edu def fmt(files): 4915040Sgblack@eecs.umich.edu f = map(lambda s: s[com_pfx_len:], files) 4925040Sgblack@eecs.umich.edu return ', '.join(f) 4935040Sgblack@eecs.umich.edu return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 4945040Sgblack@eecs.umich.edu 4955040Sgblack@eecs.umich.eduExport('Transform') 4965040Sgblack@eecs.umich.edu 4975040Sgblack@eecs.umich.edu# enable the regression script to use the termcap 4985063Sgblack@eecs.umich.edumain['TERMCAP'] = termcap 4995040Sgblack@eecs.umich.edu 5005063Sgblack@eecs.umich.eduif GetOption('verbose'): 5015063Sgblack@eecs.umich.edu def MakeAction(action, string, *args, **kwargs): 5026742Svince@csl.cornell.edu return Action(action, *args, **kwargs) 5036430Sgblack@eecs.umich.eduelse: 5046430Sgblack@eecs.umich.edu MakeAction = Action 5056430Sgblack@eecs.umich.edu main['CCCOMSTR'] = Transform("CC") 5066461Sgblack@eecs.umich.edu main['CXXCOMSTR'] = Transform("CXX") 5076430Sgblack@eecs.umich.edu main['ASCOMSTR'] = Transform("AS") 5086430Sgblack@eecs.umich.edu main['SWIGCOMSTR'] = Transform("SWIG") 5096430Sgblack@eecs.umich.edu main['ARCOMSTR'] = Transform("AR", 0) 5106430Sgblack@eecs.umich.edu main['LINKCOMSTR'] = Transform("LINK", 0) 5116462Sgblack@eecs.umich.edu main['RANLIBCOMSTR'] = Transform("RANLIB", 0) 5126430Sgblack@eecs.umich.edu main['M4COMSTR'] = Transform("M4") 5136462Sgblack@eecs.umich.edu main['SHCCCOMSTR'] = Transform("SHCC") 5146430Sgblack@eecs.umich.edu main['SHCXXCOMSTR'] = Transform("SHCXX") 5156430Sgblack@eecs.umich.eduExport('MakeAction') 5165040Sgblack@eecs.umich.edu 5176463Sgblack@eecs.umich.edu# Initialize the Link-Time Optimization (LTO) flags 5186463Sgblack@eecs.umich.edumain['LTO_CCFLAGS'] = [] 5196463Sgblack@eecs.umich.edumain['LTO_LDFLAGS'] = [] 5206463Sgblack@eecs.umich.edu 5216463Sgblack@eecs.umich.edu# According to the readme, tcmalloc works best if the compiler doesn't 5226463Sgblack@eecs.umich.edu# assume that we're using the builtin malloc and friends. These flags 5236463Sgblack@eecs.umich.edu# are compiler-specific, so we need to set them after we detect which 5246463Sgblack@eecs.umich.edu# compiler we're using. 5255040Sgblack@eecs.umich.edumain['TCMALLOC_CCFLAGS'] = [] 5265063Sgblack@eecs.umich.edu 5275040Sgblack@eecs.umich.eduCXX_version = readCommand([main['CXX'],'--version'], exception=False) 5285063Sgblack@eecs.umich.eduCXX_V = readCommand([main['CXX'],'-V'], exception=False) 5294809Sgblack@eecs.umich.edu 5306742Svince@csl.cornell.edumain['GCC'] = CXX_version and CXX_version.find('g++') >= 0 5316430Sgblack@eecs.umich.edumain['CLANG'] = CXX_version and CXX_version.find('clang') >= 0 5325063Sgblack@eecs.umich.eduif main['GCC'] + main['CLANG'] > 1: 5336461Sgblack@eecs.umich.edu print 'Error: How can we have two at the same time?' 5345063Sgblack@eecs.umich.edu Exit(1) 5355063Sgblack@eecs.umich.edu 5366430Sgblack@eecs.umich.edu# Set up default C++ compiler flags 5375063Sgblack@eecs.umich.eduif main['GCC'] or main['CLANG']: 5385040Sgblack@eecs.umich.edu # As gcc and clang share many flags, do the common parts here 5396463Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-pipe']) 5406463Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-fno-strict-aliasing']) 5416463Sgblack@eecs.umich.edu # Enable -Wall and then disable the few warnings that we 5426463Sgblack@eecs.umich.edu # consistently violate 5436463Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 5446463Sgblack@eecs.umich.edu # We always compile using C++11, but only gcc >= 4.7 and clang 3.1 5456463Sgblack@eecs.umich.edu # actually use that name, so we stick with c++0x 5465040Sgblack@eecs.umich.edu main.Append(CXXFLAGS=['-std=c++0x']) 5475063Sgblack@eecs.umich.edu # Add selected sanity checks from -Wextra 5485063Sgblack@eecs.umich.edu main.Append(CXXFLAGS=['-Wmissing-field-initializers', 5495040Sgblack@eecs.umich.edu '-Woverloaded-virtual']) 5505063Sgblack@eecs.umich.eduelse: 5515063Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, 5525063Sgblack@eecs.umich.edu print "Don't know what compiler options to use for your compiler." 5535063Sgblack@eecs.umich.edu print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX'] 5546345Sgblack@eecs.umich.edu print termcap.Yellow + ' version:' + termcap.Normal, 5556345Sgblack@eecs.umich.edu if not CXX_version: 5565063Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\ 5575062Sgblack@eecs.umich.edu termcap.Normal 5585075Sgblack@eecs.umich.edu else: 5595075Sgblack@eecs.umich.edu print CXX_version.replace('\n', '<nl>') 5605040Sgblack@eecs.umich.edu print " If you're trying to use a compiler other than GCC" 5615075Sgblack@eecs.umich.edu print " or clang, there appears to be something wrong with your" 5625075Sgblack@eecs.umich.edu print " environment." 5635075Sgblack@eecs.umich.edu print " " 5645075Sgblack@eecs.umich.edu print " If you are trying to use a compiler other than those listed" 5655075Sgblack@eecs.umich.edu print " above you will need to ease fix SConstruct and " 5665075Sgblack@eecs.umich.edu print " src/SConscript to support that compiler." 5675075Sgblack@eecs.umich.edu Exit(1) 5685075Sgblack@eecs.umich.edu 5695075Sgblack@eecs.umich.eduif main['GCC']: 5705075Sgblack@eecs.umich.edu # Check for a supported version of gcc, >= 4.4 is needed for c++0x 5715075Sgblack@eecs.umich.edu # support. See http://gcc.gnu.org/projects/cxx0x.html for details 5725075Sgblack@eecs.umich.edu gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) 5735075Sgblack@eecs.umich.edu if compareVersions(gcc_version, "4.4") < 0: 5745075Sgblack@eecs.umich.edu print 'Error: gcc version 4.4 or newer required.' 5755075Sgblack@eecs.umich.edu print ' Installed version:', gcc_version 5765040Sgblack@eecs.umich.edu Exit(1) 5774823Sgblack@eecs.umich.edu 5785075Sgblack@eecs.umich.edu main['GCC_VERSION'] = gcc_version 5795075Sgblack@eecs.umich.edu 5805075Sgblack@eecs.umich.edu # Check for versions with bugs 5815075Sgblack@eecs.umich.edu if not compareVersions(gcc_version, '4.4.1') or \ 5825075Sgblack@eecs.umich.edu not compareVersions(gcc_version, '4.4.2'): 5835075Sgblack@eecs.umich.edu print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' 5845075Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-fno-tree-vectorize']) 5855075Sgblack@eecs.umich.edu 5865075Sgblack@eecs.umich.edu # LTO support is only really working properly from 4.6 and beyond 5875075Sgblack@eecs.umich.edu if compareVersions(gcc_version, '4.6') >= 0: 5885075Sgblack@eecs.umich.edu # Add the appropriate Link-Time Optimization (LTO) flags 5897070Sgblack@eecs.umich.edu # unless LTO is explicitly turned off. Note that these flags 5907070Sgblack@eecs.umich.edu # are only used by the fast target. 5917070Sgblack@eecs.umich.edu if not GetOption('no_lto'): 5927070Sgblack@eecs.umich.edu # Pass the LTO flag when compiling to produce GIMPLE 5937070Sgblack@eecs.umich.edu # output, we merely create the flags here and only append 5947070Sgblack@eecs.umich.edu # them later/ 5957070Sgblack@eecs.umich.edu main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')] 5967070Sgblack@eecs.umich.edu 5977080Sgblack@eecs.umich.edu # Use the same amount of jobs for LTO as we are running 5987070Sgblack@eecs.umich.edu # scons with, we hardcode the use of the linker plugin 5997080Sgblack@eecs.umich.edu # which requires either gold or GNU ld >= 2.21 6007070Sgblack@eecs.umich.edu main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'), 6017070Sgblack@eecs.umich.edu '-fuse-linker-plugin'] 6027070Sgblack@eecs.umich.edu 6037070Sgblack@eecs.umich.edu main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc', 6047070Sgblack@eecs.umich.edu '-fno-builtin-realloc', '-fno-builtin-free']) 6057080Sgblack@eecs.umich.edu 6067080Sgblack@eecs.umich.eduelif main['CLANG']: 6077080Sgblack@eecs.umich.edu # Check for a supported version of clang, >= 2.9 is needed to 6087080Sgblack@eecs.umich.edu # support similar features as gcc 4.4. See 6097070Sgblack@eecs.umich.edu # http://clang.llvm.org/cxx_status.html for details 6107070Sgblack@eecs.umich.edu clang_version_re = re.compile(".* version (\d+\.\d+)") 6117070Sgblack@eecs.umich.edu clang_version_match = clang_version_re.match(CXX_version) 6127070Sgblack@eecs.umich.edu if (clang_version_match): 6137070Sgblack@eecs.umich.edu clang_version = clang_version_match.groups()[0] 6147070Sgblack@eecs.umich.edu if compareVersions(clang_version, "2.9") < 0: 6157070Sgblack@eecs.umich.edu print 'Error: clang version 2.9 or newer required.' 6167070Sgblack@eecs.umich.edu print ' Installed version:', clang_version 6177070Sgblack@eecs.umich.edu Exit(1) 6187070Sgblack@eecs.umich.edu else: 6197070Sgblack@eecs.umich.edu print 'Error: Unable to determine clang version.' 6207070Sgblack@eecs.umich.edu Exit(1) 6217070Sgblack@eecs.umich.edu 6225075Sgblack@eecs.umich.edu # clang has a few additional warnings that we disable, 6235075Sgblack@eecs.umich.edu # tautological comparisons are allowed due to unsigned integers 6245075Sgblack@eecs.umich.edu # being compared to constants that happen to be 0, and extraneous 6255075Sgblack@eecs.umich.edu # parantheses are allowed due to Ruby's printing of the AST, 6265075Sgblack@eecs.umich.edu # finally self assignments are allowed as the generated CPU code 6275075Sgblack@eecs.umich.edu # is relying on this 6285075Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Wno-tautological-compare', 6295075Sgblack@eecs.umich.edu '-Wno-parentheses', 6305075Sgblack@eecs.umich.edu '-Wno-self-assign']) 6317480Sgblack@eecs.umich.edu 6325075Sgblack@eecs.umich.edu main.Append(TCMALLOC_CCFLAGS=['-fno-builtin']) 6335075Sgblack@eecs.umich.edu 6345075Sgblack@eecs.umich.edu # On Mac OS X/Darwin we need to also use libc++ (part of XCode) as 6355075Sgblack@eecs.umich.edu # opposed to libstdc++, as the later is dated. 6364732Sgblack@eecs.umich.edu if sys.platform == "darwin": 6375075Sgblack@eecs.umich.edu main.Append(CXXFLAGS=['-stdlib=libc++']) 6385075Sgblack@eecs.umich.edu main.Append(LIBS=['c++']) 6395075Sgblack@eecs.umich.edu 6405075Sgblack@eecs.umich.eduelse: 6415075Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, 6425040Sgblack@eecs.umich.edu print "Don't know what compiler options to use for your compiler." 6435040Sgblack@eecs.umich.edu print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX'] 6445040Sgblack@eecs.umich.edu print termcap.Yellow + ' version:' + termcap.Normal, 6456482Sgblack@eecs.umich.edu if not CXX_version: 6465040Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\ 6474732Sgblack@eecs.umich.edu termcap.Normal 6485040Sgblack@eecs.umich.edu else: 6495076Sgblack@eecs.umich.edu print CXX_version.replace('\n', '<nl>') 6505040Sgblack@eecs.umich.edu print " If you're trying to use a compiler other than GCC" 6514756Sgblack@eecs.umich.edu print " or clang, there appears to be something wrong with your" 6524823Sgblack@eecs.umich.edu print " environment." 6535040Sgblack@eecs.umich.edu print " " 6545076Sgblack@eecs.umich.edu print " If you are trying to use a compiler other than those listed" 6555076Sgblack@eecs.umich.edu print " above you will need to ease fix SConstruct and " 6565076Sgblack@eecs.umich.edu print " src/SConscript to support that compiler." 6575076Sgblack@eecs.umich.edu Exit(1) 6585076Sgblack@eecs.umich.edu 6595076Sgblack@eecs.umich.edu# Set up common yacc/bison flags (needed for Ruby) 6605076Sgblack@eecs.umich.edumain['YACCFLAGS'] = '-d' 6615076Sgblack@eecs.umich.edumain['YACCHXXFILESUFFIX'] = '.hh' 6626441Sgblack@eecs.umich.edu 6636441Sgblack@eecs.umich.edu# Do this after we save setting back, or else we'll tack on an 6645076Sgblack@eecs.umich.edu# extra 'qdo' every time we run scons. 6656441Sgblack@eecs.umich.eduif main['BATCH']: 6665076Sgblack@eecs.umich.edu main['CC'] = main['BATCH_CMD'] + ' ' + main['CC'] 6675076Sgblack@eecs.umich.edu main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX'] 6685076Sgblack@eecs.umich.edu main['AS'] = main['BATCH_CMD'] + ' ' + main['AS'] 6695076Sgblack@eecs.umich.edu main['AR'] = main['BATCH_CMD'] + ' ' + main['AR'] 6705076Sgblack@eecs.umich.edu main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB'] 6715076Sgblack@eecs.umich.edu 6725076Sgblack@eecs.umich.eduif sys.platform == 'cygwin': 6735076Sgblack@eecs.umich.edu # cygwin has some header file issues... 6745076Sgblack@eecs.umich.edu main.Append(CCFLAGS=["-Wno-uninitialized"]) 6755076Sgblack@eecs.umich.edu 6765076Sgblack@eecs.umich.edu# Check for the protobuf compiler 6775040Sgblack@eecs.umich.eduprotoc_version = readCommand([main['PROTOC'], '--version'], 6785076Sgblack@eecs.umich.edu exception='').split() 6795040Sgblack@eecs.umich.edu 6804756Sgblack@eecs.umich.edu# First two words should be "libprotoc x.y.z" 6814732Sgblack@eecs.umich.eduif len(protoc_version) < 2 or protoc_version[0] != 'libprotoc': 6824732Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + \ 6834732Sgblack@eecs.umich.edu 'Warning: Protocol buffer compiler (protoc) not found.\n' + \ 6844732Sgblack@eecs.umich.edu ' Please install protobuf-compiler for tracing support.' + \ 6854823Sgblack@eecs.umich.edu termcap.Normal 6865040Sgblack@eecs.umich.edu main['PROTOC'] = False 6875076Sgblack@eecs.umich.eduelse: 6885076Sgblack@eecs.umich.edu # Based on the availability of the compress stream wrappers, 6895076Sgblack@eecs.umich.edu # require 2.1.0 6905076Sgblack@eecs.umich.edu min_protoc_version = '2.1.0' 6915076Sgblack@eecs.umich.edu if compareVersions(protoc_version[1], min_protoc_version) < 0: 6925076Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + \ 6935076Sgblack@eecs.umich.edu 'Warning: protoc version', min_protoc_version, \ 6946442Sgblack@eecs.umich.edu 'or newer required.\n' + \ 6956442Sgblack@eecs.umich.edu ' Installed version:', protoc_version[1], \ 6966442Sgblack@eecs.umich.edu termcap.Normal 6975076Sgblack@eecs.umich.edu main['PROTOC'] = False 6986442Sgblack@eecs.umich.edu else: 6995076Sgblack@eecs.umich.edu # Attempt to determine the appropriate include path and 7005076Sgblack@eecs.umich.edu # library path using pkg-config, that means we also need to 7015076Sgblack@eecs.umich.edu # check for pkg-config. Note that it is possible to use 7025076Sgblack@eecs.umich.edu # protobuf without the involvement of pkg-config. Later on we 7035076Sgblack@eecs.umich.edu # check go a library config check and at that point the test 7045076Sgblack@eecs.umich.edu # will fail if libprotobuf cannot be found. 7055076Sgblack@eecs.umich.edu if readCommand(['pkg-config', '--version'], exception=''): 7065076Sgblack@eecs.umich.edu try: 7075040Sgblack@eecs.umich.edu # Attempt to establish what linking flags to add for protobuf 7085076Sgblack@eecs.umich.edu # using pkg-config 7095040Sgblack@eecs.umich.edu main.ParseConfig('pkg-config --cflags --libs-only-L protobuf') 7104756Sgblack@eecs.umich.edu except: 7114732Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + \ 7124732Sgblack@eecs.umich.edu 'Warning: pkg-config could not get protobuf flags.' + \ 7134732Sgblack@eecs.umich.edu termcap.Normal 7146443Sgblack@eecs.umich.edu 7155032Sgblack@eecs.umich.edu# Check for SWIG 7164823Sgblack@eecs.umich.eduif not main.has_key('SWIG'): 7175040Sgblack@eecs.umich.edu print 'Error: SWIG utility not found.' 7185076Sgblack@eecs.umich.edu print ' Please install (see http://www.swig.org) and retry.' 7195076Sgblack@eecs.umich.edu Exit(1) 7205076Sgblack@eecs.umich.edu 7215076Sgblack@eecs.umich.edu# Check for appropriate SWIG version 7225076Sgblack@eecs.umich.eduswig_version = readCommand([main['SWIG'], '-version'], exception='').split() 7235076Sgblack@eecs.umich.edu# First 3 words should be "SWIG Version x.y.z" 7245076Sgblack@eecs.umich.eduif len(swig_version) < 3 or \ 7256444Sgblack@eecs.umich.edu swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 7266444Sgblack@eecs.umich.edu print 'Error determining SWIG version.' 7276444Sgblack@eecs.umich.edu Exit(1) 7286444Sgblack@eecs.umich.edu 7295076Sgblack@eecs.umich.edumin_swig_version = '1.3.34' 7306444Sgblack@eecs.umich.eduif compareVersions(swig_version[2], min_swig_version) < 0: 7315076Sgblack@eecs.umich.edu print 'Error: SWIG version', min_swig_version, 'or newer required.' 7325076Sgblack@eecs.umich.edu print ' Installed version:', swig_version[2] 7335076Sgblack@eecs.umich.edu Exit(1) 7345076Sgblack@eecs.umich.edu 7355076Sgblack@eecs.umich.edu# Older versions of swig do not play well with more recent versions of 7365040Sgblack@eecs.umich.edu# gcc due to assumptions on implicit includes (cstddef) and use of 7375076Sgblack@eecs.umich.edu# namespaces 7385040Sgblack@eecs.umich.eduif main['GCC'] and compareVersions(gcc_version, '4.6') > 0 and \ 7394732Sgblack@eecs.umich.edu compareVersions(swig_version[2], '2') < 0: 7404756Sgblack@eecs.umich.edu print '\n' + termcap.Yellow + termcap.Bold + \ 7416449Sgblack@eecs.umich.edu 'Warning: SWIG 1.x cause issues with gcc 4.6 and later.\n' + \ 7426449Sgblack@eecs.umich.edu termcap.Normal + \ 7434732Sgblack@eecs.umich.edu 'Use SWIG 2.x to avoid assumptions on implicit includes\n' + \ 7446449Sgblack@eecs.umich.edu 'and use of namespaces\n' 7456449Sgblack@eecs.umich.edu 7464732Sgblack@eecs.umich.edu# Set up SWIG flags & scanner 7474732Sgblack@eecs.umich.eduswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 7484732Sgblack@eecs.umich.edumain.Append(SWIGFLAGS=swig_flags) 7496447Sgblack@eecs.umich.edu 7505040Sgblack@eecs.umich.edu# filter out all existing swig scanners, they mess up the dependency 7515076Sgblack@eecs.umich.edu# stuff for some reason 7525076Sgblack@eecs.umich.eduscanners = [] 7535076Sgblack@eecs.umich.edufor scanner in main['SCANNERS']: 7545076Sgblack@eecs.umich.edu skeys = scanner.skeys 7555076Sgblack@eecs.umich.edu if skeys == '.i': 7565076Sgblack@eecs.umich.edu continue 7575076Sgblack@eecs.umich.edu 7585076Sgblack@eecs.umich.edu if isinstance(skeys, (list, tuple)) and '.i' in skeys: 7595076Sgblack@eecs.umich.edu continue 7605076Sgblack@eecs.umich.edu 7615076Sgblack@eecs.umich.edu scanners.append(scanner) 7625076Sgblack@eecs.umich.edu 7635076Sgblack@eecs.umich.edu# add the new swig scanner that we like better 7645076Sgblack@eecs.umich.edufrom SCons.Scanner import ClassicCPP as CPPScanner 7655076Sgblack@eecs.umich.eduswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 7665076Sgblack@eecs.umich.eduscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 7675076Sgblack@eecs.umich.edu 7685076Sgblack@eecs.umich.edu# replace the scanners list that has what we want 7695076Sgblack@eecs.umich.edumain['SCANNERS'] = scanners 7705076Sgblack@eecs.umich.edu 7715040Sgblack@eecs.umich.edu# Add a custom Check function to the Configure context so that we can 7725076Sgblack@eecs.umich.edu# figure out if the compiler adds leading underscores to global 7735040Sgblack@eecs.umich.edu# variables. This is needed for the autogenerated asm files that we 7744733Sgblack@eecs.umich.edu# use for embedding the python code. 7754756Sgblack@eecs.umich.edudef CheckLeading(context): 7766454Sgblack@eecs.umich.edu context.Message("Checking for leading underscore in global variables...") 7776454Sgblack@eecs.umich.edu # 1) Define a global variable called x from asm so the C compiler 7784733Sgblack@eecs.umich.edu # won't change the symbol at all. 7794733Sgblack@eecs.umich.edu # 2) Declare that variable. 7806454Sgblack@eecs.umich.edu # 3) Use the variable 7816454Sgblack@eecs.umich.edu # 7826454Sgblack@eecs.umich.edu # If the compiler prepends an underscore, this will successfully 7836454Sgblack@eecs.umich.edu # link because the external symbol 'x' will be called '_x' which 7844733Sgblack@eecs.umich.edu # was defined by the asm statement. If the compiler does not 7854733Sgblack@eecs.umich.edu # prepend an underscore, this will not successfully link because 7864733Sgblack@eecs.umich.edu # '_x' will have been defined by assembly, while the C portion of 7876447Sgblack@eecs.umich.edu # the code will be trying to use 'x' 7885040Sgblack@eecs.umich.edu ret = context.TryLink(''' 7895076Sgblack@eecs.umich.edu asm(".globl _x; _x: .byte 0"); 7905076Sgblack@eecs.umich.edu extern int x; 7915076Sgblack@eecs.umich.edu int main() { return x; } 7926453Sgblack@eecs.umich.edu ''', extension=".c") 7935076Sgblack@eecs.umich.edu context.env.Append(LEADING_UNDERSCORE=ret) 7945076Sgblack@eecs.umich.edu context.Result(ret) 7955076Sgblack@eecs.umich.edu return ret 7965076Sgblack@eecs.umich.edu 7976453Sgblack@eecs.umich.edu# Platform-specific configuration. Note again that we assume that all 7986453Sgblack@eecs.umich.edu# builds under a given build root run on the same host platform. 7995076Sgblack@eecs.umich.educonf = Configure(main, 8006453Sgblack@eecs.umich.edu conf_dir = joinpath(build_root, '.scons_config'), 8015076Sgblack@eecs.umich.edu log_file = joinpath(build_root, 'scons_config.log'), 8026454Sgblack@eecs.umich.edu custom_tests = { 'CheckLeading' : CheckLeading }) 8036454Sgblack@eecs.umich.edu 8046454Sgblack@eecs.umich.edu# Check for leading underscores. Don't really need to worry either 8055076Sgblack@eecs.umich.edu# way so don't need to check the return code. 8066454Sgblack@eecs.umich.educonf.CheckLeading() 8075076Sgblack@eecs.umich.edu 8085076Sgblack@eecs.umich.edu# Check if we should compile a 64 bit binary on Mac OS X/Darwin 8095076Sgblack@eecs.umich.edutry: 8105076Sgblack@eecs.umich.edu import platform 8115076Sgblack@eecs.umich.edu uname = platform.uname() 8125040Sgblack@eecs.umich.edu if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 8135076Sgblack@eecs.umich.edu if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 8145040Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-arch', 'x86_64']) 8154732Sgblack@eecs.umich.edu main.Append(CFLAGS=['-arch', 'x86_64']) 8164756Sgblack@eecs.umich.edu main.Append(LINKFLAGS=['-arch', 'x86_64']) 8176446Sgblack@eecs.umich.edu main.Append(ASFLAGS=['-arch', 'x86_64']) 8186446Sgblack@eecs.umich.eduexcept: 8194732Sgblack@eecs.umich.edu pass 8206446Sgblack@eecs.umich.edu 8214732Sgblack@eecs.umich.edu# Recent versions of scons substitute a "Null" object for Configure() 8226446Sgblack@eecs.umich.edu# when configuration isn't necessary, e.g., if the "--help" option is 8234732Sgblack@eecs.umich.edu# present. Unfortuantely this Null object always returns false, 8244732Sgblack@eecs.umich.edu# breaking all our configuration checks. We replace it with our own 8254732Sgblack@eecs.umich.edu# more optimistic null object that returns True instead. 8266447Sgblack@eecs.umich.eduif not conf: 8275040Sgblack@eecs.umich.edu def NullCheck(*args, **kwargs): 8285076Sgblack@eecs.umich.edu return True 8295076Sgblack@eecs.umich.edu 8305076Sgblack@eecs.umich.edu class NullConf: 8315076Sgblack@eecs.umich.edu def __init__(self, env): 8325076Sgblack@eecs.umich.edu self.env = env 8335076Sgblack@eecs.umich.edu def Finish(self): 8345076Sgblack@eecs.umich.edu return self.env 8355076Sgblack@eecs.umich.edu def __getattr__(self, mname): 8365076Sgblack@eecs.umich.edu return NullCheck 8375076Sgblack@eecs.umich.edu 8385076Sgblack@eecs.umich.edu conf = NullConf(main) 8395076Sgblack@eecs.umich.edu 8405076Sgblack@eecs.umich.edu# Cache build files in the supplied directory. 8415076Sgblack@eecs.umich.eduif main['M5_BUILD_CACHE']: 8425076Sgblack@eecs.umich.edu print 'Using build cache located at', main['M5_BUILD_CACHE'] 8435076Sgblack@eecs.umich.edu CacheDir(main['M5_BUILD_CACHE']) 8445076Sgblack@eecs.umich.edu 8455076Sgblack@eecs.umich.edu# Find Python include and library directories for embedding the 8465076Sgblack@eecs.umich.edu# interpreter. We rely on python-config to resolve the appropriate 8475076Sgblack@eecs.umich.edu# includes and linker flags. ParseConfig does not seem to understand 8485040Sgblack@eecs.umich.edu# the more exotic linker flags such as -Xlinker and -export-dynamic so 8495076Sgblack@eecs.umich.edu# we add them explicitly below. If you want to link in an alternate 8505040Sgblack@eecs.umich.edu# version of python, see above for instructions on how to invoke 8514733Sgblack@eecs.umich.edu# scons with the appropriate PATH set. 8524756Sgblack@eecs.umich.edupy_includes = readCommand(['python-config', '--includes'], 8536456Sgblack@eecs.umich.edu exception='').split() 8546456Sgblack@eecs.umich.edu# Strip the -I from the include folders before adding them to the 8554733Sgblack@eecs.umich.edu# CPPPATH 8564733Sgblack@eecs.umich.edumain.Append(CPPPATH=map(lambda inc: inc[2:], py_includes)) 8576456Sgblack@eecs.umich.edu 8586456Sgblack@eecs.umich.edu# Read the linker flags and split them into libraries and other link 8594733Sgblack@eecs.umich.edu# flags. The libraries are added later through the call the CheckLib. 8604733Sgblack@eecs.umich.edupy_ld_flags = readCommand(['python-config', '--ldflags'], exception='').split() 8614823Sgblack@eecs.umich.edupy_libs = [] 8626456Sgblack@eecs.umich.edufor lib in py_ld_flags: 8634733Sgblack@eecs.umich.edu if not lib.startswith('-l'): 8644733Sgblack@eecs.umich.edu main.Append(LINKFLAGS=[lib]) 8654733Sgblack@eecs.umich.edu else: 8666447Sgblack@eecs.umich.edu lib = lib[2:] 8675040Sgblack@eecs.umich.edu if lib not in py_libs: 8685076Sgblack@eecs.umich.edu py_libs.append(lib) 8695076Sgblack@eecs.umich.edu 8705076Sgblack@eecs.umich.edu# verify that this stuff works 8716456Sgblack@eecs.umich.eduif not conf.CheckHeader('Python.h', '<>'): 8725076Sgblack@eecs.umich.edu print "Error: can't find Python.h header in", py_includes 8735076Sgblack@eecs.umich.edu print "Install Python headers (package python-dev on Ubuntu and RedHat)" 8745076Sgblack@eecs.umich.edu Exit(1) 8755076Sgblack@eecs.umich.edu 8766456Sgblack@eecs.umich.edufor lib in py_libs: 8775076Sgblack@eecs.umich.edu if not conf.CheckLib(lib): 8786456Sgblack@eecs.umich.edu print "Error: can't find library %s required by python" % lib 8796456Sgblack@eecs.umich.edu Exit(1) 8805076Sgblack@eecs.umich.edu 8815076Sgblack@eecs.umich.edu# On Solaris you need to use libsocket for socket ops 8825076Sgblack@eecs.umich.eduif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 8835076Sgblack@eecs.umich.edu if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 8845076Sgblack@eecs.umich.edu print "Can't find library with socket calls (e.g. accept())" 8855076Sgblack@eecs.umich.edu Exit(1) 8865076Sgblack@eecs.umich.edu 8875076Sgblack@eecs.umich.edu# Check for zlib. If the check passes, libz will be automatically 8885076Sgblack@eecs.umich.edu# added to the LIBS environment variable. 8894732Sgblack@eecs.umich.eduif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 8906479Sgblack@eecs.umich.edu print 'Error: did not find needed zlib compression library '\ 8916479Sgblack@eecs.umich.edu 'and/or zlib.h header file.' 8926479Sgblack@eecs.umich.edu print ' Please install zlib and try again.' 8936479Sgblack@eecs.umich.edu Exit(1) 8946479Sgblack@eecs.umich.edu 8956479Sgblack@eecs.umich.edu# If we have the protobuf compiler, also make sure we have the 8966479Sgblack@eecs.umich.edu# development libraries. If the check passes, libprotobuf will be 8976479Sgblack@eecs.umich.edu# automatically added to the LIBS environment variable. After 8986479Sgblack@eecs.umich.edu# this, we can use the HAVE_PROTOBUF flag to determine if we have 8996479Sgblack@eecs.umich.edu# got both protoc and libprotobuf available. 9006479Sgblack@eecs.umich.edumain['HAVE_PROTOBUF'] = main['PROTOC'] and \ 9016479Sgblack@eecs.umich.edu conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h', 9026479Sgblack@eecs.umich.edu 'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;') 9036479Sgblack@eecs.umich.edu 9046479Sgblack@eecs.umich.edu# If we have the compiler but not the library, print another warning. 9056479Sgblack@eecs.umich.eduif main['PROTOC'] and not main['HAVE_PROTOBUF']: 9066479Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + \ 9076479Sgblack@eecs.umich.edu 'Warning: did not find protocol buffer library and/or headers.\n' + \ 9086479Sgblack@eecs.umich.edu ' Please install libprotobuf-dev for tracing support.' + \ 9096479Sgblack@eecs.umich.edu termcap.Normal 9106479Sgblack@eecs.umich.edu 9116479Sgblack@eecs.umich.edu# Check for librt. 9126479Sgblack@eecs.umich.eduhave_posix_clock = \ 9136479Sgblack@eecs.umich.edu conf.CheckLibWithHeader(None, 'time.h', 'C', 9146479Sgblack@eecs.umich.edu 'clock_nanosleep(0,0,NULL,NULL);') or \ 9156479Sgblack@eecs.umich.edu conf.CheckLibWithHeader('rt', 'time.h', 'C', 9166479Sgblack@eecs.umich.edu 'clock_nanosleep(0,0,NULL,NULL);') 9176479Sgblack@eecs.umich.edu 9186479Sgblack@eecs.umich.eduhave_posix_timers = \ 9196479Sgblack@eecs.umich.edu conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ], 'C', 9206479Sgblack@eecs.umich.edu 'timer_create(CLOCK_MONOTONIC, NULL, NULL);') 9216479Sgblack@eecs.umich.edu 9226479Sgblack@eecs.umich.eduif conf.CheckLib('tcmalloc'): 9236479Sgblack@eecs.umich.edu main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS']) 9246479Sgblack@eecs.umich.eduelif conf.CheckLib('tcmalloc_minimal'): 9256479Sgblack@eecs.umich.edu main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS']) 9266479Sgblack@eecs.umich.eduelse: 9276479Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + \ 9286479Sgblack@eecs.umich.edu "You can get a 12% performance improvement by installing tcmalloc "\ 9296479Sgblack@eecs.umich.edu "(libgoogle-perftools-dev package on Ubuntu or RedHat)." + \ 9306479Sgblack@eecs.umich.edu termcap.Normal 9316479Sgblack@eecs.umich.edu 9326479Sgblack@eecs.umich.eduif not have_posix_clock: 9336479Sgblack@eecs.umich.edu print "Can't find library for POSIX clocks." 9346479Sgblack@eecs.umich.edu 9356479Sgblack@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control) 9366479Sgblack@eecs.umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>') 9376479Sgblack@eecs.umich.eduif not have_fenv: 9386479Sgblack@eecs.umich.edu print "Warning: Header file <fenv.h> not found." 9396479Sgblack@eecs.umich.edu print " This host has no IEEE FP rounding mode control." 9406479Sgblack@eecs.umich.edu 9416479Sgblack@eecs.umich.edu# Check if we should enable KVM-based hardware virtualization. The API 9426479Sgblack@eecs.umich.edu# we rely on exists since version 2.6.36 of the kernel, but somehow 9436479Sgblack@eecs.umich.edu# the KVM_API_VERSION does not reflect the change. We test for one of 9446479Sgblack@eecs.umich.edu# the types as a fall back. 9456479Sgblack@eecs.umich.eduhave_kvm = conf.CheckHeader('linux/kvm.h', '<>') and \ 9466479Sgblack@eecs.umich.edu conf.CheckTypeSize('struct kvm_xsave', '#include <linux/kvm.h>') != 0 9476479Sgblack@eecs.umich.eduif not have_kvm: 9486479Sgblack@eecs.umich.edu print "Info: Compatible header file <linux/kvm.h> not found, " \ 9496479Sgblack@eecs.umich.edu "disabling KVM support." 9506479Sgblack@eecs.umich.edu 9516479Sgblack@eecs.umich.edu# Check if the requested target ISA is compatible with the host 9526479Sgblack@eecs.umich.edudef is_isa_kvm_compatible(isa): 9536479Sgblack@eecs.umich.edu isa_comp_table = { 9546479Sgblack@eecs.umich.edu "arm" : ( "armv7l" ), 9556479Sgblack@eecs.umich.edu "x86" : ( "x86_64" ), 9566479Sgblack@eecs.umich.edu } 9576479Sgblack@eecs.umich.edu try: 9586479Sgblack@eecs.umich.edu import platform 9596479Sgblack@eecs.umich.edu host_isa = platform.machine() 9606479Sgblack@eecs.umich.edu except: 9616479Sgblack@eecs.umich.edu print "Warning: Failed to determine host ISA." 9626479Sgblack@eecs.umich.edu return False 9636479Sgblack@eecs.umich.edu 9646479Sgblack@eecs.umich.edu return host_isa in isa_comp_table.get(isa, []) 9656479Sgblack@eecs.umich.edu 9666479Sgblack@eecs.umich.edu 9676479Sgblack@eecs.umich.edu###################################################################### 9686479Sgblack@eecs.umich.edu# 9696479Sgblack@eecs.umich.edu# Finish the configuration 9706479Sgblack@eecs.umich.edu# 9716479Sgblack@eecs.umich.edumain = conf.Finish() 9726479Sgblack@eecs.umich.edu 9736479Sgblack@eecs.umich.edu###################################################################### 9746479Sgblack@eecs.umich.edu# 9756479Sgblack@eecs.umich.edu# Collect all non-global variables 9766479Sgblack@eecs.umich.edu# 9776479Sgblack@eecs.umich.edu 9786479Sgblack@eecs.umich.edu# Define the universe of supported ISAs 9796479Sgblack@eecs.umich.eduall_isa_list = [ ] 9806479Sgblack@eecs.umich.eduExport('all_isa_list') 9816479Sgblack@eecs.umich.edu 9826479Sgblack@eecs.umich.educlass CpuModel(object): 9836479Sgblack@eecs.umich.edu '''The CpuModel class encapsulates everything the ISA parser needs to 9846479Sgblack@eecs.umich.edu know about a particular CPU model.''' 9856479Sgblack@eecs.umich.edu 9866479Sgblack@eecs.umich.edu # Dict of available CPU model objects. Accessible as CpuModel.dict. 9876479Sgblack@eecs.umich.edu dict = {} 9886479Sgblack@eecs.umich.edu list = [] 9896479Sgblack@eecs.umich.edu defaults = [] 9906479Sgblack@eecs.umich.edu 9915040Sgblack@eecs.umich.edu # Constructor. Automatically adds models to CpuModel.dict. 9925246Sgblack@eecs.umich.edu def __init__(self, name, filename, includes, strings, default=False): 9935040Sgblack@eecs.umich.edu self.name = name # name of model 9945040Sgblack@eecs.umich.edu self.filename = filename # filename for output exec code 9955040Sgblack@eecs.umich.edu self.includes = includes # include files needed in exec file 9965040Sgblack@eecs.umich.edu # The 'strings' dict holds all the per-CPU symbols we can 9975040Sgblack@eecs.umich.edu # substitute into templates etc. 9985426Sgblack@eecs.umich.edu self.strings = strings 9995426Sgblack@eecs.umich.edu 10005426Sgblack@eecs.umich.edu # This cpu is enabled by default 10015426Sgblack@eecs.umich.edu self.default = default 10025426Sgblack@eecs.umich.edu 10035426Sgblack@eecs.umich.edu # Add self to dict 10045426Sgblack@eecs.umich.edu if name in CpuModel.dict: 10055426Sgblack@eecs.umich.edu raise AttributeError, "CpuModel '%s' already registered" % name 10065426Sgblack@eecs.umich.edu CpuModel.dict[name] = self 10075426Sgblack@eecs.umich.edu CpuModel.list.append(name) 10085040Sgblack@eecs.umich.edu 10095246Sgblack@eecs.umich.eduExport('CpuModel') 10105040Sgblack@eecs.umich.edu 10115040Sgblack@eecs.umich.edu# Sticky variables get saved in the variables file so they persist from 10125040Sgblack@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new 10135040Sgblack@eecs.umich.edu# value becomes sticky). 10145426Sgblack@eecs.umich.edusticky_vars = Variables(args=ARGUMENTS) 10155426Sgblack@eecs.umich.eduExport('sticky_vars') 10165426Sgblack@eecs.umich.edu 10175040Sgblack@eecs.umich.edu# Sticky variables that should be exported 10185040Sgblack@eecs.umich.eduexport_vars = [] 10195116Sgblack@eecs.umich.eduExport('export_vars') 10204951Sgblack@eecs.umich.edu 10215011Sgblack@eecs.umich.edu# For Ruby 10225011Sgblack@eecs.umich.eduall_protocols = [] 10235040Sgblack@eecs.umich.eduExport('all_protocols') 10245040Sgblack@eecs.umich.eduprotocol_dirs = [] 10255040Sgblack@eecs.umich.eduExport('protocol_dirs') 10265040Sgblack@eecs.umich.eduslicc_includes = [] 10276345Sgblack@eecs.umich.eduExport('slicc_includes') 10284732Sgblack@eecs.umich.edu 10295426Sgblack@eecs.umich.edu# Walk the tree and execute all SConsopts scripts that wil add to the 10305426Sgblack@eecs.umich.edu# above variables 10315426Sgblack@eecs.umich.eduif not GetOption('verbose'): 10325426Sgblack@eecs.umich.edu print "Reading SConsopts" 10335426Sgblack@eecs.umich.edufor bdir in [ base_dir ] + extras_dir_list: 10345426Sgblack@eecs.umich.edu if not isdir(bdir): 10355426Sgblack@eecs.umich.edu print "Error: directory '%s' does not exist" % bdir 10365426Sgblack@eecs.umich.edu Exit(1) 10375426Sgblack@eecs.umich.edu for root, dirs, files in os.walk(bdir): 10385426Sgblack@eecs.umich.edu if 'SConsopts' in files: 10395426Sgblack@eecs.umich.edu if GetOption('verbose'): 10405426Sgblack@eecs.umich.edu print "Reading", joinpath(root, 'SConsopts') 10416345Sgblack@eecs.umich.edu SConscript(joinpath(root, 'SConsopts')) 10425426Sgblack@eecs.umich.edu 10435040Sgblack@eecs.umich.eduall_isa_list.sort() 10445040Sgblack@eecs.umich.edu 10454823Sgblack@eecs.umich.edusticky_vars.AddVariables( 10465239Sgblack@eecs.umich.edu EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 10475239Sgblack@eecs.umich.edu ListVariable('CPU_MODELS', 'CPU models', 10485239Sgblack@eecs.umich.edu sorted(n for n,m in CpuModel.dict.iteritems() if m.default), 10495239Sgblack@eecs.umich.edu sorted(CpuModel.list)), 10505007Sgblack@eecs.umich.edu BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', 10515007Sgblack@eecs.umich.edu False), 10525040Sgblack@eecs.umich.edu BoolVariable('SS_COMPATIBLE_FP', 10535239Sgblack@eecs.umich.edu 'Make floating-point results compatible with SimpleScalar', 10545239Sgblack@eecs.umich.edu False), 10555239Sgblack@eecs.umich.edu BoolVariable('USE_SSE2', 10565239Sgblack@eecs.umich.edu 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 10575239Sgblack@eecs.umich.edu False), 10585239Sgblack@eecs.umich.edu BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock), 10595239Sgblack@eecs.umich.edu BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 10605239Sgblack@eecs.umich.edu BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False), 10614714Sgblack@eecs.umich.edu BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models', have_kvm), 10625040Sgblack@eecs.umich.edu EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None', 10635927Sgblack@eecs.umich.edu all_protocols), 10645241Sgblack@eecs.umich.edu ) 10655926Sgblack@eecs.umich.edu 10665926Sgblack@eecs.umich.edu# These variables get exported to #defines in config/*.hh (see src/SConscript). 10675926Sgblack@eecs.umich.eduexport_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 'TARGET_ISA', 'CP_ANNOTATE', 10686345Sgblack@eecs.umich.edu 'USE_POSIX_CLOCK', 'PROTOCOL', 'HAVE_PROTOBUF'] 10695926Sgblack@eecs.umich.edu 10705926Sgblack@eecs.umich.edu################################################### 10715926Sgblack@eecs.umich.edu# 10725926Sgblack@eecs.umich.edu# Define a SCons builder for configuration flag headers. 10735926Sgblack@eecs.umich.edu# 10745926Sgblack@eecs.umich.edu################################################### 10755926Sgblack@eecs.umich.edu 10765926Sgblack@eecs.umich.edu# This function generates a config header file that #defines the 10775926Sgblack@eecs.umich.edu# variable symbol to the current variable setting (0 or 1). The source 10785926Sgblack@eecs.umich.edu# operands are the name of the variable and a Value node containing the 10795926Sgblack@eecs.umich.edu# value of the variable. 10805926Sgblack@eecs.umich.edudef build_config_file(target, source, env): 10815926Sgblack@eecs.umich.edu (variable, value) = [s.get_contents() for s in source] 10825926Sgblack@eecs.umich.edu f = file(str(target[0]), 'w') 10835926Sgblack@eecs.umich.edu print >> f, '#define', variable, value 10846345Sgblack@eecs.umich.edu f.close() 10855926Sgblack@eecs.umich.edu return None 10865926Sgblack@eecs.umich.edu 10875926Sgblack@eecs.umich.edu# Combine the two functions into a scons Action object. 10885926Sgblack@eecs.umich.educonfig_action = MakeAction(build_config_file, Transform("CONFIG H", 2)) 10895926Sgblack@eecs.umich.edu 10906345Sgblack@eecs.umich.edu# The emitter munges the source & target node lists to reflect what 10915926Sgblack@eecs.umich.edu# we're really doing. 10925926Sgblack@eecs.umich.edudef config_emitter(target, source, env): 10935926Sgblack@eecs.umich.edu # extract variable name from Builder arg 10945926Sgblack@eecs.umich.edu variable = str(target[0]) 10955926Sgblack@eecs.umich.edu # True target is config header file 10965926Sgblack@eecs.umich.edu target = joinpath('config', variable.lower() + '.hh') 10975926Sgblack@eecs.umich.edu val = env[variable] 10985926Sgblack@eecs.umich.edu if isinstance(val, bool): 10995926Sgblack@eecs.umich.edu # Force value to 0/1 11005296Sgblack@eecs.umich.edu val = int(val) 11015296Sgblack@eecs.umich.edu elif isinstance(val, str): 11025296Sgblack@eecs.umich.edu val = '"' + val + '"' 11036345Sgblack@eecs.umich.edu 11045296Sgblack@eecs.umich.edu # Sources are variable name & value (packaged in SCons Value nodes) 11055924Sgblack@eecs.umich.edu return ([target], [Value(variable), Value(val)]) 11065296Sgblack@eecs.umich.edu 11075296Sgblack@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action) 11085934Sgblack@eecs.umich.edu 11095296Sgblack@eecs.umich.edumain.Append(BUILDERS = { 'ConfigFile' : config_builder }) 11105296Sgblack@eecs.umich.edu 11115296Sgblack@eecs.umich.edu# libelf build is shared across all configs in the build root. 11125241Sgblack@eecs.umich.edumain.SConscript('ext/libelf/SConscript', 11135241Sgblack@eecs.umich.edu variant_dir = joinpath(build_root, 'libelf')) 11145241Sgblack@eecs.umich.edu 11156345Sgblack@eecs.umich.edu# gzstream build is shared across all configs in the build root. 11165241Sgblack@eecs.umich.edumain.SConscript('ext/gzstream/SConscript', 11175241Sgblack@eecs.umich.edu variant_dir = joinpath(build_root, 'gzstream')) 11185241Sgblack@eecs.umich.edu 11195241Sgblack@eecs.umich.edu# libfdt build is shared across all configs in the build root. 11205241Sgblack@eecs.umich.edumain.SConscript('ext/libfdt/SConscript', 11215241Sgblack@eecs.umich.edu variant_dir = joinpath(build_root, 'libfdt')) 11225241Sgblack@eecs.umich.edu 11235241Sgblack@eecs.umich.edu# fputils build is shared across all configs in the build root. 11245241Sgblack@eecs.umich.edumain.SConscript('ext/fputils/SConscript', 11255241Sgblack@eecs.umich.edu variant_dir = joinpath(build_root, 'fputils')) 11265241Sgblack@eecs.umich.edu 11275241Sgblack@eecs.umich.edu################################################### 11285241Sgblack@eecs.umich.edu# 11295241Sgblack@eecs.umich.edu# This function is used to set up a directory with switching headers 11305241Sgblack@eecs.umich.edu# 11315241Sgblack@eecs.umich.edu################################################### 11325241Sgblack@eecs.umich.edu 11335241Sgblack@eecs.umich.edumain['ALL_ISA_LIST'] = all_isa_list 11345241Sgblack@eecs.umich.edudef make_switching_dir(dname, switch_headers, env): 11355241Sgblack@eecs.umich.edu # Generate the header. target[0] is the full path of the output 11365241Sgblack@eecs.umich.edu # header to generate. 'source' is a dummy variable, since we get the 11375241Sgblack@eecs.umich.edu # list of ISAs from env['ALL_ISA_LIST']. 11385241Sgblack@eecs.umich.edu def gen_switch_hdr(target, source, env): 11395241Sgblack@eecs.umich.edu fname = str(target[0]) 11405241Sgblack@eecs.umich.edu f = open(fname, 'w') 11415241Sgblack@eecs.umich.edu isa = env['TARGET_ISA'].lower() 11425241Sgblack@eecs.umich.edu print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) 11435241Sgblack@eecs.umich.edu f.close() 11445241Sgblack@eecs.umich.edu 11455241Sgblack@eecs.umich.edu # Build SCons Action object. 'varlist' specifies env vars that this 11465241Sgblack@eecs.umich.edu # action depends on; when env['ALL_ISA_LIST'] changes these actions 11475241Sgblack@eecs.umich.edu # should get re-executed. 11485241Sgblack@eecs.umich.edu switch_hdr_action = MakeAction(gen_switch_hdr, 11495241Sgblack@eecs.umich.edu Transform("GENERATE"), varlist=['ALL_ISA_LIST']) 11505241Sgblack@eecs.umich.edu 11515241Sgblack@eecs.umich.edu # Instantiate actions for each header 11525241Sgblack@eecs.umich.edu for hdr in switch_headers: 11535241Sgblack@eecs.umich.edu env.Command(hdr, [], switch_hdr_action) 11545241Sgblack@eecs.umich.eduExport('make_switching_dir') 11555241Sgblack@eecs.umich.edu 11565241Sgblack@eecs.umich.edu################################################### 11575241Sgblack@eecs.umich.edu# 11585241Sgblack@eecs.umich.edu# Define build environments for selected configurations. 11595241Sgblack@eecs.umich.edu# 11605241Sgblack@eecs.umich.edu################################################### 11615241Sgblack@eecs.umich.edu 11625241Sgblack@eecs.umich.edufor variant_path in variant_paths: 11635290Sgblack@eecs.umich.edu print "Building in", variant_path 11645294Sgblack@eecs.umich.edu 11655672Sgblack@eecs.umich.edu # Make a copy of the build-root environment to use for this config. 11665294Sgblack@eecs.umich.edu env = main.Clone() 11675290Sgblack@eecs.umich.edu env['BUILDDIR'] = variant_path 11685294Sgblack@eecs.umich.edu 11696345Sgblack@eecs.umich.edu # variant_dir is the tail component of build path, and is used to 11705294Sgblack@eecs.umich.edu # determine the build parameters (e.g., 'ALPHA_SE') 11715294Sgblack@eecs.umich.edu (build_root, variant_dir) = splitpath(variant_path) 11725290Sgblack@eecs.umich.edu 11735294Sgblack@eecs.umich.edu # Set env variables according to the build directory config. 11745290Sgblack@eecs.umich.edu sticky_vars.files = [] 11755290Sgblack@eecs.umich.edu # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in 11765294Sgblack@eecs.umich.edu # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke 11775290Sgblack@eecs.umich.edu # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings. 11785294Sgblack@eecs.umich.edu current_vars_file = joinpath(build_root, 'variables', variant_dir) 11795294Sgblack@eecs.umich.edu if isfile(current_vars_file): 11805294Sgblack@eecs.umich.edu sticky_vars.files.append(current_vars_file) 11815294Sgblack@eecs.umich.edu print "Using saved variables file %s" % current_vars_file 11825294Sgblack@eecs.umich.edu else: 11835294Sgblack@eecs.umich.edu # Build dir-specific variables file doesn't exist. 11845294Sgblack@eecs.umich.edu 11855294Sgblack@eecs.umich.edu # Make sure the directory is there so we can create it later 11865905Sgblack@eecs.umich.edu opt_dir = dirname(current_vars_file) 11875905Sgblack@eecs.umich.edu if not isdir(opt_dir): 11885905Sgblack@eecs.umich.edu mkdir(opt_dir) 11895905Sgblack@eecs.umich.edu 11905905Sgblack@eecs.umich.edu # Get default build variables from source tree. Variables are 11915294Sgblack@eecs.umich.edu # normally determined by name of $VARIANT_DIR, but can be 11925294Sgblack@eecs.umich.edu # overridden by '--default=' arg on command line. 11935932Sgblack@eecs.umich.edu default = GetOption('default') 11945294Sgblack@eecs.umich.edu opts_dir = joinpath(main.root.abspath, 'build_opts') 11955294Sgblack@eecs.umich.edu if default: 11965294Sgblack@eecs.umich.edu default_vars_files = [joinpath(build_root, 'variables', default), 11975294Sgblack@eecs.umich.edu joinpath(opts_dir, default)] 11985932Sgblack@eecs.umich.edu else: 11995294Sgblack@eecs.umich.edu default_vars_files = [joinpath(opts_dir, variant_dir)] 12005294Sgblack@eecs.umich.edu existing_files = filter(isfile, default_vars_files) 12015427Sgblack@eecs.umich.edu if existing_files: 12025427Sgblack@eecs.umich.edu default_vars_file = existing_files[0] 12035932Sgblack@eecs.umich.edu sticky_vars.files.append(default_vars_file) 12045427Sgblack@eecs.umich.edu print "Variables file %s not found,\n using defaults in %s" \ 12055427Sgblack@eecs.umich.edu % (current_vars_file, default_vars_file) 12065294Sgblack@eecs.umich.edu else: 12075294Sgblack@eecs.umich.edu print "Error: cannot find variables file %s or " \ 12085932Sgblack@eecs.umich.edu "default file(s) %s" \ 12095294Sgblack@eecs.umich.edu % (current_vars_file, ' or '.join(default_vars_files)) 12105294Sgblack@eecs.umich.edu Exit(1) 12115682Sgblack@eecs.umich.edu 12125682Sgblack@eecs.umich.edu # Apply current variable settings to env 12136345Sgblack@eecs.umich.edu sticky_vars.Update(env) 12146345Sgblack@eecs.umich.edu 12155682Sgblack@eecs.umich.edu help_texts["local_vars"] += \ 12165682Sgblack@eecs.umich.edu "Build variables for %s:\n" % variant_dir \ 12175682Sgblack@eecs.umich.edu + sticky_vars.GenerateHelpText(env) 12185682Sgblack@eecs.umich.edu 12195682Sgblack@eecs.umich.edu # Process variable settings. 12205682Sgblack@eecs.umich.edu 12216345Sgblack@eecs.umich.edu if not have_fenv and env['USE_FENV']: 12226345Sgblack@eecs.umich.edu print "Warning: <fenv.h> not available; " \ 12235682Sgblack@eecs.umich.edu "forcing USE_FENV to False in", variant_dir + "." 12245682Sgblack@eecs.umich.edu env['USE_FENV'] = False 12255682Sgblack@eecs.umich.edu 12265682Sgblack@eecs.umich.edu if not env['USE_FENV']: 12275428Sgblack@eecs.umich.edu print "Warning: No IEEE FP rounding mode control in", variant_dir + "." 12285428Sgblack@eecs.umich.edu print " FP results may deviate slightly from other platforms." 12295428Sgblack@eecs.umich.edu 12305428Sgblack@eecs.umich.edu if env['EFENCE']: 12315428Sgblack@eecs.umich.edu env.Append(LIBS=['efence']) 12325294Sgblack@eecs.umich.edu 12335424Sgblack@eecs.umich.edu if env['USE_KVM']: 12345433Sgblack@eecs.umich.edu if not have_kvm: 12355433Sgblack@eecs.umich.edu print "Warning: Can not enable KVM, host seems to lack KVM support" 12365433Sgblack@eecs.umich.edu env['USE_KVM'] = False 12375294Sgblack@eecs.umich.edu elif not have_posix_timers: 12385428Sgblack@eecs.umich.edu print "Warning: Can not enable KVM, host seems to lack support " \ 12395428Sgblack@eecs.umich.edu "for POSIX timers" 12405428Sgblack@eecs.umich.edu env['USE_KVM'] = False 12415428Sgblack@eecs.umich.edu elif not is_isa_kvm_compatible(env['TARGET_ISA']): 12425428Sgblack@eecs.umich.edu print "Info: KVM support disabled due to unsupported host and " \ 12436060Sgblack@eecs.umich.edu "target ISA combination" 12446060Sgblack@eecs.umich.edu env['USE_KVM'] = False 12456060Sgblack@eecs.umich.edu 12466060Sgblack@eecs.umich.edu # Save sticky variable settings back to current variables file 12476060Sgblack@eecs.umich.edu sticky_vars.Save(current_vars_file, env) 12486060Sgblack@eecs.umich.edu 12495428Sgblack@eecs.umich.edu if env['USE_SSE2']: 12505428Sgblack@eecs.umich.edu env.Append(CCFLAGS=['-msse2']) 12515428Sgblack@eecs.umich.edu 12525428Sgblack@eecs.umich.edu # The src/SConscript file sets up the build rules in 'env' according 12535428Sgblack@eecs.umich.edu # to the configured variables. It returns a list of environments, 12545855Sgblack@eecs.umich.edu # one for each variant build (debug, opt, etc.) 12555853Sgblack@eecs.umich.edu envList = SConscript('src/SConscript', variant_dir = variant_path, 12565674Sgblack@eecs.umich.edu exports = 'env') 12575857Sgblack@eecs.umich.edu 12586058Sgblack@eecs.umich.edu # Set up the regression tests for each build. 12595674Sgblack@eecs.umich.edu for e in envList: 12605855Sgblack@eecs.umich.edu SConscript('tests/SConscript', 12615855Sgblack@eecs.umich.edu variant_dir = joinpath(variant_path, 'tests', e.Label), 12625853Sgblack@eecs.umich.edu exports = { 'env' : e }, duplicate = False) 12635861Snate@binkert.org 12645853Sgblack@eecs.umich.edu# base help text 12655853Sgblack@eecs.umich.eduHelp(''' 12665853Sgblack@eecs.umich.eduUsage: scons [scons options] [build variables] [target(s)] 12675674Sgblack@eecs.umich.edu 12685428Sgblack@eecs.umich.eduExtra scons options: 12695433Sgblack@eecs.umich.edu%(options)s 12705433Sgblack@eecs.umich.edu 12715857Sgblack@eecs.umich.eduGlobal build variables: 12725433Sgblack@eecs.umich.edu%(global_vars)s 12735433Sgblack@eecs.umich.edu 12745673Sgblack@eecs.umich.edu%(local_vars)s 12755673Sgblack@eecs.umich.edu''' % help_texts) 12765433Sgblack@eecs.umich.edu