SConstruct revision 12246:9ffa51416f39
1# -*- mode:python -*-
2
3# Copyright (c) 2013, 2015-2017 ARM Limited
4# All rights reserved.
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating
9# to a hardware implementation of the functionality of the software
10# licensed hereunder.  You may use the software subject to the license
11# terms below provided that you ensure that this notice is replicated
12# unmodified and in its entirety in all distributions of the software,
13# modified or unmodified, in source code or in binary form.
14#
15# Copyright (c) 2011 Advanced Micro Devices, Inc.
16# Copyright (c) 2009 The Hewlett-Packard Development Company
17# Copyright (c) 2004-2005 The Regents of The University of Michigan
18# All rights reserved.
19#
20# Redistribution and use in source and binary forms, with or without
21# modification, are permitted provided that the following conditions are
22# met: redistributions of source code must retain the above copyright
23# notice, this list of conditions and the following disclaimer;
24# redistributions in binary form must reproduce the above copyright
25# notice, this list of conditions and the following disclaimer in the
26# documentation and/or other materials provided with the distribution;
27# neither the name of the copyright holders nor the names of its
28# contributors may be used to endorse or promote products derived from
29# this software without specific prior written permission.
30#
31# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42#
43# Authors: Steve Reinhardt
44#          Nathan Binkert
45
46###################################################
47#
48# SCons top-level build description (SConstruct) file.
49#
50# While in this directory ('gem5'), just type 'scons' to build the default
51# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
52# to build some other configuration (e.g., 'build/ALPHA/gem5.opt' for
53# the optimized full-system version).
54#
55# You can build gem5 in a different directory as long as there is a
56# 'build/<CONFIG>' somewhere along the target path.  The build system
57# expects that all configs under the same build directory are being
58# built for the same host system.
59#
60# Examples:
61#
62#   The following two commands are equivalent.  The '-u' option tells
63#   scons to search up the directory tree for this SConstruct file.
64#   % cd <path-to-src>/gem5 ; scons build/ALPHA/gem5.debug
65#   % cd <path-to-src>/gem5/build/ALPHA; scons -u gem5.debug
66#
67#   The following two commands are equivalent and demonstrate building
68#   in a directory outside of the source tree.  The '-C' option tells
69#   scons to chdir to the specified directory to find this SConstruct
70#   file.
71#   % cd <path-to-src>/gem5 ; scons /local/foo/build/ALPHA/gem5.debug
72#   % cd /local/foo/build/ALPHA; scons -C <path-to-src>/gem5 gem5.debug
73#
74# You can use 'scons -H' to print scons options.  If you're in this
75# 'gem5' directory (or use -u or -C to tell scons where to find this
76# file), you can use 'scons -h' to print all the gem5-specific build
77# options as well.
78#
79###################################################
80
81# Global Python includes
82import itertools
83import os
84import re
85import shutil
86import subprocess
87import sys
88
89from os import mkdir, environ
90from os.path import abspath, basename, dirname, expanduser, normpath
91from os.path import exists,  isdir, isfile
92from os.path import join as joinpath, split as splitpath
93
94# SCons includes
95import SCons
96import SCons.Node
97
98from m5.util import compareVersions, readCommand
99
100help_texts = {
101    "options" : "",
102    "global_vars" : "",
103    "local_vars" : ""
104}
105
106Export("help_texts")
107
108
109# There's a bug in scons in that (1) by default, the help texts from
110# AddOption() are supposed to be displayed when you type 'scons -h'
111# and (2) you can override the help displayed by 'scons -h' using the
112# Help() function, but these two features are incompatible: once
113# you've overridden the help text using Help(), there's no way to get
114# at the help texts from AddOptions.  See:
115#     http://scons.tigris.org/issues/show_bug.cgi?id=2356
116#     http://scons.tigris.org/issues/show_bug.cgi?id=2611
117# This hack lets us extract the help text from AddOptions and
118# re-inject it via Help().  Ideally someday this bug will be fixed and
119# we can just use AddOption directly.
120def AddLocalOption(*args, **kwargs):
121    col_width = 30
122
123    help = "  " + ", ".join(args)
124    if "help" in kwargs:
125        length = len(help)
126        if length >= col_width:
127            help += "\n" + " " * col_width
128        else:
129            help += " " * (col_width - length)
130        help += kwargs["help"]
131    help_texts["options"] += help + "\n"
132
133    AddOption(*args, **kwargs)
134
135AddLocalOption('--colors', dest='use_colors', action='store_true',
136               help="Add color to abbreviated scons output")
137AddLocalOption('--no-colors', dest='use_colors', action='store_false',
138               help="Don't add color to abbreviated scons output")
139AddLocalOption('--with-cxx-config', dest='with_cxx_config',
140               action='store_true',
141               help="Build with support for C++-based configuration")
142AddLocalOption('--default', dest='default', type='string', action='store',
143               help='Override which build_opts file to use for defaults')
144AddLocalOption('--ignore-style', dest='ignore_style', action='store_true',
145               help='Disable style checking hooks')
146AddLocalOption('--no-lto', dest='no_lto', action='store_true',
147               help='Disable Link-Time Optimization for fast')
148AddLocalOption('--force-lto', dest='force_lto', action='store_true',
149               help='Use Link-Time Optimization instead of partial linking' +
150                    ' when the compiler doesn\'t support using them together.')
151AddLocalOption('--update-ref', dest='update_ref', action='store_true',
152               help='Update test reference outputs')
153AddLocalOption('--verbose', dest='verbose', action='store_true',
154               help='Print full tool command lines')
155AddLocalOption('--without-python', dest='without_python',
156               action='store_true',
157               help='Build without Python configuration support')
158AddLocalOption('--without-tcmalloc', dest='without_tcmalloc',
159               action='store_true',
160               help='Disable linking against tcmalloc')
161AddLocalOption('--with-ubsan', dest='with_ubsan', action='store_true',
162               help='Build with Undefined Behavior Sanitizer if available')
163AddLocalOption('--with-asan', dest='with_asan', action='store_true',
164               help='Build with Address Sanitizer if available')
165
166if GetOption('no_lto') and GetOption('force_lto'):
167    print '--no-lto and --force-lto are mutually exclusive'
168    Exit(1)
169
170########################################################################
171#
172# Set up the main build environment.
173#
174########################################################################
175
176main = Environment()
177
178from gem5_scons import Transform
179from gem5_scons.util import get_termcap
180termcap = get_termcap()
181
182main_dict_keys = main.Dictionary().keys()
183
184# Check that we have a C/C++ compiler
185if not ('CC' in main_dict_keys and 'CXX' in main_dict_keys):
186    print "No C++ compiler installed (package g++ on Ubuntu and RedHat)"
187    Exit(1)
188
189###################################################
190#
191# Figure out which configurations to set up based on the path(s) of
192# the target(s).
193#
194###################################################
195
196# Find default configuration & binary.
197Default(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA/gem5.debug'))
198
199# helper function: find last occurrence of element in list
200def rfind(l, elt, offs = -1):
201    for i in range(len(l)+offs, 0, -1):
202        if l[i] == elt:
203            return i
204    raise ValueError, "element not found"
205
206# Take a list of paths (or SCons Nodes) and return a list with all
207# paths made absolute and ~-expanded.  Paths will be interpreted
208# relative to the launch directory unless a different root is provided
209def makePathListAbsolute(path_list, root=GetLaunchDir()):
210    return [abspath(joinpath(root, expanduser(str(p))))
211            for p in path_list]
212
213# Each target must have 'build' in the interior of the path; the
214# directory below this will determine the build parameters.  For
215# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
216# recognize that ALPHA_SE specifies the configuration because it
217# follow 'build' in the build path.
218
219# The funky assignment to "[:]" is needed to replace the list contents
220# in place rather than reassign the symbol to a new list, which
221# doesn't work (obviously!).
222BUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS)
223
224# Generate a list of the unique build roots and configs that the
225# collected targets reference.
226variant_paths = []
227build_root = None
228for t in BUILD_TARGETS:
229    path_dirs = t.split('/')
230    try:
231        build_top = rfind(path_dirs, 'build', -2)
232    except:
233        print "Error: no non-leaf 'build' dir found on target path", t
234        Exit(1)
235    this_build_root = joinpath('/',*path_dirs[:build_top+1])
236    if not build_root:
237        build_root = this_build_root
238    else:
239        if this_build_root != build_root:
240            print "Error: build targets not under same build root\n"\
241                  "  %s\n  %s" % (build_root, this_build_root)
242            Exit(1)
243    variant_path = joinpath('/',*path_dirs[:build_top+2])
244    if variant_path not in variant_paths:
245        variant_paths.append(variant_path)
246
247# Make sure build_root exists (might not if this is the first build there)
248if not isdir(build_root):
249    mkdir(build_root)
250main['BUILDROOT'] = build_root
251
252Export('main')
253
254main.SConsignFile(joinpath(build_root, "sconsign"))
255
256# Default duplicate option is to use hard links, but this messes up
257# when you use emacs to edit a file in the target dir, as emacs moves
258# file to file~ then copies to file, breaking the link.  Symbolic
259# (soft) links work better.
260main.SetOption('duplicate', 'soft-copy')
261
262#
263# Set up global sticky variables... these are common to an entire build
264# tree (not specific to a particular build like ALPHA_SE)
265#
266
267global_vars_file = joinpath(build_root, 'variables.global')
268
269global_vars = Variables(global_vars_file, args=ARGUMENTS)
270
271global_vars.AddVariables(
272    ('CC', 'C compiler', environ.get('CC', main['CC'])),
273    ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
274    ('PROTOC', 'protoc tool', environ.get('PROTOC', 'protoc')),
275    ('BATCH', 'Use batch pool for build and tests', False),
276    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
277    ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
278    ('EXTRAS', 'Add extra directories to the compilation', '')
279    )
280
281# Update main environment with values from ARGUMENTS & global_vars_file
282global_vars.Update(main)
283help_texts["global_vars"] += global_vars.GenerateHelpText(main)
284
285# Save sticky variable settings back to current variables file
286global_vars.Save(global_vars_file, main)
287
288# Parse EXTRAS variable to build list of all directories where we're
289# look for sources etc.  This list is exported as extras_dir_list.
290base_dir = main.srcdir.abspath
291if main['EXTRAS']:
292    extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':'))
293else:
294    extras_dir_list = []
295
296Export('base_dir')
297Export('extras_dir_list')
298
299# the ext directory should be on the #includes path
300main.Append(CPPPATH=[Dir('ext')])
301
302# Add shared top-level headers
303main.Prepend(CPPPATH=Dir('include'))
304
305if GetOption('verbose'):
306    def MakeAction(action, string, *args, **kwargs):
307        return Action(action, *args, **kwargs)
308else:
309    MakeAction = Action
310    main['CCCOMSTR']        = Transform("CC")
311    main['CXXCOMSTR']       = Transform("CXX")
312    main['ASCOMSTR']        = Transform("AS")
313    main['ARCOMSTR']        = Transform("AR", 0)
314    main['LINKCOMSTR']      = Transform("LINK", 0)
315    main['SHLINKCOMSTR']    = Transform("SHLINK", 0)
316    main['RANLIBCOMSTR']    = Transform("RANLIB", 0)
317    main['M4COMSTR']        = Transform("M4")
318    main['SHCCCOMSTR']      = Transform("SHCC")
319    main['SHCXXCOMSTR']     = Transform("SHCXX")
320Export('MakeAction')
321
322# Initialize the Link-Time Optimization (LTO) flags
323main['LTO_CCFLAGS'] = []
324main['LTO_LDFLAGS'] = []
325
326# According to the readme, tcmalloc works best if the compiler doesn't
327# assume that we're using the builtin malloc and friends. These flags
328# are compiler-specific, so we need to set them after we detect which
329# compiler we're using.
330main['TCMALLOC_CCFLAGS'] = []
331
332CXX_version = readCommand([main['CXX'],'--version'], exception=False)
333CXX_V = readCommand([main['CXX'],'-V'], exception=False)
334
335main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
336main['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
337if main['GCC'] + main['CLANG'] > 1:
338    print 'Error: How can we have two at the same time?'
339    Exit(1)
340
341# Set up default C++ compiler flags
342if main['GCC'] or main['CLANG']:
343    # As gcc and clang share many flags, do the common parts here
344    main.Append(CCFLAGS=['-pipe'])
345    main.Append(CCFLAGS=['-fno-strict-aliasing'])
346    # Enable -Wall and -Wextra and then disable the few warnings that
347    # we consistently violate
348    main.Append(CCFLAGS=['-Wall', '-Wundef', '-Wextra',
349                         '-Wno-sign-compare', '-Wno-unused-parameter'])
350    # We always compile using C++11
351    main.Append(CXXFLAGS=['-std=c++11'])
352    if sys.platform.startswith('freebsd'):
353        main.Append(CCFLAGS=['-I/usr/local/include'])
354        main.Append(CXXFLAGS=['-I/usr/local/include'])
355
356    main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '')
357    main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}')
358    main['PLINKFLAGS'] = main.subst('${LINKFLAGS}')
359    shared_partial_flags = ['-r', '-nostdlib']
360    main.Append(PSHLINKFLAGS=shared_partial_flags)
361    main.Append(PLINKFLAGS=shared_partial_flags)
362else:
363    print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
364    print "Don't know what compiler options to use for your compiler."
365    print termcap.Yellow + '       compiler:' + termcap.Normal, main['CXX']
366    print termcap.Yellow + '       version:' + termcap.Normal,
367    if not CXX_version:
368        print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
369               termcap.Normal
370    else:
371        print CXX_version.replace('\n', '<nl>')
372    print "       If you're trying to use a compiler other than GCC"
373    print "       or clang, there appears to be something wrong with your"
374    print "       environment."
375    print "       "
376    print "       If you are trying to use a compiler other than those listed"
377    print "       above you will need to ease fix SConstruct and "
378    print "       src/SConscript to support that compiler."
379    Exit(1)
380
381if main['GCC']:
382    # Check for a supported version of gcc. >= 4.8 is chosen for its
383    # level of c++11 support. See
384    # http://gcc.gnu.org/projects/cxx0x.html for details.
385    gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
386    if compareVersions(gcc_version, "4.8") < 0:
387        print 'Error: gcc version 4.8 or newer required.'
388        print '       Installed version:', gcc_version
389        Exit(1)
390
391    main['GCC_VERSION'] = gcc_version
392
393    if compareVersions(gcc_version, '4.9') >= 0:
394        # Incremental linking with LTO is currently broken in gcc versions
395        # 4.9 and above. A version where everything works completely hasn't
396        # yet been identified.
397        #
398        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548
399        main['BROKEN_INCREMENTAL_LTO'] = True
400    if compareVersions(gcc_version, '6.0') >= 0:
401        # gcc versions 6.0 and greater accept an -flinker-output flag which
402        # selects what type of output the linker should generate. This is
403        # necessary for incremental lto to work, but is also broken in
404        # current versions of gcc. It may not be necessary in future
405        # versions. We add it here since it might be, and as a reminder that
406        # it exists. It's excluded if lto is being forced.
407        #
408        # https://gcc.gnu.org/gcc-6/changes.html
409        # https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03161.html
410        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69866
411        if not GetOption('force_lto'):
412            main.Append(PSHLINKFLAGS='-flinker-output=rel')
413            main.Append(PLINKFLAGS='-flinker-output=rel')
414
415    # gcc from version 4.8 and above generates "rep; ret" instructions
416    # to avoid performance penalties on certain AMD chips. Older
417    # assemblers detect this as an error, "Error: expecting string
418    # instruction after `rep'"
419    as_version_raw = readCommand([main['AS'], '-v', '/dev/null',
420                                  '-o', '/dev/null'],
421                                 exception=False).split()
422
423    # version strings may contain extra distro-specific
424    # qualifiers, so play it safe and keep only what comes before
425    # the first hyphen
426    as_version = as_version_raw[-1].split('-')[0] if as_version_raw else None
427
428    if not as_version or compareVersions(as_version, "2.23") < 0:
429        print termcap.Yellow + termcap.Bold + \
430            'Warning: This combination of gcc and binutils have' + \
431            ' known incompatibilities.\n' + \
432            '         If you encounter build problems, please update ' + \
433            'binutils to 2.23.' + \
434            termcap.Normal
435
436    # Make sure we warn if the user has requested to compile with the
437    # Undefined Benahvior Sanitizer and this version of gcc does not
438    # support it.
439    if GetOption('with_ubsan') and \
440            compareVersions(gcc_version, '4.9') < 0:
441        print termcap.Yellow + termcap.Bold + \
442            'Warning: UBSan is only supported using gcc 4.9 and later.' + \
443            termcap.Normal
444
445    disable_lto = GetOption('no_lto')
446    if not disable_lto and main.get('BROKEN_INCREMENTAL_LTO', False) and \
447            not GetOption('force_lto'):
448        print termcap.Yellow + termcap.Bold + \
449            'Warning: Your compiler doesn\'t support incremental linking' + \
450            ' and lto at the same time, so lto is being disabled. To force' + \
451            ' lto on anyway, use the --force-lto option. That will disable' + \
452            ' partial linking.' + \
453            termcap.Normal
454        disable_lto = True
455
456    # Add the appropriate Link-Time Optimization (LTO) flags
457    # unless LTO is explicitly turned off. Note that these flags
458    # are only used by the fast target.
459    if not disable_lto:
460        # Pass the LTO flag when compiling to produce GIMPLE
461        # output, we merely create the flags here and only append
462        # them later
463        main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
464
465        # Use the same amount of jobs for LTO as we are running
466        # scons with
467        main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
468
469    main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
470                                  '-fno-builtin-realloc', '-fno-builtin-free'])
471
472    # add option to check for undeclared overrides
473    if compareVersions(gcc_version, "5.0") > 0:
474        main.Append(CCFLAGS=['-Wno-error=suggest-override'])
475
476elif main['CLANG']:
477    # Check for a supported version of clang, >= 3.1 is needed to
478    # support similar features as gcc 4.8. See
479    # http://clang.llvm.org/cxx_status.html for details
480    clang_version_re = re.compile(".* version (\d+\.\d+)")
481    clang_version_match = clang_version_re.search(CXX_version)
482    if (clang_version_match):
483        clang_version = clang_version_match.groups()[0]
484        if compareVersions(clang_version, "3.1") < 0:
485            print 'Error: clang version 3.1 or newer required.'
486            print '       Installed version:', clang_version
487            Exit(1)
488    else:
489        print 'Error: Unable to determine clang version.'
490        Exit(1)
491
492    # clang has a few additional warnings that we disable, extraneous
493    # parantheses are allowed due to Ruby's printing of the AST,
494    # finally self assignments are allowed as the generated CPU code
495    # is relying on this
496    main.Append(CCFLAGS=['-Wno-parentheses',
497                         '-Wno-self-assign',
498                         # Some versions of libstdc++ (4.8?) seem to
499                         # use struct hash and class hash
500                         # interchangeably.
501                         '-Wno-mismatched-tags',
502                         ])
503
504    main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
505
506    # On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
507    # opposed to libstdc++, as the later is dated.
508    if sys.platform == "darwin":
509        main.Append(CXXFLAGS=['-stdlib=libc++'])
510        main.Append(LIBS=['c++'])
511
512    # On FreeBSD we need libthr.
513    if sys.platform.startswith('freebsd'):
514        main.Append(LIBS=['thr'])
515
516else:
517    print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
518    print "Don't know what compiler options to use for your compiler."
519    print termcap.Yellow + '       compiler:' + termcap.Normal, main['CXX']
520    print termcap.Yellow + '       version:' + termcap.Normal,
521    if not CXX_version:
522        print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
523               termcap.Normal
524    else:
525        print CXX_version.replace('\n', '<nl>')
526    print "       If you're trying to use a compiler other than GCC"
527    print "       or clang, there appears to be something wrong with your"
528    print "       environment."
529    print "       "
530    print "       If you are trying to use a compiler other than those listed"
531    print "       above you will need to ease fix SConstruct and "
532    print "       src/SConscript to support that compiler."
533    Exit(1)
534
535# Set up common yacc/bison flags (needed for Ruby)
536main['YACCFLAGS'] = '-d'
537main['YACCHXXFILESUFFIX'] = '.hh'
538
539# Do this after we save setting back, or else we'll tack on an
540# extra 'qdo' every time we run scons.
541if main['BATCH']:
542    main['CC']     = main['BATCH_CMD'] + ' ' + main['CC']
543    main['CXX']    = main['BATCH_CMD'] + ' ' + main['CXX']
544    main['AS']     = main['BATCH_CMD'] + ' ' + main['AS']
545    main['AR']     = main['BATCH_CMD'] + ' ' + main['AR']
546    main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB']
547
548if sys.platform == 'cygwin':
549    # cygwin has some header file issues...
550    main.Append(CCFLAGS=["-Wno-uninitialized"])
551
552# Check for the protobuf compiler
553protoc_version = readCommand([main['PROTOC'], '--version'],
554                             exception='').split()
555
556# First two words should be "libprotoc x.y.z"
557if len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
558    print termcap.Yellow + termcap.Bold + \
559        'Warning: Protocol buffer compiler (protoc) not found.\n' + \
560        '         Please install protobuf-compiler for tracing support.' + \
561        termcap.Normal
562    main['PROTOC'] = False
563else:
564    # Based on the availability of the compress stream wrappers,
565    # require 2.1.0
566    min_protoc_version = '2.1.0'
567    if compareVersions(protoc_version[1], min_protoc_version) < 0:
568        print termcap.Yellow + termcap.Bold + \
569            'Warning: protoc version', min_protoc_version, \
570            'or newer required.\n' + \
571            '         Installed version:', protoc_version[1], \
572            termcap.Normal
573        main['PROTOC'] = False
574    else:
575        # Attempt to determine the appropriate include path and
576        # library path using pkg-config, that means we also need to
577        # check for pkg-config. Note that it is possible to use
578        # protobuf without the involvement of pkg-config. Later on we
579        # check go a library config check and at that point the test
580        # will fail if libprotobuf cannot be found.
581        if readCommand(['pkg-config', '--version'], exception=''):
582            try:
583                # Attempt to establish what linking flags to add for protobuf
584                # using pkg-config
585                main.ParseConfig('pkg-config --cflags --libs-only-L protobuf')
586            except:
587                print termcap.Yellow + termcap.Bold + \
588                    'Warning: pkg-config could not get protobuf flags.' + \
589                    termcap.Normal
590
591
592# Check for 'timeout' from GNU coreutils. If present, regressions will
593# be run with a time limit. We require version 8.13 since we rely on
594# support for the '--foreground' option.
595if sys.platform.startswith('freebsd'):
596    timeout_lines = readCommand(['gtimeout', '--version'],
597                                exception='').splitlines()
598else:
599    timeout_lines = readCommand(['timeout', '--version'],
600                                exception='').splitlines()
601# Get the first line and tokenize it
602timeout_version = timeout_lines[0].split() if timeout_lines else []
603main['TIMEOUT'] =  timeout_version and \
604    compareVersions(timeout_version[-1], '8.13') >= 0
605
606# Add a custom Check function to test for structure members.
607def CheckMember(context, include, decl, member, include_quotes="<>"):
608    context.Message("Checking for member %s in %s..." %
609                    (member, decl))
610    text = """
611#include %(header)s
612int main(){
613  %(decl)s test;
614  (void)test.%(member)s;
615  return 0;
616};
617""" % { "header" : include_quotes[0] + include + include_quotes[1],
618        "decl" : decl,
619        "member" : member,
620        }
621
622    ret = context.TryCompile(text, extension=".cc")
623    context.Result(ret)
624    return ret
625
626# Platform-specific configuration.  Note again that we assume that all
627# builds under a given build root run on the same host platform.
628conf = Configure(main,
629                 conf_dir = joinpath(build_root, '.scons_config'),
630                 log_file = joinpath(build_root, 'scons_config.log'),
631                 custom_tests = {
632        'CheckMember' : CheckMember,
633        })
634
635# Check if we should compile a 64 bit binary on Mac OS X/Darwin
636try:
637    import platform
638    uname = platform.uname()
639    if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
640        if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
641            main.Append(CCFLAGS=['-arch', 'x86_64'])
642            main.Append(CFLAGS=['-arch', 'x86_64'])
643            main.Append(LINKFLAGS=['-arch', 'x86_64'])
644            main.Append(ASFLAGS=['-arch', 'x86_64'])
645except:
646    pass
647
648# Recent versions of scons substitute a "Null" object for Configure()
649# when configuration isn't necessary, e.g., if the "--help" option is
650# present.  Unfortuantely this Null object always returns false,
651# breaking all our configuration checks.  We replace it with our own
652# more optimistic null object that returns True instead.
653if not conf:
654    def NullCheck(*args, **kwargs):
655        return True
656
657    class NullConf:
658        def __init__(self, env):
659            self.env = env
660        def Finish(self):
661            return self.env
662        def __getattr__(self, mname):
663            return NullCheck
664
665    conf = NullConf(main)
666
667# Cache build files in the supplied directory.
668if main['M5_BUILD_CACHE']:
669    print 'Using build cache located at', main['M5_BUILD_CACHE']
670    CacheDir(main['M5_BUILD_CACHE'])
671
672main['USE_PYTHON'] = not GetOption('without_python')
673if main['USE_PYTHON']:
674    # Find Python include and library directories for embedding the
675    # interpreter. We rely on python-config to resolve the appropriate
676    # includes and linker flags. ParseConfig does not seem to understand
677    # the more exotic linker flags such as -Xlinker and -export-dynamic so
678    # we add them explicitly below. If you want to link in an alternate
679    # version of python, see above for instructions on how to invoke
680    # scons with the appropriate PATH set.
681    #
682    # First we check if python2-config exists, else we use python-config
683    python_config = readCommand(['which', 'python2-config'],
684                                exception='').strip()
685    if not os.path.exists(python_config):
686        python_config = readCommand(['which', 'python-config'],
687                                    exception='').strip()
688    py_includes = readCommand([python_config, '--includes'],
689                              exception='').split()
690    # Strip the -I from the include folders before adding them to the
691    # CPPPATH
692    main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes))
693
694    # Read the linker flags and split them into libraries and other link
695    # flags. The libraries are added later through the call the CheckLib.
696    py_ld_flags = readCommand([python_config, '--ldflags'],
697        exception='').split()
698    py_libs = []
699    for lib in py_ld_flags:
700         if not lib.startswith('-l'):
701             main.Append(LINKFLAGS=[lib])
702         else:
703             lib = lib[2:]
704             if lib not in py_libs:
705                 py_libs.append(lib)
706
707    # verify that this stuff works
708    if not conf.CheckHeader('Python.h', '<>'):
709        print "Error: can't find Python.h header in", py_includes
710        print "Install Python headers (package python-dev on Ubuntu and RedHat)"
711        Exit(1)
712
713    for lib in py_libs:
714        if not conf.CheckLib(lib):
715            print "Error: can't find library %s required by python" % lib
716            Exit(1)
717
718# On Solaris you need to use libsocket for socket ops
719if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
720   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
721       print "Can't find library with socket calls (e.g. accept())"
722       Exit(1)
723
724# Check for zlib.  If the check passes, libz will be automatically
725# added to the LIBS environment variable.
726if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
727    print 'Error: did not find needed zlib compression library '\
728          'and/or zlib.h header file.'
729    print '       Please install zlib and try again.'
730    Exit(1)
731
732# If we have the protobuf compiler, also make sure we have the
733# development libraries. If the check passes, libprotobuf will be
734# automatically added to the LIBS environment variable. After
735# this, we can use the HAVE_PROTOBUF flag to determine if we have
736# got both protoc and libprotobuf available.
737main['HAVE_PROTOBUF'] = main['PROTOC'] and \
738    conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
739                            'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
740
741# If we have the compiler but not the library, print another warning.
742if main['PROTOC'] and not main['HAVE_PROTOBUF']:
743    print termcap.Yellow + termcap.Bold + \
744        'Warning: did not find protocol buffer library and/or headers.\n' + \
745    '       Please install libprotobuf-dev for tracing support.' + \
746    termcap.Normal
747
748# Check for librt.
749have_posix_clock = \
750    conf.CheckLibWithHeader(None, 'time.h', 'C',
751                            'clock_nanosleep(0,0,NULL,NULL);') or \
752    conf.CheckLibWithHeader('rt', 'time.h', 'C',
753                            'clock_nanosleep(0,0,NULL,NULL);')
754
755have_posix_timers = \
756    conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ], 'C',
757                            'timer_create(CLOCK_MONOTONIC, NULL, NULL);')
758
759if not GetOption('without_tcmalloc'):
760    if conf.CheckLib('tcmalloc'):
761        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
762    elif conf.CheckLib('tcmalloc_minimal'):
763        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
764    else:
765        print termcap.Yellow + termcap.Bold + \
766              "You can get a 12% performance improvement by "\
767              "installing tcmalloc (libgoogle-perftools-dev package "\
768              "on Ubuntu or RedHat)." + termcap.Normal
769
770
771# Detect back trace implementations. The last implementation in the
772# list will be used by default.
773backtrace_impls = [ "none" ]
774
775if conf.CheckLibWithHeader(None, 'execinfo.h', 'C',
776                           'backtrace_symbols_fd((void*)0, 0, 0);'):
777    backtrace_impls.append("glibc")
778elif conf.CheckLibWithHeader('execinfo', 'execinfo.h', 'C',
779                           'backtrace_symbols_fd((void*)0, 0, 0);'):
780    # NetBSD and FreeBSD need libexecinfo.
781    backtrace_impls.append("glibc")
782    main.Append(LIBS=['execinfo'])
783
784if backtrace_impls[-1] == "none":
785    default_backtrace_impl = "none"
786    print termcap.Yellow + termcap.Bold + \
787        "No suitable back trace implementation found." + \
788        termcap.Normal
789
790if not have_posix_clock:
791    print "Can't find library for POSIX clocks."
792
793# Check for <fenv.h> (C99 FP environment control)
794have_fenv = conf.CheckHeader('fenv.h', '<>')
795if not have_fenv:
796    print "Warning: Header file <fenv.h> not found."
797    print "         This host has no IEEE FP rounding mode control."
798
799# Check for <png.h> (libpng library needed if wanting to dump
800# frame buffer image in png format)
801have_png = conf.CheckHeader('png.h', '<>')
802if not have_png:
803    print "Warning: Header file <png.h> not found."
804    print "         This host has no libpng library."
805    print "         Disabling support for PNG framebuffers."
806
807# Check if we should enable KVM-based hardware virtualization. The API
808# we rely on exists since version 2.6.36 of the kernel, but somehow
809# the KVM_API_VERSION does not reflect the change. We test for one of
810# the types as a fall back.
811have_kvm = conf.CheckHeader('linux/kvm.h', '<>')
812if not have_kvm:
813    print "Info: Compatible header file <linux/kvm.h> not found, " \
814        "disabling KVM support."
815
816# Check if the TUN/TAP driver is available.
817have_tuntap = conf.CheckHeader('linux/if_tun.h', '<>')
818if not have_tuntap:
819    print "Info: Compatible header file <linux/if_tun.h> not found."
820
821# x86 needs support for xsave. We test for the structure here since we
822# won't be able to run new tests by the time we know which ISA we're
823# targeting.
824have_kvm_xsave = conf.CheckTypeSize('struct kvm_xsave',
825                                    '#include <linux/kvm.h>') != 0
826
827# Check if the requested target ISA is compatible with the host
828def is_isa_kvm_compatible(isa):
829    try:
830        import platform
831        host_isa = platform.machine()
832    except:
833        print "Warning: Failed to determine host ISA."
834        return False
835
836    if not have_posix_timers:
837        print "Warning: Can not enable KVM, host seems to lack support " \
838            "for POSIX timers"
839        return False
840
841    if isa == "arm":
842        return host_isa in ( "armv7l", "aarch64" )
843    elif isa == "x86":
844        if host_isa != "x86_64":
845            return False
846
847        if not have_kvm_xsave:
848            print "KVM on x86 requires xsave support in kernel headers."
849            return False
850
851        return True
852    else:
853        return False
854
855
856# Check if the exclude_host attribute is available. We want this to
857# get accurate instruction counts in KVM.
858main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
859    'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
860
861
862######################################################################
863#
864# Finish the configuration
865#
866main = conf.Finish()
867
868######################################################################
869#
870# Collect all non-global variables
871#
872
873# Define the universe of supported ISAs
874all_isa_list = [ ]
875all_gpu_isa_list = [ ]
876Export('all_isa_list')
877Export('all_gpu_isa_list')
878
879class CpuModel(object):
880    '''The CpuModel class encapsulates everything the ISA parser needs to
881    know about a particular CPU model.'''
882
883    # Dict of available CPU model objects.  Accessible as CpuModel.dict.
884    dict = {}
885
886    # Constructor.  Automatically adds models to CpuModel.dict.
887    def __init__(self, name, default=False):
888        self.name = name           # name of model
889
890        # This cpu is enabled by default
891        self.default = default
892
893        # Add self to dict
894        if name in CpuModel.dict:
895            raise AttributeError, "CpuModel '%s' already registered" % name
896        CpuModel.dict[name] = self
897
898Export('CpuModel')
899
900# Sticky variables get saved in the variables file so they persist from
901# one invocation to the next (unless overridden, in which case the new
902# value becomes sticky).
903sticky_vars = Variables(args=ARGUMENTS)
904Export('sticky_vars')
905
906# Sticky variables that should be exported
907export_vars = []
908Export('export_vars')
909
910# For Ruby
911all_protocols = []
912Export('all_protocols')
913protocol_dirs = []
914Export('protocol_dirs')
915slicc_includes = []
916Export('slicc_includes')
917
918# Walk the tree and execute all SConsopts scripts that wil add to the
919# above variables
920if GetOption('verbose'):
921    print "Reading SConsopts"
922for bdir in [ base_dir ] + extras_dir_list:
923    if not isdir(bdir):
924        print "Error: directory '%s' does not exist" % bdir
925        Exit(1)
926    for root, dirs, files in os.walk(bdir):
927        if 'SConsopts' in files:
928            if GetOption('verbose'):
929                print "Reading", joinpath(root, 'SConsopts')
930            SConscript(joinpath(root, 'SConsopts'))
931
932all_isa_list.sort()
933all_gpu_isa_list.sort()
934
935sticky_vars.AddVariables(
936    EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
937    EnumVariable('TARGET_GPU_ISA', 'Target GPU ISA', 'hsail', all_gpu_isa_list),
938    ListVariable('CPU_MODELS', 'CPU models',
939                 sorted(n for n,m in CpuModel.dict.iteritems() if m.default),
940                 sorted(CpuModel.dict.keys())),
941    BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger',
942                 False),
943    BoolVariable('SS_COMPATIBLE_FP',
944                 'Make floating-point results compatible with SimpleScalar',
945                 False),
946    BoolVariable('USE_SSE2',
947                 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
948                 False),
949    BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
950    BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
951    BoolVariable('USE_PNG',  'Enable support for PNG images', have_png),
952    BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability',
953                 False),
954    BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models',
955                 have_kvm),
956    BoolVariable('USE_TUNTAP',
957                 'Enable using a tap device to bridge to the host network',
958                 have_tuntap),
959    BoolVariable('BUILD_GPU', 'Build the compute-GPU model', False),
960    EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
961                  all_protocols),
962    EnumVariable('BACKTRACE_IMPL', 'Post-mortem dump implementation',
963                 backtrace_impls[-1], backtrace_impls)
964    )
965
966# These variables get exported to #defines in config/*.hh (see src/SConscript).
967export_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 'TARGET_ISA', 'TARGET_GPU_ISA',
968                'CP_ANNOTATE', 'USE_POSIX_CLOCK', 'USE_KVM', 'USE_TUNTAP',
969                'PROTOCOL', 'HAVE_PROTOBUF', 'HAVE_PERF_ATTR_EXCLUDE_HOST',
970                'USE_PNG']
971
972###################################################
973#
974# Define a SCons builder for configuration flag headers.
975#
976###################################################
977
978# This function generates a config header file that #defines the
979# variable symbol to the current variable setting (0 or 1).  The source
980# operands are the name of the variable and a Value node containing the
981# value of the variable.
982def build_config_file(target, source, env):
983    (variable, value) = [s.get_contents() for s in source]
984    f = file(str(target[0]), 'w')
985    print >> f, '#define', variable, value
986    f.close()
987    return None
988
989# Combine the two functions into a scons Action object.
990config_action = MakeAction(build_config_file, Transform("CONFIG H", 2))
991
992# The emitter munges the source & target node lists to reflect what
993# we're really doing.
994def config_emitter(target, source, env):
995    # extract variable name from Builder arg
996    variable = str(target[0])
997    # True target is config header file
998    target = joinpath('config', variable.lower() + '.hh')
999    val = env[variable]
1000    if isinstance(val, bool):
1001        # Force value to 0/1
1002        val = int(val)
1003    elif isinstance(val, str):
1004        val = '"' + val + '"'
1005
1006    # Sources are variable name & value (packaged in SCons Value nodes)
1007    return ([target], [Value(variable), Value(val)])
1008
1009config_builder = Builder(emitter = config_emitter, action = config_action)
1010
1011main.Append(BUILDERS = { 'ConfigFile' : config_builder })
1012
1013###################################################
1014#
1015# Builders for static and shared partially linked object files.
1016#
1017###################################################
1018
1019partial_static_builder = Builder(action=SCons.Defaults.LinkAction,
1020                                 src_suffix='$OBJSUFFIX',
1021                                 src_builder=['StaticObject', 'Object'],
1022                                 LINKFLAGS='$PLINKFLAGS',
1023                                 LIBS='')
1024
1025def partial_shared_emitter(target, source, env):
1026    for tgt in target:
1027        tgt.attributes.shared = 1
1028    return (target, source)
1029partial_shared_builder = Builder(action=SCons.Defaults.ShLinkAction,
1030                                 emitter=partial_shared_emitter,
1031                                 src_suffix='$SHOBJSUFFIX',
1032                                 src_builder='SharedObject',
1033                                 SHLINKFLAGS='$PSHLINKFLAGS',
1034                                 LIBS='')
1035
1036main.Append(BUILDERS = { 'PartialShared' : partial_shared_builder,
1037                         'PartialStatic' : partial_static_builder })
1038
1039# builds in ext are shared across all configs in the build root.
1040ext_dir = abspath(joinpath(str(main.root), 'ext'))
1041ext_build_dirs = []
1042for root, dirs, files in os.walk(ext_dir):
1043    if 'SConscript' in files:
1044        build_dir = os.path.relpath(root, ext_dir)
1045        ext_build_dirs.append(build_dir)
1046        main.SConscript(joinpath(root, 'SConscript'),
1047                        variant_dir=joinpath(build_root, build_dir))
1048
1049main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
1050
1051###################################################
1052#
1053# This builder and wrapper method are used to set up a directory with
1054# switching headers. Those are headers which are in a generic location and
1055# that include more specific headers from a directory chosen at build time
1056# based on the current build settings.
1057#
1058###################################################
1059
1060def build_switching_header(target, source, env):
1061    path = str(target[0])
1062    subdir = str(source[0])
1063    dp, fp = os.path.split(path)
1064    dp = os.path.relpath(os.path.realpath(dp),
1065                         os.path.realpath(env['BUILDDIR']))
1066    with open(path, 'w') as hdr:
1067        print >>hdr, '#include "%s/%s/%s"' % (dp, subdir, fp)
1068
1069switching_header_action = MakeAction(build_switching_header,
1070                                     Transform('GENERATE'))
1071
1072switching_header_builder = Builder(action=switching_header_action,
1073                                   source_factory=Value,
1074                                   single_source=True)
1075
1076main.Append(BUILDERS = { 'SwitchingHeader': switching_header_builder })
1077
1078def switching_headers(self, headers, source):
1079    for header in headers:
1080        self.SwitchingHeader(header, source)
1081
1082main.AddMethod(switching_headers, 'SwitchingHeaders')
1083
1084###################################################
1085#
1086# Define build environments for selected configurations.
1087#
1088###################################################
1089
1090for variant_path in variant_paths:
1091    if not GetOption('silent'):
1092        print "Building in", variant_path
1093
1094    # Make a copy of the build-root environment to use for this config.
1095    env = main.Clone()
1096    env['BUILDDIR'] = variant_path
1097
1098    # variant_dir is the tail component of build path, and is used to
1099    # determine the build parameters (e.g., 'ALPHA_SE')
1100    (build_root, variant_dir) = splitpath(variant_path)
1101
1102    # Set env variables according to the build directory config.
1103    sticky_vars.files = []
1104    # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in
1105    # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke
1106    # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings.
1107    current_vars_file = joinpath(build_root, 'variables', variant_dir)
1108    if isfile(current_vars_file):
1109        sticky_vars.files.append(current_vars_file)
1110        if not GetOption('silent'):
1111            print "Using saved variables file %s" % current_vars_file
1112    elif variant_dir in ext_build_dirs:
1113        # Things in ext are built without a variant directory.
1114        continue
1115    else:
1116        # Build dir-specific variables file doesn't exist.
1117
1118        # Make sure the directory is there so we can create it later
1119        opt_dir = dirname(current_vars_file)
1120        if not isdir(opt_dir):
1121            mkdir(opt_dir)
1122
1123        # Get default build variables from source tree.  Variables are
1124        # normally determined by name of $VARIANT_DIR, but can be
1125        # overridden by '--default=' arg on command line.
1126        default = GetOption('default')
1127        opts_dir = joinpath(main.root.abspath, 'build_opts')
1128        if default:
1129            default_vars_files = [joinpath(build_root, 'variables', default),
1130                                  joinpath(opts_dir, default)]
1131        else:
1132            default_vars_files = [joinpath(opts_dir, variant_dir)]
1133        existing_files = filter(isfile, default_vars_files)
1134        if existing_files:
1135            default_vars_file = existing_files[0]
1136            sticky_vars.files.append(default_vars_file)
1137            print "Variables file %s not found,\n  using defaults in %s" \
1138                  % (current_vars_file, default_vars_file)
1139        else:
1140            print "Error: cannot find variables file %s or " \
1141                  "default file(s) %s" \
1142                  % (current_vars_file, ' or '.join(default_vars_files))
1143            Exit(1)
1144
1145    # Apply current variable settings to env
1146    sticky_vars.Update(env)
1147
1148    help_texts["local_vars"] += \
1149        "Build variables for %s:\n" % variant_dir \
1150                 + sticky_vars.GenerateHelpText(env)
1151
1152    # Process variable settings.
1153
1154    if not have_fenv and env['USE_FENV']:
1155        print "Warning: <fenv.h> not available; " \
1156              "forcing USE_FENV to False in", variant_dir + "."
1157        env['USE_FENV'] = False
1158
1159    if not env['USE_FENV']:
1160        print "Warning: No IEEE FP rounding mode control in", variant_dir + "."
1161        print "         FP results may deviate slightly from other platforms."
1162
1163    if not have_png and env['USE_PNG']:
1164        print "Warning: <png.h> not available; " \
1165              "forcing USE_PNG to False in", variant_dir + "."
1166        env['USE_PNG'] = False
1167
1168    if env['USE_PNG']:
1169        env.Append(LIBS=['png'])
1170
1171    if env['EFENCE']:
1172        env.Append(LIBS=['efence'])
1173
1174    if env['USE_KVM']:
1175        if not have_kvm:
1176            print "Warning: Can not enable KVM, host seems to lack KVM support"
1177            env['USE_KVM'] = False
1178        elif not is_isa_kvm_compatible(env['TARGET_ISA']):
1179            print "Info: KVM support disabled due to unsupported host and " \
1180                "target ISA combination"
1181            env['USE_KVM'] = False
1182
1183    if env['USE_TUNTAP']:
1184        if not have_tuntap:
1185            print "Warning: Can't connect EtherTap with a tap device."
1186            env['USE_TUNTAP'] = False
1187
1188    if env['BUILD_GPU']:
1189        env.Append(CPPDEFINES=['BUILD_GPU'])
1190
1191    # Warn about missing optional functionality
1192    if env['USE_KVM']:
1193        if not main['HAVE_PERF_ATTR_EXCLUDE_HOST']:
1194            print "Warning: perf_event headers lack support for the " \
1195                "exclude_host attribute. KVM instruction counts will " \
1196                "be inaccurate."
1197
1198    # Save sticky variable settings back to current variables file
1199    sticky_vars.Save(current_vars_file, env)
1200
1201    if env['USE_SSE2']:
1202        env.Append(CCFLAGS=['-msse2'])
1203
1204    # The src/SConscript file sets up the build rules in 'env' according
1205    # to the configured variables.  It returns a list of environments,
1206    # one for each variant build (debug, opt, etc.)
1207    SConscript('src/SConscript', variant_dir = variant_path, exports = 'env')
1208
1209# base help text
1210Help('''
1211Usage: scons [scons options] [build variables] [target(s)]
1212
1213Extra scons options:
1214%(options)s
1215
1216Global build variables:
1217%(global_vars)s
1218
1219%(local_vars)s
1220''' % help_texts)
1221