SConstruct revision 13020
1955SN/A# -*- mode:python -*-
2955SN/A
312230Sgiacomo.travaglini@arm.com# Copyright (c) 2013, 2015-2017 ARM Limited
49812Sandreas.hansson@arm.com# All rights reserved.
59812Sandreas.hansson@arm.com#
69812Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall
79812Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual
89812Sandreas.hansson@arm.com# property including but not limited to intellectual property relating
99812Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software
109812Sandreas.hansson@arm.com# licensed hereunder.  You may use the software subject to the license
119812Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated
129812Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software,
139812Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form.
149812Sandreas.hansson@arm.com#
157816Ssteve.reinhardt@amd.com# Copyright (c) 2011 Advanced Micro Devices, Inc.
165871Snate@binkert.org# Copyright (c) 2009 The Hewlett-Packard Development Company
171762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
18955SN/A# All rights reserved.
19955SN/A#
20955SN/A# Redistribution and use in source and binary forms, with or without
21955SN/A# modification, are permitted provided that the following conditions are
22955SN/A# met: redistributions of source code must retain the above copyright
23955SN/A# notice, this list of conditions and the following disclaimer;
24955SN/A# redistributions in binary form must reproduce the above copyright
25955SN/A# notice, this list of conditions and the following disclaimer in the
26955SN/A# documentation and/or other materials provided with the distribution;
27955SN/A# neither the name of the copyright holders nor the names of its
28955SN/A# contributors may be used to endorse or promote products derived from
29955SN/A# this software without specific prior written permission.
30955SN/A#
31955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
422665Ssaidi@eecs.umich.edu#
432665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
445863Snate@binkert.org#          Nathan Binkert
45955SN/A
46955SN/A###################################################
47955SN/A#
48955SN/A# SCons top-level build description (SConstruct) file.
49955SN/A#
508878Ssteve.reinhardt@amd.com# While in this directory ('gem5'), just type 'scons' to build the default
512632Sstever@eecs.umich.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
528878Ssteve.reinhardt@amd.com# to build some other configuration (e.g., 'build/ALPHA/gem5.opt' for
532632Sstever@eecs.umich.edu# the optimized full-system version).
54955SN/A#
558878Ssteve.reinhardt@amd.com# You can build gem5 in a different directory as long as there is a
562632Sstever@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path.  The build system
572761Sstever@eecs.umich.edu# expects that all configs under the same build directory are being
582632Sstever@eecs.umich.edu# built for the same host system.
592632Sstever@eecs.umich.edu#
602632Sstever@eecs.umich.edu# Examples:
612761Sstever@eecs.umich.edu#
622761Sstever@eecs.umich.edu#   The following two commands are equivalent.  The '-u' option tells
632761Sstever@eecs.umich.edu#   scons to search up the directory tree for this SConstruct file.
648878Ssteve.reinhardt@amd.com#   % cd <path-to-src>/gem5 ; scons build/ALPHA/gem5.debug
658878Ssteve.reinhardt@amd.com#   % cd <path-to-src>/gem5/build/ALPHA; scons -u gem5.debug
662761Sstever@eecs.umich.edu#
672761Sstever@eecs.umich.edu#   The following two commands are equivalent and demonstrate building
682761Sstever@eecs.umich.edu#   in a directory outside of the source tree.  The '-C' option tells
692761Sstever@eecs.umich.edu#   scons to chdir to the specified directory to find this SConstruct
702761Sstever@eecs.umich.edu#   file.
718878Ssteve.reinhardt@amd.com#   % cd <path-to-src>/gem5 ; scons /local/foo/build/ALPHA/gem5.debug
728878Ssteve.reinhardt@amd.com#   % cd /local/foo/build/ALPHA; scons -C <path-to-src>/gem5 gem5.debug
732632Sstever@eecs.umich.edu#
742632Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
758878Ssteve.reinhardt@amd.com# 'gem5' directory (or use -u or -C to tell scons where to find this
768878Ssteve.reinhardt@amd.com# file), you can use 'scons -h' to print all the gem5-specific build
772632Sstever@eecs.umich.edu# options as well.
78955SN/A#
79955SN/A###################################################
80955SN/A
815863Snate@binkert.orgfrom __future__ import print_function
825863Snate@binkert.org
835863Snate@binkert.org# Global Python includes
845863Snate@binkert.orgimport itertools
855863Snate@binkert.orgimport os
865863Snate@binkert.orgimport re
875863Snate@binkert.orgimport shutil
885863Snate@binkert.orgimport subprocess
895863Snate@binkert.orgimport sys
905863Snate@binkert.org
915863Snate@binkert.orgfrom os import mkdir, environ
928878Ssteve.reinhardt@amd.comfrom os.path import abspath, basename, dirname, expanduser, normpath
935863Snate@binkert.orgfrom os.path import exists,  isdir, isfile
945863Snate@binkert.orgfrom os.path import join as joinpath, split as splitpath
955863Snate@binkert.org
9612178Sprosenfeld@micron.com# SCons includes
975863Snate@binkert.orgimport SCons
9812178Sprosenfeld@micron.comimport SCons.Node
995863Snate@binkert.org
1005863Snate@binkert.orgfrom m5.util import compareVersions, readCommand
1015863Snate@binkert.org
1029812Sandreas.hansson@arm.comhelp_texts = {
1039812Sandreas.hansson@arm.com    "options" : "",
1045863Snate@binkert.org    "global_vars" : "",
1055863Snate@binkert.org    "local_vars" : ""
1068878Ssteve.reinhardt@amd.com}
1075863Snate@binkert.org
1085863Snate@binkert.orgExport("help_texts")
1095863Snate@binkert.org
1106654Snate@binkert.org
11110196SCurtis.Dunham@arm.com# There's a bug in scons in that (1) by default, the help texts from
112955SN/A# AddOption() are supposed to be displayed when you type 'scons -h'
1135396Ssaidi@eecs.umich.edu# and (2) you can override the help displayed by 'scons -h' using the
11411401Sandreas.sandberg@arm.com# Help() function, but these two features are incompatible: once
1155863Snate@binkert.org# you've overridden the help text using Help(), there's no way to get
1165863Snate@binkert.org# at the help texts from AddOptions.  See:
1174202Sbinkertn@umich.edu#     http://scons.tigris.org/issues/show_bug.cgi?id=2356
1185863Snate@binkert.org#     http://scons.tigris.org/issues/show_bug.cgi?id=2611
1195863Snate@binkert.org# This hack lets us extract the help text from AddOptions and
1205863Snate@binkert.org# re-inject it via Help().  Ideally someday this bug will be fixed and
1215863Snate@binkert.org# we can just use AddOption directly.
122955SN/Adef AddLocalOption(*args, **kwargs):
1236654Snate@binkert.org    col_width = 30
1245273Sstever@gmail.com
1255871Snate@binkert.org    help = "  " + ", ".join(args)
1265273Sstever@gmail.com    if "help" in kwargs:
1276655Snate@binkert.org        length = len(help)
1288878Ssteve.reinhardt@amd.com        if length >= col_width:
1296655Snate@binkert.org            help += "\n" + " " * col_width
1306655Snate@binkert.org        else:
1319219Spower.jg@gmail.com            help += " " * (col_width - length)
1326655Snate@binkert.org        help += kwargs["help"]
1335871Snate@binkert.org    help_texts["options"] += help + "\n"
1346654Snate@binkert.org
1358947Sandreas.hansson@arm.com    AddOption(*args, **kwargs)
1365396Ssaidi@eecs.umich.edu
1378120Sgblack@eecs.umich.eduAddLocalOption('--colors', dest='use_colors', action='store_true',
1388120Sgblack@eecs.umich.edu               help="Add color to abbreviated scons output")
1398120Sgblack@eecs.umich.eduAddLocalOption('--no-colors', dest='use_colors', action='store_false',
1408120Sgblack@eecs.umich.edu               help="Don't add color to abbreviated scons output")
1418120Sgblack@eecs.umich.eduAddLocalOption('--with-cxx-config', dest='with_cxx_config',
1428120Sgblack@eecs.umich.edu               action='store_true',
1438120Sgblack@eecs.umich.edu               help="Build with support for C++-based configuration")
1448120Sgblack@eecs.umich.eduAddLocalOption('--default', dest='default', type='string', action='store',
1458879Ssteve.reinhardt@amd.com               help='Override which build_opts file to use for defaults')
1468879Ssteve.reinhardt@amd.comAddLocalOption('--ignore-style', dest='ignore_style', action='store_true',
1478879Ssteve.reinhardt@amd.com               help='Disable style checking hooks')
1488879Ssteve.reinhardt@amd.comAddLocalOption('--no-lto', dest='no_lto', action='store_true',
1498879Ssteve.reinhardt@amd.com               help='Disable Link-Time Optimization for fast')
1508879Ssteve.reinhardt@amd.comAddLocalOption('--force-lto', dest='force_lto', action='store_true',
1518879Ssteve.reinhardt@amd.com               help='Use Link-Time Optimization instead of partial linking' +
1528879Ssteve.reinhardt@amd.com                    ' when the compiler doesn\'t support using them together.')
1538879Ssteve.reinhardt@amd.comAddLocalOption('--update-ref', dest='update_ref', action='store_true',
1548879Ssteve.reinhardt@amd.com               help='Update test reference outputs')
1558879Ssteve.reinhardt@amd.comAddLocalOption('--verbose', dest='verbose', action='store_true',
1568879Ssteve.reinhardt@amd.com               help='Print full tool command lines')
1578879Ssteve.reinhardt@amd.comAddLocalOption('--without-python', dest='without_python',
1588120Sgblack@eecs.umich.edu               action='store_true',
1598120Sgblack@eecs.umich.edu               help='Build without Python configuration support')
1608120Sgblack@eecs.umich.eduAddLocalOption('--without-tcmalloc', dest='without_tcmalloc',
1618120Sgblack@eecs.umich.edu               action='store_true',
1628120Sgblack@eecs.umich.edu               help='Disable linking against tcmalloc')
1638120Sgblack@eecs.umich.eduAddLocalOption('--with-ubsan', dest='with_ubsan', action='store_true',
1648120Sgblack@eecs.umich.edu               help='Build with Undefined Behavior Sanitizer if available')
1658120Sgblack@eecs.umich.eduAddLocalOption('--with-asan', dest='with_asan', action='store_true',
1668120Sgblack@eecs.umich.edu               help='Build with Address Sanitizer if available')
1678120Sgblack@eecs.umich.edu
1688120Sgblack@eecs.umich.eduif GetOption('no_lto') and GetOption('force_lto'):
1698120Sgblack@eecs.umich.edu    print('--no-lto and --force-lto are mutually exclusive')
1708120Sgblack@eecs.umich.edu    Exit(1)
1718120Sgblack@eecs.umich.edu
1728879Ssteve.reinhardt@amd.com########################################################################
1738879Ssteve.reinhardt@amd.com#
1748879Ssteve.reinhardt@amd.com# Set up the main build environment.
1758879Ssteve.reinhardt@amd.com#
17610458Sandreas.hansson@arm.com########################################################################
17710458Sandreas.hansson@arm.com
17810458Sandreas.hansson@arm.commain = Environment()
1798879Ssteve.reinhardt@amd.com
1808879Ssteve.reinhardt@amd.comfrom gem5_scons import Transform
1818879Ssteve.reinhardt@amd.comfrom gem5_scons.util import get_termcap
1828879Ssteve.reinhardt@amd.comtermcap = get_termcap()
1839227Sandreas.hansson@arm.com
1849227Sandreas.hansson@arm.commain_dict_keys = main.Dictionary().keys()
18512063Sgabeblack@google.com
18612063Sgabeblack@google.com# Check that we have a C/C++ compiler
18712063Sgabeblack@google.comif not ('CC' in main_dict_keys and 'CXX' in main_dict_keys):
1888879Ssteve.reinhardt@amd.com    print("No C++ compiler installed (package g++ on Ubuntu and RedHat)")
1898879Ssteve.reinhardt@amd.com    Exit(1)
1908879Ssteve.reinhardt@amd.com
1918879Ssteve.reinhardt@amd.com###################################################
19210453SAndrew.Bardsley@arm.com#
19310453SAndrew.Bardsley@arm.com# Figure out which configurations to set up based on the path(s) of
19410453SAndrew.Bardsley@arm.com# the target(s).
19510456SCurtis.Dunham@arm.com#
19610456SCurtis.Dunham@arm.com###################################################
19710456SCurtis.Dunham@arm.com
19810457Sandreas.hansson@arm.com# Find default configuration & binary.
19910457Sandreas.hansson@arm.comDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA/gem5.debug'))
20011342Sandreas.hansson@arm.com
20111342Sandreas.hansson@arm.com# helper function: find last occurrence of element in list
2028120Sgblack@eecs.umich.edudef rfind(l, elt, offs = -1):
20312063Sgabeblack@google.com    for i in range(len(l)+offs, 0, -1):
20412063Sgabeblack@google.com        if l[i] == elt:
20512063Sgabeblack@google.com            return i
20612063Sgabeblack@google.com    raise ValueError, "element not found"
2078947Sandreas.hansson@arm.com
2087816Ssteve.reinhardt@amd.com# Take a list of paths (or SCons Nodes) and return a list with all
2095871Snate@binkert.org# paths made absolute and ~-expanded.  Paths will be interpreted
2105871Snate@binkert.org# relative to the launch directory unless a different root is provided
2116121Snate@binkert.orgdef makePathListAbsolute(path_list, root=GetLaunchDir()):
2125871Snate@binkert.org    return [abspath(joinpath(root, expanduser(str(p))))
2135871Snate@binkert.org            for p in path_list]
2149926Sstan.czerniawski@arm.com
2159926Sstan.czerniawski@arm.com# Each target must have 'build' in the interior of the path; the
2169119Sandreas.hansson@arm.com# directory below this will determine the build parameters.  For
21710068Sandreas.hansson@arm.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
21811989Sandreas.sandberg@arm.com# recognize that ALPHA_SE specifies the configuration because it
219955SN/A# follow 'build' in the build path.
2209416SAndreas.Sandberg@ARM.com
22111342Sandreas.hansson@arm.com# The funky assignment to "[:]" is needed to replace the list contents
22211212Sjoseph.gross@amd.com# in place rather than reassign the symbol to a new list, which
22311212Sjoseph.gross@amd.com# doesn't work (obviously!).
22411212Sjoseph.gross@amd.comBUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS)
22511212Sjoseph.gross@amd.com
22611212Sjoseph.gross@amd.com# Generate a list of the unique build roots and configs that the
2279416SAndreas.Sandberg@ARM.com# collected targets reference.
2289416SAndreas.Sandberg@ARM.comvariant_paths = []
2295871Snate@binkert.orgbuild_root = None
23010584Sandreas.hansson@arm.comfor t in BUILD_TARGETS:
2319416SAndreas.Sandberg@ARM.com    path_dirs = t.split('/')
2329416SAndreas.Sandberg@ARM.com    try:
2335871Snate@binkert.org        build_top = rfind(path_dirs, 'build', -2)
234955SN/A    except:
23510671Sandreas.hansson@arm.com        print("Error: no non-leaf 'build' dir found on target path", t)
23610671Sandreas.hansson@arm.com        Exit(1)
23710671Sandreas.hansson@arm.com    this_build_root = joinpath('/',*path_dirs[:build_top+1])
23810671Sandreas.hansson@arm.com    if not build_root:
2398881Smarc.orr@gmail.com        build_root = this_build_root
2406121Snate@binkert.org    else:
2416121Snate@binkert.org        if this_build_root != build_root:
2421533SN/A            print("Error: build targets not under same build root\n"
2439239Sandreas.hansson@arm.com                  "  %s\n  %s" % (build_root, this_build_root))
2449239Sandreas.hansson@arm.com            Exit(1)
2459239Sandreas.hansson@arm.com    variant_path = joinpath('/',*path_dirs[:build_top+2])
2469239Sandreas.hansson@arm.com    if variant_path not in variant_paths:
2479239Sandreas.hansson@arm.com        variant_paths.append(variant_path)
2489239Sandreas.hansson@arm.com
2499239Sandreas.hansson@arm.com# Make sure build_root exists (might not if this is the first build there)
2506655Snate@binkert.orgif not isdir(build_root):
2516655Snate@binkert.org    mkdir(build_root)
2526655Snate@binkert.orgmain['BUILDROOT'] = build_root
2536655Snate@binkert.org
2545871Snate@binkert.orgExport('main')
2555871Snate@binkert.org
2565863Snate@binkert.orgmain.SConsignFile(joinpath(build_root, "sconsign"))
2575871Snate@binkert.org
2588878Ssteve.reinhardt@amd.com# Default duplicate option is to use hard links, but this messes up
2595871Snate@binkert.org# when you use emacs to edit a file in the target dir, as emacs moves
2605871Snate@binkert.org# file to file~ then copies to file, breaking the link.  Symbolic
2615871Snate@binkert.org# (soft) links work better.
2625863Snate@binkert.orgmain.SetOption('duplicate', 'soft-copy')
2636121Snate@binkert.org
2645863Snate@binkert.org#
26511408Sandreas.sandberg@arm.com# Set up global sticky variables... these are common to an entire build
26611408Sandreas.sandberg@arm.com# tree (not specific to a particular build like ALPHA_SE)
2678336Ssteve.reinhardt@amd.com#
26811469SCurtis.Dunham@arm.com
26911469SCurtis.Dunham@arm.comglobal_vars_file = joinpath(build_root, 'variables.global')
2708336Ssteve.reinhardt@amd.com
2714678Snate@binkert.orgglobal_vars = Variables(global_vars_file, args=ARGUMENTS)
27211887Sandreas.sandberg@arm.com
27311887Sandreas.sandberg@arm.comglobal_vars.AddVariables(
27411887Sandreas.sandberg@arm.com    ('CC', 'C compiler', environ.get('CC', main['CC'])),
27511887Sandreas.sandberg@arm.com    ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
27611887Sandreas.sandberg@arm.com    ('PROTOC', 'protoc tool', environ.get('PROTOC', 'protoc')),
27711887Sandreas.sandberg@arm.com    ('BATCH', 'Use batch pool for build and tests', False),
27811887Sandreas.sandberg@arm.com    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
27911887Sandreas.sandberg@arm.com    ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
28011887Sandreas.sandberg@arm.com    ('EXTRAS', 'Add extra directories to the compilation', '')
28111887Sandreas.sandberg@arm.com    )
28211887Sandreas.sandberg@arm.com
28311408Sandreas.sandberg@arm.com# Update main environment with values from ARGUMENTS & global_vars_file
28411401Sandreas.sandberg@arm.comglobal_vars.Update(main)
28511401Sandreas.sandberg@arm.comhelp_texts["global_vars"] += global_vars.GenerateHelpText(main)
28611401Sandreas.sandberg@arm.com
28711401Sandreas.sandberg@arm.com# Save sticky variable settings back to current variables file
28811401Sandreas.sandberg@arm.comglobal_vars.Save(global_vars_file, main)
28911401Sandreas.sandberg@arm.com
2908336Ssteve.reinhardt@amd.com# Parse EXTRAS variable to build list of all directories where we're
2918336Ssteve.reinhardt@amd.com# look for sources etc.  This list is exported as extras_dir_list.
2928336Ssteve.reinhardt@amd.combase_dir = main.srcdir.abspath
2934678Snate@binkert.orgif main['EXTRAS']:
29411401Sandreas.sandberg@arm.com    extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':'))
2954678Snate@binkert.orgelse:
2964678Snate@binkert.org    extras_dir_list = []
29711401Sandreas.sandberg@arm.com
29811401Sandreas.sandberg@arm.comExport('base_dir')
2998336Ssteve.reinhardt@amd.comExport('extras_dir_list')
3004678Snate@binkert.org
3018336Ssteve.reinhardt@amd.com# the ext directory should be on the #includes path
3028336Ssteve.reinhardt@amd.commain.Append(CPPPATH=[Dir('ext')])
3038336Ssteve.reinhardt@amd.com
3048336Ssteve.reinhardt@amd.com# Add shared top-level headers
3058336Ssteve.reinhardt@amd.commain.Prepend(CPPPATH=Dir('include'))
3068336Ssteve.reinhardt@amd.com
3075871Snate@binkert.orgif GetOption('verbose'):
3085871Snate@binkert.org    def MakeAction(action, string, *args, **kwargs):
3098336Ssteve.reinhardt@amd.com        return Action(action, *args, **kwargs)
31011408Sandreas.sandberg@arm.comelse:
31111408Sandreas.sandberg@arm.com    MakeAction = Action
31211408Sandreas.sandberg@arm.com    main['CCCOMSTR']        = Transform("CC")
31311408Sandreas.sandberg@arm.com    main['CXXCOMSTR']       = Transform("CXX")
31411408Sandreas.sandberg@arm.com    main['ASCOMSTR']        = Transform("AS")
31511408Sandreas.sandberg@arm.com    main['ARCOMSTR']        = Transform("AR", 0)
31611408Sandreas.sandberg@arm.com    main['LINKCOMSTR']      = Transform("LINK", 0)
3178336Ssteve.reinhardt@amd.com    main['SHLINKCOMSTR']    = Transform("SHLINK", 0)
31811401Sandreas.sandberg@arm.com    main['RANLIBCOMSTR']    = Transform("RANLIB", 0)
31911401Sandreas.sandberg@arm.com    main['M4COMSTR']        = Transform("M4")
32011401Sandreas.sandberg@arm.com    main['SHCCCOMSTR']      = Transform("SHCC")
3215871Snate@binkert.org    main['SHCXXCOMSTR']     = Transform("SHCXX")
3228336Ssteve.reinhardt@amd.comExport('MakeAction')
3238336Ssteve.reinhardt@amd.com
32411401Sandreas.sandberg@arm.com# Initialize the Link-Time Optimization (LTO) flags
32511401Sandreas.sandberg@arm.commain['LTO_CCFLAGS'] = []
32611401Sandreas.sandberg@arm.commain['LTO_LDFLAGS'] = []
32711401Sandreas.sandberg@arm.com
32811401Sandreas.sandberg@arm.com# According to the readme, tcmalloc works best if the compiler doesn't
3294678Snate@binkert.org# assume that we're using the builtin malloc and friends. These flags
3305871Snate@binkert.org# are compiler-specific, so we need to set them after we detect which
3314678Snate@binkert.org# compiler we're using.
33211401Sandreas.sandberg@arm.commain['TCMALLOC_CCFLAGS'] = []
33311401Sandreas.sandberg@arm.com
33411401Sandreas.sandberg@arm.comCXX_version = readCommand([main['CXX'],'--version'], exception=False)
33511401Sandreas.sandberg@arm.comCXX_V = readCommand([main['CXX'],'-V'], exception=False)
33611401Sandreas.sandberg@arm.com
33711401Sandreas.sandberg@arm.commain['GCC'] = CXX_version and CXX_version.find('g++') >= 0
33811401Sandreas.sandberg@arm.commain['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
33911401Sandreas.sandberg@arm.comif main['GCC'] + main['CLANG'] > 1:
34011401Sandreas.sandberg@arm.com    print('Error: How can we have two at the same time?')
34111401Sandreas.sandberg@arm.com    Exit(1)
34211401Sandreas.sandberg@arm.com
34311401Sandreas.sandberg@arm.com# Set up default C++ compiler flags
34411450Sandreas.sandberg@arm.comif main['GCC'] or main['CLANG']:
34511450Sandreas.sandberg@arm.com    # As gcc and clang share many flags, do the common parts here
34611450Sandreas.sandberg@arm.com    main.Append(CCFLAGS=['-pipe'])
34711450Sandreas.sandberg@arm.com    main.Append(CCFLAGS=['-fno-strict-aliasing'])
34811450Sandreas.sandberg@arm.com    # Enable -Wall and -Wextra and then disable the few warnings that
34911450Sandreas.sandberg@arm.com    # we consistently violate
35011450Sandreas.sandberg@arm.com    main.Append(CCFLAGS=['-Wall', '-Wundef', '-Wextra',
35111450Sandreas.sandberg@arm.com                         '-Wno-sign-compare', '-Wno-unused-parameter'])
35211450Sandreas.sandberg@arm.com    # We always compile using C++11
35311450Sandreas.sandberg@arm.com    main.Append(CXXFLAGS=['-std=c++11'])
35411450Sandreas.sandberg@arm.com    if sys.platform.startswith('freebsd'):
35511401Sandreas.sandberg@arm.com        main.Append(CCFLAGS=['-I/usr/local/include'])
35611450Sandreas.sandberg@arm.com        main.Append(CXXFLAGS=['-I/usr/local/include'])
35711450Sandreas.sandberg@arm.com
35811450Sandreas.sandberg@arm.com    main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '')
35911401Sandreas.sandberg@arm.com    main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}')
36011450Sandreas.sandberg@arm.com    main['PLINKFLAGS'] = main.subst('${LINKFLAGS}')
36111401Sandreas.sandberg@arm.com    shared_partial_flags = ['-r', '-nostdlib']
3628336Ssteve.reinhardt@amd.com    main.Append(PSHLINKFLAGS=shared_partial_flags)
3638336Ssteve.reinhardt@amd.com    main.Append(PLINKFLAGS=shared_partial_flags)
3648336Ssteve.reinhardt@amd.com
3658336Ssteve.reinhardt@amd.com    # Treat warnings as errors but white list some warnings that we
3668336Ssteve.reinhardt@amd.com    # want to allow (e.g., deprecation warnings).
3678336Ssteve.reinhardt@amd.com    main.Append(CCFLAGS=['-Werror',
3688336Ssteve.reinhardt@amd.com                         '-Wno-error=deprecated-declarations',
3698336Ssteve.reinhardt@amd.com                         '-Wno-error=deprecated',
3708336Ssteve.reinhardt@amd.com                        ])
3718336Ssteve.reinhardt@amd.comelse:
37211401Sandreas.sandberg@arm.com    print(termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, end=' ')
37311401Sandreas.sandberg@arm.com    print("Don't know what compiler options to use for your compiler.")
3748336Ssteve.reinhardt@amd.com    print(termcap.Yellow + '       compiler:' + termcap.Normal, main['CXX'])
3758336Ssteve.reinhardt@amd.com    print(termcap.Yellow + '       version:' + termcap.Normal, end = ' ')
3768336Ssteve.reinhardt@amd.com    if not CXX_version:
3775871Snate@binkert.org        print(termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +
37811476Sandreas.sandberg@arm.com              termcap.Normal)
37911476Sandreas.sandberg@arm.com    else:
38011476Sandreas.sandberg@arm.com        print(CXX_version.replace('\n', '<nl>'))
38111476Sandreas.sandberg@arm.com    print("       If you're trying to use a compiler other than GCC")
38211476Sandreas.sandberg@arm.com    print("       or clang, there appears to be something wrong with your")
38311476Sandreas.sandberg@arm.com    print("       environment.")
38411476Sandreas.sandberg@arm.com    print("       ")
38511476Sandreas.sandberg@arm.com    print("       If you are trying to use a compiler other than those listed")
38611476Sandreas.sandberg@arm.com    print("       above you will need to ease fix SConstruct and ")
38711887Sandreas.sandberg@arm.com    print("       src/SConscript to support that compiler.")
38811887Sandreas.sandberg@arm.com    Exit(1)
38911887Sandreas.sandberg@arm.com
39011408Sandreas.sandberg@arm.comif main['GCC']:
39111887Sandreas.sandberg@arm.com    # Check for a supported version of gcc. >= 4.8 is chosen for its
39211887Sandreas.sandberg@arm.com    # level of c++11 support. See
39311887Sandreas.sandberg@arm.com    # http://gcc.gnu.org/projects/cxx0x.html for details.
39411887Sandreas.sandberg@arm.com    gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
39511887Sandreas.sandberg@arm.com    if compareVersions(gcc_version, "4.8") < 0:
39611887Sandreas.sandberg@arm.com        print('Error: gcc version 4.8 or newer required.')
39711926Sgabeblack@google.com        print('       Installed version: ', gcc_version)
39811926Sgabeblack@google.com        Exit(1)
39911926Sgabeblack@google.com
40011926Sgabeblack@google.com    main['GCC_VERSION'] = gcc_version
40111887Sandreas.sandberg@arm.com
40211887Sandreas.sandberg@arm.com    if compareVersions(gcc_version, '4.9') >= 0:
40311944Sandreas.sandberg@arm.com        # Incremental linking with LTO is currently broken in gcc versions
40411887Sandreas.sandberg@arm.com        # 4.9 and above. A version where everything works completely hasn't
40511927Sgabeblack@google.com        # yet been identified.
40611927Sgabeblack@google.com        #
40711927Sgabeblack@google.com        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548
40811927Sgabeblack@google.com        main['BROKEN_INCREMENTAL_LTO'] = True
40911927Sgabeblack@google.com    if compareVersions(gcc_version, '6.0') >= 0:
41011927Sgabeblack@google.com        # gcc versions 6.0 and greater accept an -flinker-output flag which
41111887Sandreas.sandberg@arm.com        # selects what type of output the linker should generate. This is
41211928Sgabeblack@google.com        # necessary for incremental lto to work, but is also broken in
41311928Sgabeblack@google.com        # current versions of gcc. It may not be necessary in future
41411887Sandreas.sandberg@arm.com        # versions. We add it here since it might be, and as a reminder that
41511887Sandreas.sandberg@arm.com        # it exists. It's excluded if lto is being forced.
41611887Sandreas.sandberg@arm.com        #
41711887Sandreas.sandberg@arm.com        # https://gcc.gnu.org/gcc-6/changes.html
41811887Sandreas.sandberg@arm.com        # https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03161.html
41911887Sandreas.sandberg@arm.com        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69866
42011887Sandreas.sandberg@arm.com        if not GetOption('force_lto'):
42111887Sandreas.sandberg@arm.com            main.Append(PSHLINKFLAGS='-flinker-output=rel')
42211887Sandreas.sandberg@arm.com            main.Append(PLINKFLAGS='-flinker-output=rel')
42311887Sandreas.sandberg@arm.com
42411476Sandreas.sandberg@arm.com    # gcc from version 4.8 and above generates "rep; ret" instructions
42511476Sandreas.sandberg@arm.com    # to avoid performance penalties on certain AMD chips. Older
42611408Sandreas.sandberg@arm.com    # assemblers detect this as an error, "Error: expecting string
42711408Sandreas.sandberg@arm.com    # instruction after `rep'"
42811408Sandreas.sandberg@arm.com    as_version_raw = readCommand([main['AS'], '-v', '/dev/null',
42911408Sandreas.sandberg@arm.com                                  '-o', '/dev/null'],
43011408Sandreas.sandberg@arm.com                                 exception=False).split()
43111408Sandreas.sandberg@arm.com
43211408Sandreas.sandberg@arm.com    # version strings may contain extra distro-specific
43311887Sandreas.sandberg@arm.com    # qualifiers, so play it safe and keep only what comes before
43411887Sandreas.sandberg@arm.com    # the first hyphen
43511476Sandreas.sandberg@arm.com    as_version = as_version_raw[-1].split('-')[0] if as_version_raw else None
43611887Sandreas.sandberg@arm.com
43711887Sandreas.sandberg@arm.com    if not as_version or compareVersions(as_version, "2.23") < 0:
43811476Sandreas.sandberg@arm.com        print(termcap.Yellow + termcap.Bold +
43911476Sandreas.sandberg@arm.com            'Warning: This combination of gcc and binutils have' +
44011476Sandreas.sandberg@arm.com            ' known incompatibilities.\n' +
44111476Sandreas.sandberg@arm.com            '         If you encounter build problems, please update ' +
4426121Snate@binkert.org            'binutils to 2.23.' +
443955SN/A            termcap.Normal)
444955SN/A
4452632Sstever@eecs.umich.edu    # Make sure we warn if the user has requested to compile with the
4462632Sstever@eecs.umich.edu    # Undefined Benahvior Sanitizer and this version of gcc does not
447955SN/A    # support it.
448955SN/A    if GetOption('with_ubsan') and \
449955SN/A            compareVersions(gcc_version, '4.9') < 0:
450955SN/A        print(termcap.Yellow + termcap.Bold +
4518878Ssteve.reinhardt@amd.com            'Warning: UBSan is only supported using gcc 4.9 and later.' +
452955SN/A            termcap.Normal)
4532632Sstever@eecs.umich.edu
4542632Sstever@eecs.umich.edu    disable_lto = GetOption('no_lto')
4552632Sstever@eecs.umich.edu    if not disable_lto and main.get('BROKEN_INCREMENTAL_LTO', False) and \
4562632Sstever@eecs.umich.edu            not GetOption('force_lto'):
4572632Sstever@eecs.umich.edu        print(termcap.Yellow + termcap.Bold +
4582632Sstever@eecs.umich.edu            'Warning: Your compiler doesn\'t support incremental linking' +
4592632Sstever@eecs.umich.edu            ' and lto at the same time, so lto is being disabled. To force' +
4608268Ssteve.reinhardt@amd.com            ' lto on anyway, use the --force-lto option. That will disable' +
4618268Ssteve.reinhardt@amd.com            ' partial linking.' +
4628268Ssteve.reinhardt@amd.com            termcap.Normal)
4638268Ssteve.reinhardt@amd.com        disable_lto = True
4648268Ssteve.reinhardt@amd.com
4658268Ssteve.reinhardt@amd.com    # Add the appropriate Link-Time Optimization (LTO) flags
4668268Ssteve.reinhardt@amd.com    # unless LTO is explicitly turned off. Note that these flags
4672632Sstever@eecs.umich.edu    # are only used by the fast target.
4682632Sstever@eecs.umich.edu    if not disable_lto:
4692632Sstever@eecs.umich.edu        # Pass the LTO flag when compiling to produce GIMPLE
4702632Sstever@eecs.umich.edu        # output, we merely create the flags here and only append
4718268Ssteve.reinhardt@amd.com        # them later
4722632Sstever@eecs.umich.edu        main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
4738268Ssteve.reinhardt@amd.com
4748268Ssteve.reinhardt@amd.com        # Use the same amount of jobs for LTO as we are running
4758268Ssteve.reinhardt@amd.com        # scons with
4768268Ssteve.reinhardt@amd.com        main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
4773718Sstever@eecs.umich.edu
4782634Sstever@eecs.umich.edu    main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
4792634Sstever@eecs.umich.edu                                  '-fno-builtin-realloc', '-fno-builtin-free'])
4805863Snate@binkert.org
4812638Sstever@eecs.umich.edu    # The address sanitizer is available for gcc >= 4.8
4828268Ssteve.reinhardt@amd.com    if GetOption('with_asan'):
4832632Sstever@eecs.umich.edu        if GetOption('with_ubsan') and \
4842632Sstever@eecs.umich.edu                compareVersions(main['GCC_VERSION'], '4.9') >= 0:
4852632Sstever@eecs.umich.edu            main.Append(CCFLAGS=['-fsanitize=address,undefined',
4862632Sstever@eecs.umich.edu                                 '-fno-omit-frame-pointer'],
4872632Sstever@eecs.umich.edu                        LINKFLAGS='-fsanitize=address,undefined')
4881858SN/A        else:
4893716Sstever@eecs.umich.edu            main.Append(CCFLAGS=['-fsanitize=address',
4902638Sstever@eecs.umich.edu                                 '-fno-omit-frame-pointer'],
4912638Sstever@eecs.umich.edu                        LINKFLAGS='-fsanitize=address')
4922638Sstever@eecs.umich.edu    # Only gcc >= 4.9 supports UBSan, so check both the version
4932638Sstever@eecs.umich.edu    # and the command-line option before adding the compiler and
4942638Sstever@eecs.umich.edu    # linker flags.
4952638Sstever@eecs.umich.edu    elif GetOption('with_ubsan') and \
4962638Sstever@eecs.umich.edu            compareVersions(main['GCC_VERSION'], '4.9') >= 0:
4975863Snate@binkert.org        main.Append(CCFLAGS='-fsanitize=undefined')
4985863Snate@binkert.org        main.Append(LINKFLAGS='-fsanitize=undefined')
4995863Snate@binkert.org
500955SN/Aelif main['CLANG']:
5015341Sstever@gmail.com    # Check for a supported version of clang, >= 3.1 is needed to
5025341Sstever@gmail.com    # support similar features as gcc 4.8. See
5035863Snate@binkert.org    # http://clang.llvm.org/cxx_status.html for details
5047756SAli.Saidi@ARM.com    clang_version_re = re.compile(".* version (\d+\.\d+)")
5055341Sstever@gmail.com    clang_version_match = clang_version_re.search(CXX_version)
5066121Snate@binkert.org    if (clang_version_match):
5074494Ssaidi@eecs.umich.edu        clang_version = clang_version_match.groups()[0]
5086121Snate@binkert.org        if compareVersions(clang_version, "3.1") < 0:
5091105SN/A            print('Error: clang version 3.1 or newer required.')
5102667Sstever@eecs.umich.edu            print('       Installed version:', clang_version)
5112667Sstever@eecs.umich.edu            Exit(1)
5122667Sstever@eecs.umich.edu    else:
5132667Sstever@eecs.umich.edu        print('Error: Unable to determine clang version.')
5146121Snate@binkert.org        Exit(1)
5152667Sstever@eecs.umich.edu
5165341Sstever@gmail.com    # clang has a few additional warnings that we disable, extraneous
5175863Snate@binkert.org    # parantheses are allowed due to Ruby's printing of the AST,
5185341Sstever@gmail.com    # finally self assignments are allowed as the generated CPU code
5195341Sstever@gmail.com    # is relying on this
5205341Sstever@gmail.com    main.Append(CCFLAGS=['-Wno-parentheses',
5218120Sgblack@eecs.umich.edu                         '-Wno-self-assign',
5225341Sstever@gmail.com                         # Some versions of libstdc++ (4.8?) seem to
5238120Sgblack@eecs.umich.edu                         # use struct hash and class hash
5245341Sstever@gmail.com                         # interchangeably.
5258120Sgblack@eecs.umich.edu                         '-Wno-mismatched-tags',
5266121Snate@binkert.org                         ])
5276121Snate@binkert.org
5289396Sandreas.hansson@arm.com    main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
5295397Ssaidi@eecs.umich.edu
5305397Ssaidi@eecs.umich.edu    # On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
5317727SAli.Saidi@ARM.com    # opposed to libstdc++, as the later is dated.
5328268Ssteve.reinhardt@amd.com    if sys.platform == "darwin":
5336168Snate@binkert.org        main.Append(CXXFLAGS=['-stdlib=libc++'])
5345341Sstever@gmail.com        main.Append(LIBS=['c++'])
5358120Sgblack@eecs.umich.edu
5368120Sgblack@eecs.umich.edu    # On FreeBSD we need libthr.
5378120Sgblack@eecs.umich.edu    if sys.platform.startswith('freebsd'):
5386814Sgblack@eecs.umich.edu        main.Append(LIBS=['thr'])
5395863Snate@binkert.org
5408120Sgblack@eecs.umich.edu    # We require clang >= 3.1, so there is no need to check any
5415341Sstever@gmail.com    # versions here.
5425863Snate@binkert.org    if GetOption('with_ubsan'):
5438268Ssteve.reinhardt@amd.com        if GetOption('with_asan'):
5446121Snate@binkert.org            main.Append(CCFLAGS=['-fsanitize=address,undefined',
5456121Snate@binkert.org                                 '-fno-omit-frame-pointer'],
5468268Ssteve.reinhardt@amd.com                       LINKFLAGS='-fsanitize=address,undefined')
5475742Snate@binkert.org        else:
5485742Snate@binkert.org            main.Append(CCFLAGS='-fsanitize=undefined',
5495341Sstever@gmail.com                        LINKFLAGS='-fsanitize=undefined')
5505742Snate@binkert.org
5515742Snate@binkert.org    elif GetOption('with_asan'):
5525341Sstever@gmail.com        main.Append(CCFLAGS=['-fsanitize=address',
5536017Snate@binkert.org                             '-fno-omit-frame-pointer'],
5546121Snate@binkert.org                   LINKFLAGS='-fsanitize=address')
5556017Snate@binkert.org
55612158Sandreas.sandberg@arm.comelse:
55712158Sandreas.sandberg@arm.com    print(termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, end=' ')
55812158Sandreas.sandberg@arm.com    print("Don't know what compiler options to use for your compiler.")
5597816Ssteve.reinhardt@amd.com    print(termcap.Yellow + '       compiler:' + termcap.Normal, main['CXX'])
5607756SAli.Saidi@ARM.com    print(termcap.Yellow + '       version:' + termcap.Normal, end=' ')
5617756SAli.Saidi@ARM.com    if not CXX_version:
5627756SAli.Saidi@ARM.com        print(termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +
5637756SAli.Saidi@ARM.com              termcap.Normal)
5647756SAli.Saidi@ARM.com    else:
5657756SAli.Saidi@ARM.com        print(CXX_version.replace('\n', '<nl>'))
5667756SAli.Saidi@ARM.com    print("       If you're trying to use a compiler other than GCC")
5677756SAli.Saidi@ARM.com    print("       or clang, there appears to be something wrong with your")
5687816Ssteve.reinhardt@amd.com    print("       environment.")
5697816Ssteve.reinhardt@amd.com    print("       ")
5707816Ssteve.reinhardt@amd.com    print("       If you are trying to use a compiler other than those listed")
5717816Ssteve.reinhardt@amd.com    print("       above you will need to ease fix SConstruct and ")
5727816Ssteve.reinhardt@amd.com    print("       src/SConscript to support that compiler.")
5737816Ssteve.reinhardt@amd.com    Exit(1)
5747816Ssteve.reinhardt@amd.com
5757816Ssteve.reinhardt@amd.com# Set up common yacc/bison flags (needed for Ruby)
5767816Ssteve.reinhardt@amd.commain['YACCFLAGS'] = '-d'
5777816Ssteve.reinhardt@amd.commain['YACCHXXFILESUFFIX'] = '.hh'
5787756SAli.Saidi@ARM.com
5797816Ssteve.reinhardt@amd.com# Do this after we save setting back, or else we'll tack on an
5807816Ssteve.reinhardt@amd.com# extra 'qdo' every time we run scons.
5817816Ssteve.reinhardt@amd.comif main['BATCH']:
5827816Ssteve.reinhardt@amd.com    main['CC']     = main['BATCH_CMD'] + ' ' + main['CC']
5837816Ssteve.reinhardt@amd.com    main['CXX']    = main['BATCH_CMD'] + ' ' + main['CXX']
5847816Ssteve.reinhardt@amd.com    main['AS']     = main['BATCH_CMD'] + ' ' + main['AS']
5857816Ssteve.reinhardt@amd.com    main['AR']     = main['BATCH_CMD'] + ' ' + main['AR']
5867816Ssteve.reinhardt@amd.com    main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB']
5877816Ssteve.reinhardt@amd.com
5887816Ssteve.reinhardt@amd.comif sys.platform == 'cygwin':
5897816Ssteve.reinhardt@amd.com    # cygwin has some header file issues...
5907816Ssteve.reinhardt@amd.com    main.Append(CCFLAGS=["-Wno-uninitialized"])
5917816Ssteve.reinhardt@amd.com
5927816Ssteve.reinhardt@amd.com# Check for the protobuf compiler
5937816Ssteve.reinhardt@amd.comprotoc_version = readCommand([main['PROTOC'], '--version'],
5947816Ssteve.reinhardt@amd.com                             exception='').split()
5957816Ssteve.reinhardt@amd.com
5967816Ssteve.reinhardt@amd.com# First two words should be "libprotoc x.y.z"
5977816Ssteve.reinhardt@amd.comif len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
5987816Ssteve.reinhardt@amd.com    print(termcap.Yellow + termcap.Bold +
5997816Ssteve.reinhardt@amd.com        'Warning: Protocol buffer compiler (protoc) not found.\n' +
6007816Ssteve.reinhardt@amd.com        '         Please install protobuf-compiler for tracing support.' +
6017816Ssteve.reinhardt@amd.com        termcap.Normal)
6027816Ssteve.reinhardt@amd.com    main['PROTOC'] = False
6037816Ssteve.reinhardt@amd.comelse:
6047816Ssteve.reinhardt@amd.com    # Based on the availability of the compress stream wrappers,
6057816Ssteve.reinhardt@amd.com    # require 2.1.0
6067816Ssteve.reinhardt@amd.com    min_protoc_version = '2.1.0'
6077816Ssteve.reinhardt@amd.com    if compareVersions(protoc_version[1], min_protoc_version) < 0:
6087816Ssteve.reinhardt@amd.com        print(termcap.Yellow + termcap.Bold +
6097816Ssteve.reinhardt@amd.com            'Warning: protoc version', min_protoc_version,
6107816Ssteve.reinhardt@amd.com            'or newer required.\n' +
6117816Ssteve.reinhardt@amd.com            '         Installed version:', protoc_version[1],
6127816Ssteve.reinhardt@amd.com            termcap.Normal)
6137816Ssteve.reinhardt@amd.com        main['PROTOC'] = False
6147816Ssteve.reinhardt@amd.com    else:
6157816Ssteve.reinhardt@amd.com        # Attempt to determine the appropriate include path and
6167816Ssteve.reinhardt@amd.com        # library path using pkg-config, that means we also need to
6177816Ssteve.reinhardt@amd.com        # check for pkg-config. Note that it is possible to use
6187816Ssteve.reinhardt@amd.com        # protobuf without the involvement of pkg-config. Later on we
6197816Ssteve.reinhardt@amd.com        # check go a library config check and at that point the test
6207816Ssteve.reinhardt@amd.com        # will fail if libprotobuf cannot be found.
6217816Ssteve.reinhardt@amd.com        if readCommand(['pkg-config', '--version'], exception=''):
6227816Ssteve.reinhardt@amd.com            try:
6237816Ssteve.reinhardt@amd.com                # Attempt to establish what linking flags to add for protobuf
6247816Ssteve.reinhardt@amd.com                # using pkg-config
6257816Ssteve.reinhardt@amd.com                main.ParseConfig('pkg-config --cflags --libs-only-L protobuf')
6267816Ssteve.reinhardt@amd.com            except:
6277816Ssteve.reinhardt@amd.com                print(termcap.Yellow + termcap.Bold +
6287816Ssteve.reinhardt@amd.com                    'Warning: pkg-config could not get protobuf flags.' +
6297816Ssteve.reinhardt@amd.com                    termcap.Normal)
6307816Ssteve.reinhardt@amd.com
6317816Ssteve.reinhardt@amd.com
6327816Ssteve.reinhardt@amd.com# Check for 'timeout' from GNU coreutils. If present, regressions will
6337816Ssteve.reinhardt@amd.com# be run with a time limit. We require version 8.13 since we rely on
6347816Ssteve.reinhardt@amd.com# support for the '--foreground' option.
6357816Ssteve.reinhardt@amd.comif sys.platform.startswith('freebsd'):
6367816Ssteve.reinhardt@amd.com    timeout_lines = readCommand(['gtimeout', '--version'],
6377816Ssteve.reinhardt@amd.com                                exception='').splitlines()
6387816Ssteve.reinhardt@amd.comelse:
6397816Ssteve.reinhardt@amd.com    timeout_lines = readCommand(['timeout', '--version'],
6408947Sandreas.hansson@arm.com                                exception='').splitlines()
6418947Sandreas.hansson@arm.com# Get the first line and tokenize it
6427756SAli.Saidi@ARM.comtimeout_version = timeout_lines[0].split() if timeout_lines else []
6438120Sgblack@eecs.umich.edumain['TIMEOUT'] =  timeout_version and \
6447756SAli.Saidi@ARM.com    compareVersions(timeout_version[-1], '8.13') >= 0
6457756SAli.Saidi@ARM.com
6467756SAli.Saidi@ARM.com# Add a custom Check function to test for structure members.
6477756SAli.Saidi@ARM.comdef CheckMember(context, include, decl, member, include_quotes="<>"):
6487816Ssteve.reinhardt@amd.com    context.Message("Checking for member %s in %s..." %
6497816Ssteve.reinhardt@amd.com                    (member, decl))
6507816Ssteve.reinhardt@amd.com    text = """
6517816Ssteve.reinhardt@amd.com#include %(header)s
6527816Ssteve.reinhardt@amd.comint main(){
65311979Sgabeblack@google.com  %(decl)s test;
6547816Ssteve.reinhardt@amd.com  (void)test.%(member)s;
6557816Ssteve.reinhardt@amd.com  return 0;
6567816Ssteve.reinhardt@amd.com};
6577816Ssteve.reinhardt@amd.com""" % { "header" : include_quotes[0] + include + include_quotes[1],
6587756SAli.Saidi@ARM.com        "decl" : decl,
6597756SAli.Saidi@ARM.com        "member" : member,
6609227Sandreas.hansson@arm.com        }
6619227Sandreas.hansson@arm.com
6629227Sandreas.hansson@arm.com    ret = context.TryCompile(text, extension=".cc")
6639227Sandreas.hansson@arm.com    context.Result(ret)
6649590Sandreas@sandberg.pp.se    return ret
6659590Sandreas@sandberg.pp.se
6669590Sandreas@sandberg.pp.se# Platform-specific configuration.  Note again that we assume that all
6679590Sandreas@sandberg.pp.se# builds under a given build root run on the same host platform.
6689590Sandreas@sandberg.pp.seconf = Configure(main,
6699590Sandreas@sandberg.pp.se                 conf_dir = joinpath(build_root, '.scons_config'),
6706654Snate@binkert.org                 log_file = joinpath(build_root, 'scons_config.log'),
6716654Snate@binkert.org                 custom_tests = {
6725871Snate@binkert.org        'CheckMember' : CheckMember,
6736121Snate@binkert.org        })
6748946Sandreas.hansson@arm.com
6759419Sandreas.hansson@arm.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin
6763940Ssaidi@eecs.umich.edutry:
6773918Ssaidi@eecs.umich.edu    import platform
6783918Ssaidi@eecs.umich.edu    uname = platform.uname()
6791858SN/A    if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
6809556Sandreas.hansson@arm.com        if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
6819556Sandreas.hansson@arm.com            main.Append(CCFLAGS=['-arch', 'x86_64'])
6829556Sandreas.hansson@arm.com            main.Append(CFLAGS=['-arch', 'x86_64'])
6839556Sandreas.hansson@arm.com            main.Append(LINKFLAGS=['-arch', 'x86_64'])
68411294Sandreas.hansson@arm.com            main.Append(ASFLAGS=['-arch', 'x86_64'])
68511294Sandreas.hansson@arm.comexcept:
68611294Sandreas.hansson@arm.com    pass
68711294Sandreas.hansson@arm.com
68810878Sandreas.hansson@arm.com# Recent versions of scons substitute a "Null" object for Configure()
68910878Sandreas.hansson@arm.com# when configuration isn't necessary, e.g., if the "--help" option is
69011811Sbaz21@cam.ac.uk# present.  Unfortuantely this Null object always returns false,
69111811Sbaz21@cam.ac.uk# breaking all our configuration checks.  We replace it with our own
69211811Sbaz21@cam.ac.uk# more optimistic null object that returns True instead.
69311982Sgabeblack@google.comif not conf:
69411982Sgabeblack@google.com    def NullCheck(*args, **kwargs):
69511982Sgabeblack@google.com        return True
69611982Sgabeblack@google.com
69711992Sgabeblack@google.com    class NullConf:
69811982Sgabeblack@google.com        def __init__(self, env):
69911982Sgabeblack@google.com            self.env = env
7009556Sandreas.hansson@arm.com        def Finish(self):
7019556Sandreas.hansson@arm.com            return self.env
7029556Sandreas.hansson@arm.com        def __getattr__(self, mname):
7039556Sandreas.hansson@arm.com            return NullCheck
7049556Sandreas.hansson@arm.com
7059556Sandreas.hansson@arm.com    conf = NullConf(main)
7069556Sandreas.hansson@arm.com
7079556Sandreas.hansson@arm.com# Cache build files in the supplied directory.
7089556Sandreas.hansson@arm.comif main['M5_BUILD_CACHE']:
7099556Sandreas.hansson@arm.com    print('Using build cache located at', main['M5_BUILD_CACHE'])
7109556Sandreas.hansson@arm.com    CacheDir(main['M5_BUILD_CACHE'])
7119556Sandreas.hansson@arm.com
7129556Sandreas.hansson@arm.commain['USE_PYTHON'] = not GetOption('without_python')
7139556Sandreas.hansson@arm.comif main['USE_PYTHON']:
7149556Sandreas.hansson@arm.com    # Find Python include and library directories for embedding the
7159556Sandreas.hansson@arm.com    # interpreter. We rely on python-config to resolve the appropriate
7169556Sandreas.hansson@arm.com    # includes and linker flags. ParseConfig does not seem to understand
7179556Sandreas.hansson@arm.com    # the more exotic linker flags such as -Xlinker and -export-dynamic so
7189556Sandreas.hansson@arm.com    # we add them explicitly below. If you want to link in an alternate
7196121Snate@binkert.org    # version of python, see above for instructions on how to invoke
72011500Sandreas.hansson@arm.com    # scons with the appropriate PATH set.
72110238Sandreas.hansson@arm.com    #
72210878Sandreas.hansson@arm.com    # First we check if python2-config exists, else we use python-config
7239420Sandreas.hansson@arm.com    python_config = readCommand(['which', 'python2-config'],
72411500Sandreas.hansson@arm.com                                exception='').strip()
72511500Sandreas.hansson@arm.com    if not os.path.exists(python_config):
7269420Sandreas.hansson@arm.com        python_config = readCommand(['which', 'python-config'],
7279420Sandreas.hansson@arm.com                                    exception='').strip()
7289420Sandreas.hansson@arm.com    py_includes = readCommand([python_config, '--includes'],
7299420Sandreas.hansson@arm.com                              exception='').split()
7309420Sandreas.hansson@arm.com    # Strip the -I from the include folders before adding them to the
73112063Sgabeblack@google.com    # CPPPATH
73212063Sgabeblack@google.com    main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes))
73312063Sgabeblack@google.com
73412063Sgabeblack@google.com    # Read the linker flags and split them into libraries and other link
73512063Sgabeblack@google.com    # flags. The libraries are added later through the call the CheckLib.
73612063Sgabeblack@google.com    py_ld_flags = readCommand([python_config, '--ldflags'],
73712063Sgabeblack@google.com        exception='').split()
73812063Sgabeblack@google.com    py_libs = []
73912063Sgabeblack@google.com    for lib in py_ld_flags:
74012063Sgabeblack@google.com         if not lib.startswith('-l'):
74112063Sgabeblack@google.com             main.Append(LINKFLAGS=[lib])
74212063Sgabeblack@google.com         else:
74312063Sgabeblack@google.com             lib = lib[2:]
74412063Sgabeblack@google.com             if lib not in py_libs:
74512063Sgabeblack@google.com                 py_libs.append(lib)
74612063Sgabeblack@google.com
74712063Sgabeblack@google.com    # verify that this stuff works
74812063Sgabeblack@google.com    if not conf.CheckHeader('Python.h', '<>'):
74912063Sgabeblack@google.com        print("Error: Check failed for Python.h header in", py_includes)
75012063Sgabeblack@google.com        print("Two possible reasons:")
75112063Sgabeblack@google.com        print("1. Python headers are not installed (You can install the "
75212063Sgabeblack@google.com              "package python-dev on Ubuntu and RedHat)")
75310264Sandreas.hansson@arm.com        print("2. SCons is using a wrong C compiler. This can happen if "
75410264Sandreas.hansson@arm.com              "CC has the wrong value.")
75510264Sandreas.hansson@arm.com        print("CC = %s" % main['CC'])
75610264Sandreas.hansson@arm.com        Exit(1)
75711925Sgabeblack@google.com
75811925Sgabeblack@google.com    for lib in py_libs:
75911500Sandreas.hansson@arm.com        if not conf.CheckLib(lib):
76010264Sandreas.hansson@arm.com            print("Error: can't find library %s required by python" % lib)
76111500Sandreas.hansson@arm.com            Exit(1)
76211500Sandreas.hansson@arm.com
76311500Sandreas.hansson@arm.com# On Solaris you need to use libsocket for socket ops
76411500Sandreas.hansson@arm.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
76510866Sandreas.hansson@arm.com   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
76611500Sandreas.hansson@arm.com       print("Can't find library with socket calls (e.g. accept())")
76711500Sandreas.hansson@arm.com       Exit(1)
76811500Sandreas.hansson@arm.com
76911500Sandreas.hansson@arm.com# Check for zlib.  If the check passes, libz will be automatically
77011500Sandreas.hansson@arm.com# added to the LIBS environment variable.
77111500Sandreas.hansson@arm.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
77211500Sandreas.hansson@arm.com    print('Error: did not find needed zlib compression library '
77310264Sandreas.hansson@arm.com          'and/or zlib.h header file.')
77410457Sandreas.hansson@arm.com    print('       Please install zlib and try again.')
77510457Sandreas.hansson@arm.com    Exit(1)
77610457Sandreas.hansson@arm.com
77710457Sandreas.hansson@arm.com# If we have the protobuf compiler, also make sure we have the
77810457Sandreas.hansson@arm.com# development libraries. If the check passes, libprotobuf will be
77910457Sandreas.hansson@arm.com# automatically added to the LIBS environment variable. After
78010457Sandreas.hansson@arm.com# this, we can use the HAVE_PROTOBUF flag to determine if we have
78110457Sandreas.hansson@arm.com# got both protoc and libprotobuf available.
78210457Sandreas.hansson@arm.commain['HAVE_PROTOBUF'] = main['PROTOC'] and \
78312063Sgabeblack@google.com    conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
78412063Sgabeblack@google.com                            'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
78512063Sgabeblack@google.com
78612063Sgabeblack@google.com# Valgrind gets much less confused if you tell it when you're using
78712063Sgabeblack@google.com# alternative stacks.
78812063Sgabeblack@google.commain['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
78912063Sgabeblack@google.com
79012063Sgabeblack@google.com# If we have the compiler but not the library, print another warning.
79112063Sgabeblack@google.comif main['PROTOC'] and not main['HAVE_PROTOBUF']:
79212063Sgabeblack@google.com    print(termcap.Yellow + termcap.Bold +
79312063Sgabeblack@google.com        'Warning: did not find protocol buffer library and/or headers.\n' +
79410238Sandreas.hansson@arm.com    '       Please install libprotobuf-dev for tracing support.' +
79510238Sandreas.hansson@arm.com    termcap.Normal)
79610238Sandreas.hansson@arm.com
79712063Sgabeblack@google.com# Check for librt.
79810238Sandreas.hansson@arm.comhave_posix_clock = \
79910238Sandreas.hansson@arm.com    conf.CheckLibWithHeader(None, 'time.h', 'C',
80010416Sandreas.hansson@arm.com                            'clock_nanosleep(0,0,NULL,NULL);') or \
80110238Sandreas.hansson@arm.com    conf.CheckLibWithHeader('rt', 'time.h', 'C',
8029227Sandreas.hansson@arm.com                            'clock_nanosleep(0,0,NULL,NULL);')
80310238Sandreas.hansson@arm.com
80410416Sandreas.hansson@arm.comhave_posix_timers = \
80510416Sandreas.hansson@arm.com    conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ], 'C',
8069227Sandreas.hansson@arm.com                            'timer_create(CLOCK_MONOTONIC, NULL, NULL);')
8079590Sandreas@sandberg.pp.se
8089590Sandreas@sandberg.pp.seif not GetOption('without_tcmalloc'):
8099590Sandreas@sandberg.pp.se    if conf.CheckLib('tcmalloc'):
81011497SMatteo.Andreozzi@arm.com        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
81111497SMatteo.Andreozzi@arm.com    elif conf.CheckLib('tcmalloc_minimal'):
81211497SMatteo.Andreozzi@arm.com        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
81311497SMatteo.Andreozzi@arm.com    else:
8148737Skoansin.tan@gmail.com        print(termcap.Yellow + termcap.Bold +
81510878Sandreas.hansson@arm.com              "You can get a 12% performance improvement by "
81611500Sandreas.hansson@arm.com              "installing tcmalloc (libgoogle-perftools-dev package "
8179420Sandreas.hansson@arm.com              "on Ubuntu or RedHat)." + termcap.Normal)
8188737Skoansin.tan@gmail.com
81910106SMitch.Hayenga@arm.com
8208737Skoansin.tan@gmail.com# Detect back trace implementations. The last implementation in the
8218737Skoansin.tan@gmail.com# list will be used by default.
82210878Sandreas.hansson@arm.combacktrace_impls = [ "none" ]
82310878Sandreas.hansson@arm.com
8248737Skoansin.tan@gmail.combacktrace_checker = 'char temp;' + \
8258737Skoansin.tan@gmail.com    ' backtrace_symbols_fd((void*)&temp, 0, 0);'
8268737Skoansin.tan@gmail.comif conf.CheckLibWithHeader(None, 'execinfo.h', 'C', backtrace_checker):
8278737Skoansin.tan@gmail.com    backtrace_impls.append("glibc")
8288737Skoansin.tan@gmail.comelif conf.CheckLibWithHeader('execinfo', 'execinfo.h', 'C',
8298737Skoansin.tan@gmail.com                             backtrace_checker):
83011294Sandreas.hansson@arm.com    # NetBSD and FreeBSD need libexecinfo.
8319556Sandreas.hansson@arm.com    backtrace_impls.append("glibc")
8329556Sandreas.hansson@arm.com    main.Append(LIBS=['execinfo'])
8339556Sandreas.hansson@arm.com
83411294Sandreas.hansson@arm.comif backtrace_impls[-1] == "none":
83510278SAndreas.Sandberg@ARM.com    default_backtrace_impl = "none"
83610278SAndreas.Sandberg@ARM.com    print(termcap.Yellow + termcap.Bold +
83710278SAndreas.Sandberg@ARM.com        "No suitable back trace implementation found." +
83810278SAndreas.Sandberg@ARM.com        termcap.Normal)
83910278SAndreas.Sandberg@ARM.com
84010278SAndreas.Sandberg@ARM.comif not have_posix_clock:
8419556Sandreas.hansson@arm.com    print("Can't find library for POSIX clocks.")
8429590Sandreas@sandberg.pp.se
8439590Sandreas@sandberg.pp.se# Check for <fenv.h> (C99 FP environment control)
8449420Sandreas.hansson@arm.comhave_fenv = conf.CheckHeader('fenv.h', '<>')
8459846Sandreas.hansson@arm.comif not have_fenv:
8469846Sandreas.hansson@arm.com    print("Warning: Header file <fenv.h> not found.")
8479846Sandreas.hansson@arm.com    print("         This host has no IEEE FP rounding mode control.")
8489846Sandreas.hansson@arm.com
8498946Sandreas.hansson@arm.com# Check for <png.h> (libpng library needed if wanting to dump
85011811Sbaz21@cam.ac.uk# frame buffer image in png format)
85111811Sbaz21@cam.ac.ukhave_png = conf.CheckHeader('png.h', '<>')
85211811Sbaz21@cam.ac.ukif not have_png:
85311811Sbaz21@cam.ac.uk    print("Warning: Header file <png.h> not found.")
8543918Ssaidi@eecs.umich.edu    print("         This host has no libpng library.")
8559068SAli.Saidi@ARM.com    print("         Disabling support for PNG framebuffers.")
8569068SAli.Saidi@ARM.com
8579068SAli.Saidi@ARM.com# Check if we should enable KVM-based hardware virtualization. The API
8589068SAli.Saidi@ARM.com# we rely on exists since version 2.6.36 of the kernel, but somehow
8599068SAli.Saidi@ARM.com# the KVM_API_VERSION does not reflect the change. We test for one of
8609068SAli.Saidi@ARM.com# the types as a fall back.
8619068SAli.Saidi@ARM.comhave_kvm = conf.CheckHeader('linux/kvm.h', '<>')
8629068SAli.Saidi@ARM.comif not have_kvm:
8639068SAli.Saidi@ARM.com    print("Info: Compatible header file <linux/kvm.h> not found, "
8649419Sandreas.hansson@arm.com          "disabling KVM support.")
8659068SAli.Saidi@ARM.com
8669068SAli.Saidi@ARM.com# Check if the TUN/TAP driver is available.
8679068SAli.Saidi@ARM.comhave_tuntap = conf.CheckHeader('linux/if_tun.h', '<>')
8689068SAli.Saidi@ARM.comif not have_tuntap:
8699068SAli.Saidi@ARM.com    print("Info: Compatible header file <linux/if_tun.h> not found.")
8709068SAli.Saidi@ARM.com
8713918Ssaidi@eecs.umich.edu# x86 needs support for xsave. We test for the structure here since we
8723918Ssaidi@eecs.umich.edu# won't be able to run new tests by the time we know which ISA we're
8736157Snate@binkert.org# targeting.
8746157Snate@binkert.orghave_kvm_xsave = conf.CheckTypeSize('struct kvm_xsave',
8756157Snate@binkert.org                                    '#include <linux/kvm.h>') != 0
8766157Snate@binkert.org
8775397Ssaidi@eecs.umich.edu# Check if the requested target ISA is compatible with the host
8785397Ssaidi@eecs.umich.edudef is_isa_kvm_compatible(isa):
8796121Snate@binkert.org    try:
8806121Snate@binkert.org        import platform
8816121Snate@binkert.org        host_isa = platform.machine()
8826121Snate@binkert.org    except:
8836121Snate@binkert.org        print("Warning: Failed to determine host ISA.")
8846121Snate@binkert.org        return False
8855397Ssaidi@eecs.umich.edu
8861851SN/A    if not have_posix_timers:
8871851SN/A        print("Warning: Can not enable KVM, host seems to lack support "
8887739Sgblack@eecs.umich.edu              "for POSIX timers")
889955SN/A        return False
8909396Sandreas.hansson@arm.com
8919396Sandreas.hansson@arm.com    if isa == "arm":
8929396Sandreas.hansson@arm.com        return host_isa in ( "armv7l", "aarch64" )
8939396Sandreas.hansson@arm.com    elif isa == "x86":
8949396Sandreas.hansson@arm.com        if host_isa != "x86_64":
8959396Sandreas.hansson@arm.com            return False
8969396Sandreas.hansson@arm.com
8979396Sandreas.hansson@arm.com        if not have_kvm_xsave:
8989396Sandreas.hansson@arm.com            print("KVM on x86 requires xsave support in kernel headers.")
8999396Sandreas.hansson@arm.com            return False
9009396Sandreas.hansson@arm.com
9019396Sandreas.hansson@arm.com        return True
9029396Sandreas.hansson@arm.com    else:
9039396Sandreas.hansson@arm.com        return False
9049396Sandreas.hansson@arm.com
9059396Sandreas.hansson@arm.com
9069477Sandreas.hansson@arm.com# Check if the exclude_host attribute is available. We want this to
9079477Sandreas.hansson@arm.com# get accurate instruction counts in KVM.
9089477Sandreas.hansson@arm.commain['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
9099477Sandreas.hansson@arm.com    'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
9109477Sandreas.hansson@arm.com
9119477Sandreas.hansson@arm.com
9129477Sandreas.hansson@arm.com######################################################################
9139477Sandreas.hansson@arm.com#
9149477Sandreas.hansson@arm.com# Finish the configuration
9159477Sandreas.hansson@arm.com#
9169477Sandreas.hansson@arm.commain = conf.Finish()
9179477Sandreas.hansson@arm.com
9189477Sandreas.hansson@arm.com######################################################################
9199477Sandreas.hansson@arm.com#
9209477Sandreas.hansson@arm.com# Collect all non-global variables
9219477Sandreas.hansson@arm.com#
9229477Sandreas.hansson@arm.com
9239477Sandreas.hansson@arm.com# Define the universe of supported ISAs
9249477Sandreas.hansson@arm.comall_isa_list = [ ]
9259477Sandreas.hansson@arm.comall_gpu_isa_list = [ ]
9269477Sandreas.hansson@arm.comExport('all_isa_list')
9279477Sandreas.hansson@arm.comExport('all_gpu_isa_list')
9289396Sandreas.hansson@arm.com
9292667Sstever@eecs.umich.educlass CpuModel(object):
93010710Sandreas.hansson@arm.com    '''The CpuModel class encapsulates everything the ISA parser needs to
93110710Sandreas.hansson@arm.com    know about a particular CPU model.'''
93210710Sandreas.hansson@arm.com
93311811Sbaz21@cam.ac.uk    # Dict of available CPU model objects.  Accessible as CpuModel.dict.
93411811Sbaz21@cam.ac.uk    dict = {}
93511811Sbaz21@cam.ac.uk
93611811Sbaz21@cam.ac.uk    # Constructor.  Automatically adds models to CpuModel.dict.
93711811Sbaz21@cam.ac.uk    def __init__(self, name, default=False):
93811811Sbaz21@cam.ac.uk        self.name = name           # name of model
93910710Sandreas.hansson@arm.com
94010710Sandreas.hansson@arm.com        # This cpu is enabled by default
94110710Sandreas.hansson@arm.com        self.default = default
94210710Sandreas.hansson@arm.com
94310384SCurtis.Dunham@arm.com        # Add self to dict
9449986Sandreas@sandberg.pp.se        if name in CpuModel.dict:
9459986Sandreas@sandberg.pp.se            raise AttributeError, "CpuModel '%s' already registered" % name
9469986Sandreas@sandberg.pp.se        CpuModel.dict[name] = self
9479986Sandreas@sandberg.pp.se
9489986Sandreas@sandberg.pp.seExport('CpuModel')
9499986Sandreas@sandberg.pp.se
9509986Sandreas@sandberg.pp.se# Sticky variables get saved in the variables file so they persist from
9519986Sandreas@sandberg.pp.se# one invocation to the next (unless overridden, in which case the new
9529986Sandreas@sandberg.pp.se# value becomes sticky).
9539986Sandreas@sandberg.pp.sesticky_vars = Variables(args=ARGUMENTS)
9549986Sandreas@sandberg.pp.seExport('sticky_vars')
9559986Sandreas@sandberg.pp.se
9569986Sandreas@sandberg.pp.se# Sticky variables that should be exported
9579986Sandreas@sandberg.pp.seexport_vars = []
9589986Sandreas@sandberg.pp.seExport('export_vars')
9599986Sandreas@sandberg.pp.se
9609986Sandreas@sandberg.pp.se# For Ruby
9619986Sandreas@sandberg.pp.seall_protocols = []
9629986Sandreas@sandberg.pp.seExport('all_protocols')
9639986Sandreas@sandberg.pp.seprotocol_dirs = []
9642638Sstever@eecs.umich.eduExport('protocol_dirs')
9652638Sstever@eecs.umich.eduslicc_includes = []
9666121Snate@binkert.orgExport('slicc_includes')
9673716Sstever@eecs.umich.edu
9685522Snate@binkert.org# Walk the tree and execute all SConsopts scripts that wil add to the
9699986Sandreas@sandberg.pp.se# above variables
9709986Sandreas@sandberg.pp.seif GetOption('verbose'):
9719986Sandreas@sandberg.pp.se    print("Reading SConsopts")
9725522Snate@binkert.orgfor bdir in [ base_dir ] + extras_dir_list:
9735227Ssaidi@eecs.umich.edu    if not isdir(bdir):
9745227Ssaidi@eecs.umich.edu        print("Error: directory '%s' does not exist" % bdir)
9755227Ssaidi@eecs.umich.edu        Exit(1)
9765227Ssaidi@eecs.umich.edu    for root, dirs, files in os.walk(bdir):
9776654Snate@binkert.org        if 'SConsopts' in files:
9786654Snate@binkert.org            if GetOption('verbose'):
9797769SAli.Saidi@ARM.com                print("Reading", joinpath(root, 'SConsopts'))
9807769SAli.Saidi@ARM.com            SConscript(joinpath(root, 'SConsopts'))
9817769SAli.Saidi@ARM.com
9827769SAli.Saidi@ARM.comall_isa_list.sort()
9835227Ssaidi@eecs.umich.eduall_gpu_isa_list.sort()
9845227Ssaidi@eecs.umich.edu
9855227Ssaidi@eecs.umich.edusticky_vars.AddVariables(
9865204Sstever@gmail.com    EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
9875204Sstever@gmail.com    EnumVariable('TARGET_GPU_ISA', 'Target GPU ISA', 'hsail', all_gpu_isa_list),
9885204Sstever@gmail.com    ListVariable('CPU_MODELS', 'CPU models',
9895204Sstever@gmail.com                 sorted(n for n,m in CpuModel.dict.iteritems() if m.default),
9905204Sstever@gmail.com                 sorted(CpuModel.dict.keys())),
9915204Sstever@gmail.com    BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger',
9925204Sstever@gmail.com                 False),
9935204Sstever@gmail.com    BoolVariable('SS_COMPATIBLE_FP',
9945204Sstever@gmail.com                 'Make floating-point results compatible with SimpleScalar',
9955204Sstever@gmail.com                 False),
9965204Sstever@gmail.com    BoolVariable('USE_SSE2',
9975204Sstever@gmail.com                 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
9985204Sstever@gmail.com                 False),
9995204Sstever@gmail.com    BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
10005204Sstever@gmail.com    BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
10015204Sstever@gmail.com    BoolVariable('USE_PNG',  'Enable support for PNG images', have_png),
10025204Sstever@gmail.com    BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability',
10036121Snate@binkert.org                 False),
10045204Sstever@gmail.com    BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models',
10057727SAli.Saidi@ARM.com                 have_kvm),
10067727SAli.Saidi@ARM.com    BoolVariable('USE_TUNTAP',
10077727SAli.Saidi@ARM.com                 'Enable using a tap device to bridge to the host network',
10087727SAli.Saidi@ARM.com                 have_tuntap),
10097727SAli.Saidi@ARM.com    BoolVariable('BUILD_GPU', 'Build the compute-GPU model', False),
101011988Sandreas.sandberg@arm.com    EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
101111988Sandreas.sandberg@arm.com                  all_protocols),
101210453SAndrew.Bardsley@arm.com    EnumVariable('BACKTRACE_IMPL', 'Post-mortem dump implementation',
101310453SAndrew.Bardsley@arm.com                 backtrace_impls[-1], backtrace_impls)
101410453SAndrew.Bardsley@arm.com    )
101510453SAndrew.Bardsley@arm.com
101610453SAndrew.Bardsley@arm.com# These variables get exported to #defines in config/*.hh (see src/SConscript).
101710453SAndrew.Bardsley@arm.comexport_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 'TARGET_ISA', 'TARGET_GPU_ISA',
101810453SAndrew.Bardsley@arm.com                'CP_ANNOTATE', 'USE_POSIX_CLOCK', 'USE_KVM', 'USE_TUNTAP',
101910453SAndrew.Bardsley@arm.com                'PROTOCOL', 'HAVE_PROTOBUF', 'HAVE_VALGRIND',
102010453SAndrew.Bardsley@arm.com                'HAVE_PERF_ATTR_EXCLUDE_HOST', 'USE_PNG']
102110453SAndrew.Bardsley@arm.com
102210160Sandreas.hansson@arm.com###################################################
102310453SAndrew.Bardsley@arm.com#
102410453SAndrew.Bardsley@arm.com# Define a SCons builder for configuration flag headers.
102510453SAndrew.Bardsley@arm.com#
102610453SAndrew.Bardsley@arm.com###################################################
102710453SAndrew.Bardsley@arm.com
102810453SAndrew.Bardsley@arm.com# This function generates a config header file that #defines the
102910453SAndrew.Bardsley@arm.com# variable symbol to the current variable setting (0 or 1).  The source
103010453SAndrew.Bardsley@arm.com# operands are the name of the variable and a Value node containing the
10319812Sandreas.hansson@arm.com# value of the variable.
103210453SAndrew.Bardsley@arm.comdef build_config_file(target, source, env):
103310453SAndrew.Bardsley@arm.com    (variable, value) = [s.get_contents() for s in source]
103410453SAndrew.Bardsley@arm.com    f = file(str(target[0]), 'w')
103510453SAndrew.Bardsley@arm.com    print('#define', variable, value, file=f)
103610453SAndrew.Bardsley@arm.com    f.close()
103710453SAndrew.Bardsley@arm.com    return None
103810453SAndrew.Bardsley@arm.com
103910453SAndrew.Bardsley@arm.com# Combine the two functions into a scons Action object.
104010453SAndrew.Bardsley@arm.comconfig_action = MakeAction(build_config_file, Transform("CONFIG H", 2))
104110453SAndrew.Bardsley@arm.com
104210453SAndrew.Bardsley@arm.com# The emitter munges the source & target node lists to reflect what
104310453SAndrew.Bardsley@arm.com# we're really doing.
10447727SAli.Saidi@ARM.comdef config_emitter(target, source, env):
104510453SAndrew.Bardsley@arm.com    # extract variable name from Builder arg
104610453SAndrew.Bardsley@arm.com    variable = str(target[0])
104710453SAndrew.Bardsley@arm.com    # True target is config header file
104810453SAndrew.Bardsley@arm.com    target = joinpath('config', variable.lower() + '.hh')
104910453SAndrew.Bardsley@arm.com    val = env[variable]
10503118Sstever@eecs.umich.edu    if isinstance(val, bool):
105110453SAndrew.Bardsley@arm.com        # Force value to 0/1
105210453SAndrew.Bardsley@arm.com        val = int(val)
105310453SAndrew.Bardsley@arm.com    elif isinstance(val, str):
105410453SAndrew.Bardsley@arm.com        val = '"' + val + '"'
10553118Sstever@eecs.umich.edu
10563483Ssaidi@eecs.umich.edu    # Sources are variable name & value (packaged in SCons Value nodes)
10573494Ssaidi@eecs.umich.edu    return ([target], [Value(variable), Value(val)])
10583494Ssaidi@eecs.umich.edu
10593483Ssaidi@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action)
10603483Ssaidi@eecs.umich.edu
10613483Ssaidi@eecs.umich.edumain.Append(BUILDERS = { 'ConfigFile' : config_builder })
10623053Sstever@eecs.umich.edu
10633053Sstever@eecs.umich.edu###################################################
10643918Ssaidi@eecs.umich.edu#
10653053Sstever@eecs.umich.edu# Builders for static and shared partially linked object files.
10663053Sstever@eecs.umich.edu#
10673053Sstever@eecs.umich.edu###################################################
10683053Sstever@eecs.umich.edu
10693053Sstever@eecs.umich.edupartial_static_builder = Builder(action=SCons.Defaults.LinkAction,
10709396Sandreas.hansson@arm.com                                 src_suffix='$OBJSUFFIX',
10719396Sandreas.hansson@arm.com                                 src_builder=['StaticObject', 'Object'],
10729396Sandreas.hansson@arm.com                                 LINKFLAGS='$PLINKFLAGS',
10739396Sandreas.hansson@arm.com                                 LIBS='')
10749396Sandreas.hansson@arm.com
10759396Sandreas.hansson@arm.comdef partial_shared_emitter(target, source, env):
10769396Sandreas.hansson@arm.com    for tgt in target:
10779396Sandreas.hansson@arm.com        tgt.attributes.shared = 1
10789396Sandreas.hansson@arm.com    return (target, source)
10799477Sandreas.hansson@arm.compartial_shared_builder = Builder(action=SCons.Defaults.ShLinkAction,
10809396Sandreas.hansson@arm.com                                 emitter=partial_shared_emitter,
10819477Sandreas.hansson@arm.com                                 src_suffix='$SHOBJSUFFIX',
10829477Sandreas.hansson@arm.com                                 src_builder='SharedObject',
10839477Sandreas.hansson@arm.com                                 SHLINKFLAGS='$PSHLINKFLAGS',
10849477Sandreas.hansson@arm.com                                 LIBS='')
10859396Sandreas.hansson@arm.com
10867840Snate@binkert.orgmain.Append(BUILDERS = { 'PartialShared' : partial_shared_builder,
10877865Sgblack@eecs.umich.edu                         'PartialStatic' : partial_static_builder })
10887865Sgblack@eecs.umich.edu
10897865Sgblack@eecs.umich.edu# builds in ext are shared across all configs in the build root.
10907865Sgblack@eecs.umich.eduext_dir = abspath(joinpath(str(main.root), 'ext'))
10917865Sgblack@eecs.umich.eduext_build_dirs = []
10927840Snate@binkert.orgfor root, dirs, files in os.walk(ext_dir):
10939900Sandreas@sandberg.pp.se    if 'SConscript' in files:
10949900Sandreas@sandberg.pp.se        build_dir = os.path.relpath(root, ext_dir)
10959900Sandreas@sandberg.pp.se        ext_build_dirs.append(build_dir)
10969900Sandreas@sandberg.pp.se        main.SConscript(joinpath(root, 'SConscript'),
109710456SCurtis.Dunham@arm.com                        variant_dir=joinpath(build_root, build_dir))
109810456SCurtis.Dunham@arm.com
109910456SCurtis.Dunham@arm.commain.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
110010456SCurtis.Dunham@arm.com
110110456SCurtis.Dunham@arm.com###################################################
110210456SCurtis.Dunham@arm.com#
110310456SCurtis.Dunham@arm.com# This builder and wrapper method are used to set up a directory with
110410456SCurtis.Dunham@arm.com# switching headers. Those are headers which are in a generic location and
110510456SCurtis.Dunham@arm.com# that include more specific headers from a directory chosen at build time
110610456SCurtis.Dunham@arm.com# based on the current build settings.
11079045SAli.Saidi@ARM.com#
110811235Sandreas.sandberg@arm.com###################################################
110911235Sandreas.sandberg@arm.com
111011235Sandreas.sandberg@arm.comdef build_switching_header(target, source, env):
111111235Sandreas.sandberg@arm.com    path = str(target[0])
111211235Sandreas.sandberg@arm.com    subdir = str(source[0])
111311235Sandreas.sandberg@arm.com    dp, fp = os.path.split(path)
111411235Sandreas.sandberg@arm.com    dp = os.path.relpath(os.path.realpath(dp),
111511235Sandreas.sandberg@arm.com                         os.path.realpath(env['BUILDDIR']))
111611811Sbaz21@cam.ac.uk    with open(path, 'w') as hdr:
111711811Sbaz21@cam.ac.uk        print('#include "%s/%s/%s"' % (dp, subdir, fp), file=hdr)
111811811Sbaz21@cam.ac.uk
111911811Sbaz21@cam.ac.ukswitching_header_action = MakeAction(build_switching_header,
112011811Sbaz21@cam.ac.uk                                     Transform('GENERATE'))
112111235Sandreas.sandberg@arm.com
112211235Sandreas.sandberg@arm.comswitching_header_builder = Builder(action=switching_header_action,
112311235Sandreas.sandberg@arm.com                                   source_factory=Value,
112411235Sandreas.sandberg@arm.com                                   single_source=True)
112511235Sandreas.sandberg@arm.com
112611235Sandreas.sandberg@arm.commain.Append(BUILDERS = { 'SwitchingHeader': switching_header_builder })
112711235Sandreas.sandberg@arm.com
11287840Snate@binkert.orgdef switching_headers(self, headers, source):
11297840Snate@binkert.org    for header in headers:
11307840Snate@binkert.org        self.SwitchingHeader(header, source)
11311858SN/A
11321858SN/Amain.AddMethod(switching_headers, 'SwitchingHeaders')
11331858SN/A
11341858SN/A###################################################
11351858SN/A#
11361858SN/A# Define build environments for selected configurations.
113712230Sgiacomo.travaglini@arm.com#
113812230Sgiacomo.travaglini@arm.com###################################################
113912230Sgiacomo.travaglini@arm.com
114012230Sgiacomo.travaglini@arm.comfor variant_path in variant_paths:
114112230Sgiacomo.travaglini@arm.com    if not GetOption('silent'):
114212230Sgiacomo.travaglini@arm.com        print("Building in", variant_path)
114312230Sgiacomo.travaglini@arm.com
114412230Sgiacomo.travaglini@arm.com    # Make a copy of the build-root environment to use for this config.
11459903Sandreas.hansson@arm.com    env = main.Clone()
11469903Sandreas.hansson@arm.com    env['BUILDDIR'] = variant_path
11479903Sandreas.hansson@arm.com
11489903Sandreas.hansson@arm.com    # variant_dir is the tail component of build path, and is used to
114910841Sandreas.sandberg@arm.com    # determine the build parameters (e.g., 'ALPHA_SE')
11509651SAndreas.Sandberg@ARM.com    (build_root, variant_dir) = splitpath(variant_path)
11519903Sandreas.hansson@arm.com
11529651SAndreas.Sandberg@ARM.com    # Set env variables according to the build directory config.
11539651SAndreas.Sandberg@ARM.com    sticky_vars.files = []
115412056Sgabeblack@google.com    # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in
115512056Sgabeblack@google.com    # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke
115612056Sgabeblack@google.com    # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings.
115712056Sgabeblack@google.com    current_vars_file = joinpath(build_root, 'variables', variant_dir)
115812056Sgabeblack@google.com    if isfile(current_vars_file):
115910841Sandreas.sandberg@arm.com        sticky_vars.files.append(current_vars_file)
116010841Sandreas.sandberg@arm.com        if not GetOption('silent'):
116110841Sandreas.sandberg@arm.com            print("Using saved variables file %s" % current_vars_file)
116210841Sandreas.sandberg@arm.com    elif variant_dir in ext_build_dirs:
116310841Sandreas.sandberg@arm.com        # Things in ext are built without a variant directory.
116410841Sandreas.sandberg@arm.com        continue
11659651SAndreas.Sandberg@ARM.com    else:
11669651SAndreas.Sandberg@ARM.com        # Build dir-specific variables file doesn't exist.
11679651SAndreas.Sandberg@ARM.com
11689651SAndreas.Sandberg@ARM.com        # Make sure the directory is there so we can create it later
11699651SAndreas.Sandberg@ARM.com        opt_dir = dirname(current_vars_file)
11709651SAndreas.Sandberg@ARM.com        if not isdir(opt_dir):
11719651SAndreas.Sandberg@ARM.com            mkdir(opt_dir)
11729651SAndreas.Sandberg@ARM.com
11739651SAndreas.Sandberg@ARM.com        # Get default build variables from source tree.  Variables are
117410841Sandreas.sandberg@arm.com        # normally determined by name of $VARIANT_DIR, but can be
117510841Sandreas.sandberg@arm.com        # overridden by '--default=' arg on command line.
117610841Sandreas.sandberg@arm.com        default = GetOption('default')
117710841Sandreas.sandberg@arm.com        opts_dir = joinpath(main.root.abspath, 'build_opts')
117810841Sandreas.sandberg@arm.com        if default:
117910841Sandreas.sandberg@arm.com            default_vars_files = [joinpath(build_root, 'variables', default),
118010860Sandreas.sandberg@arm.com                                  joinpath(opts_dir, default)]
118110841Sandreas.sandberg@arm.com        else:
118210841Sandreas.sandberg@arm.com            default_vars_files = [joinpath(opts_dir, variant_dir)]
118310841Sandreas.sandberg@arm.com        existing_files = filter(isfile, default_vars_files)
118410841Sandreas.sandberg@arm.com        if existing_files:
118510841Sandreas.sandberg@arm.com            default_vars_file = existing_files[0]
118610841Sandreas.sandberg@arm.com            sticky_vars.files.append(default_vars_file)
118710841Sandreas.sandberg@arm.com            print("Variables file %s not found,\n  using defaults in %s"
118810841Sandreas.sandberg@arm.com                  % (current_vars_file, default_vars_file))
118910841Sandreas.sandberg@arm.com        else:
119010841Sandreas.sandberg@arm.com            print("Error: cannot find variables file %s or "
119110841Sandreas.sandberg@arm.com                  "default file(s) %s"
11929651SAndreas.Sandberg@ARM.com                  % (current_vars_file, ' or '.join(default_vars_files)))
11939651SAndreas.Sandberg@ARM.com            Exit(1)
11949986Sandreas@sandberg.pp.se
11959986Sandreas@sandberg.pp.se    # Apply current variable settings to env
11969986Sandreas@sandberg.pp.se    sticky_vars.Update(env)
11979986Sandreas@sandberg.pp.se
11989986Sandreas@sandberg.pp.se    help_texts["local_vars"] += \
11999986Sandreas@sandberg.pp.se        "Build variables for %s:\n" % variant_dir \
12005863Snate@binkert.org                 + sticky_vars.GenerateHelpText(env)
12015863Snate@binkert.org
12025863Snate@binkert.org    # Process variable settings.
12035863Snate@binkert.org
12046121Snate@binkert.org    if not have_fenv and env['USE_FENV']:
12051858SN/A        print("Warning: <fenv.h> not available; "
12065863Snate@binkert.org              "forcing USE_FENV to False in", variant_dir + ".")
12075863Snate@binkert.org        env['USE_FENV'] = False
12085863Snate@binkert.org
12095863Snate@binkert.org    if not env['USE_FENV']:
12105863Snate@binkert.org        print("Warning: No IEEE FP rounding mode control in",
12112139SN/A              variant_dir + ".")
12124202Sbinkertn@umich.edu        print("         FP results may deviate slightly from other platforms.")
121311308Santhony.gutierrez@amd.com
12144202Sbinkertn@umich.edu    if not have_png and env['USE_PNG']:
121511308Santhony.gutierrez@amd.com        print("Warning: <png.h> not available; "
12162139SN/A              "forcing USE_PNG to False in", variant_dir + ".")
12176994Snate@binkert.org        env['USE_PNG'] = False
12186994Snate@binkert.org
12196994Snate@binkert.org    if env['USE_PNG']:
12206994Snate@binkert.org        env.Append(LIBS=['png'])
12216994Snate@binkert.org
12226994Snate@binkert.org    if env['EFENCE']:
12236994Snate@binkert.org        env.Append(LIBS=['efence'])
12246994Snate@binkert.org
122510319SAndreas.Sandberg@ARM.com    if env['USE_KVM']:
12266994Snate@binkert.org        if not have_kvm:
12276994Snate@binkert.org            print("Warning: Can not enable KVM, host seems to "
12286994Snate@binkert.org                  "lack KVM support")
12296994Snate@binkert.org            env['USE_KVM'] = False
12306994Snate@binkert.org        elif not is_isa_kvm_compatible(env['TARGET_ISA']):
12316994Snate@binkert.org            print("Info: KVM support disabled due to unsupported host and "
12326994Snate@binkert.org                  "target ISA combination")
12336994Snate@binkert.org            env['USE_KVM'] = False
12346994Snate@binkert.org
12356994Snate@binkert.org    if env['USE_TUNTAP']:
12366994Snate@binkert.org        if not have_tuntap:
12372155SN/A            print("Warning: Can't connect EtherTap with a tap device.")
12385863Snate@binkert.org            env['USE_TUNTAP'] = False
12391869SN/A
12401869SN/A    if env['BUILD_GPU']:
12415863Snate@binkert.org        env.Append(CPPDEFINES=['BUILD_GPU'])
12425863Snate@binkert.org
12434202Sbinkertn@umich.edu    # Warn about missing optional functionality
12446108Snate@binkert.org    if env['USE_KVM']:
12456108Snate@binkert.org        if not main['HAVE_PERF_ATTR_EXCLUDE_HOST']:
12466108Snate@binkert.org            print("Warning: perf_event headers lack support for the "
12476108Snate@binkert.org                  "exclude_host attribute. KVM instruction counts will "
12489219Spower.jg@gmail.com                  "be inaccurate.")
12499219Spower.jg@gmail.com
12509219Spower.jg@gmail.com    # Save sticky variable settings back to current variables file
12519219Spower.jg@gmail.com    sticky_vars.Save(current_vars_file, env)
12529219Spower.jg@gmail.com
12539219Spower.jg@gmail.com    if env['USE_SSE2']:
12549219Spower.jg@gmail.com        env.Append(CCFLAGS=['-msse2'])
12559219Spower.jg@gmail.com
12564202Sbinkertn@umich.edu    # The src/SConscript file sets up the build rules in 'env' according
12575863Snate@binkert.org    # to the configured variables.  It returns a list of environments,
125810135SCurtis.Dunham@arm.com    # one for each variant build (debug, opt, etc.)
12598474Sgblack@eecs.umich.edu    SConscript('src/SConscript', variant_dir = variant_path, exports = 'env')
12605742Snate@binkert.org
12618268Ssteve.reinhardt@amd.com# base help text
12628268Ssteve.reinhardt@amd.comHelp('''
12638268Ssteve.reinhardt@amd.comUsage: scons [scons options] [build variables] [target(s)]
12645742Snate@binkert.org
12655341Sstever@gmail.comExtra scons options:
12668474Sgblack@eecs.umich.edu%(options)s
12678474Sgblack@eecs.umich.edu
12685342Sstever@gmail.comGlobal build variables:
12694202Sbinkertn@umich.edu%(global_vars)s
12704202Sbinkertn@umich.edu
127111308Santhony.gutierrez@amd.com%(local_vars)s
12724202Sbinkertn@umich.edu''' % help_texts)
12735863Snate@binkert.org