+if main['GCC']:
+ # Check for a supported version of gcc. >= 4.8 is chosen for its
+ # level of c++11 support. See
+ # http://gcc.gnu.org/projects/cxx0x.html for details.
+ gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
+ if compareVersions(gcc_version, "4.8") < 0:
+ print 'Error: gcc version 4.8 or newer required.'
+ print ' Installed version:', gcc_version
+ Exit(1)
+
+ main['GCC_VERSION'] = gcc_version
+
+ # gcc from version 4.8 and above generates "rep; ret" instructions
+ # to avoid performance penalties on certain AMD chips. Older
+ # assemblers detect this as an error, "Error: expecting string
+ # instruction after `rep'"
+ as_version_raw = readCommand([main['AS'], '-v', '/dev/null'],
+ exception=False).split()
+
+ # version strings may contain extra distro-specific
+ # qualifiers, so play it safe and keep only what comes before
+ # the first hyphen
+ as_version = as_version_raw[-1].split('-')[0] if as_version_raw else None
+
+ if not as_version or compareVersions(as_version, "2.23") < 0:
+ print termcap.Yellow + termcap.Bold + \
+ 'Warning: This combination of gcc and binutils have' + \
+ ' known incompatibilities.\n' + \
+ ' If you encounter build problems, please update ' + \
+ 'binutils to 2.23.' + \
+ termcap.Normal
+
+ # Make sure we warn if the user has requested to compile with the
+ # Undefined Benahvior Sanitizer and this version of gcc does not
+ # support it.
+ if GetOption('with_ubsan') and \
+ compareVersions(gcc_version, '4.9') < 0:
+ print termcap.Yellow + termcap.Bold + \
+ 'Warning: UBSan is only supported using gcc 4.9 and later.' + \
+ termcap.Normal
+
+ # Add the appropriate Link-Time Optimization (LTO) flags
+ # unless LTO is explicitly turned off. Note that these flags
+ # are only used by the fast target.
+ if not GetOption('no_lto'):
+ # Pass the LTO flag when compiling to produce GIMPLE
+ # output, we merely create the flags here and only append
+ # them later
+ main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
+
+ # Use the same amount of jobs for LTO as we are running
+ # scons with
+ main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
+
+ main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
+ '-fno-builtin-realloc', '-fno-builtin-free'])
+
+ # add option to check for undeclared overrides
+ if compareVersions(gcc_version, "5.0") > 0:
+ main.Append(CCFLAGS=['-Wno-error=suggest-override'])
+
+elif main['CLANG']:
+ # Check for a supported version of clang, >= 3.1 is needed to
+ # support similar features as gcc 4.8. See
+ # http://clang.llvm.org/cxx_status.html for details
+ clang_version_re = re.compile(".* version (\d+\.\d+)")
+ clang_version_match = clang_version_re.search(CXX_version)
+ if (clang_version_match):
+ clang_version = clang_version_match.groups()[0]
+ if compareVersions(clang_version, "3.1") < 0:
+ print 'Error: clang version 3.1 or newer required.'
+ print ' Installed version:', clang_version
+ Exit(1)
+ else:
+ print 'Error: Unable to determine clang version.'
+ Exit(1)
+
+ # clang has a few additional warnings that we disable, extraneous
+ # parantheses are allowed due to Ruby's printing of the AST,
+ # finally self assignments are allowed as the generated CPU code
+ # is relying on this
+ main.Append(CCFLAGS=['-Wno-parentheses',
+ '-Wno-self-assign',
+ # Some versions of libstdc++ (4.8?) seem to
+ # use struct hash and class hash
+ # interchangeably.
+ '-Wno-mismatched-tags',
+ ])
+
+ main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
+
+ # On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
+ # opposed to libstdc++, as the later is dated.
+ if sys.platform == "darwin":
+ main.Append(CXXFLAGS=['-stdlib=libc++'])
+ main.Append(LIBS=['c++'])
+
+else:
+ print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
+ print "Don't know what compiler options to use for your compiler."
+ print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX']
+ print termcap.Yellow + ' version:' + termcap.Normal,
+ if not CXX_version:
+ print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
+ termcap.Normal
+ else:
+ print CXX_version.replace('\n', '<nl>')
+ print " If you're trying to use a compiler other than GCC"
+ print " or clang, there appears to be something wrong with your"
+ print " environment."
+ print " "
+ print " If you are trying to use a compiler other than those listed"
+ print " above you will need to ease fix SConstruct and "
+ print " src/SConscript to support that compiler."
+ Exit(1)
+
+# Set up common yacc/bison flags (needed for Ruby)
+main['YACCFLAGS'] = '-d'
+main['YACCHXXFILESUFFIX'] = '.hh'
+