- if not compareVersions(gcc_version, '4.4.1') or \
- not compareVersions(gcc_version, '4.4.2'):
- print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
- main.Append(CCFLAGS=['-fno-tree-vectorize'])
-elif main['ICC']:
- pass #Fix me... add warning flags once we clean up icc warnings
-elif main['SUNCC']:
- main.Append(CCFLAGS=['-Qoption ccfe'])
- main.Append(CCFLAGS=['-features=gcc'])
- main.Append(CCFLAGS=['-features=extensions'])
- main.Append(CCFLAGS=['-library=stlport4'])
- main.Append(CCFLAGS=['-xar'])
- #main.Append(CCFLAGS=['-instances=semiexplicit'])
+
+ # 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'"
+ if compareVersions(gcc_version, "4.8") > 0:
+ 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'])
+
+elif main['CLANG']:
+ # Check for a supported version of clang, >= 3.1 is needed to
+ # support similar features as gcc 4.7. 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,
+ # tautological comparisons are allowed due to unsigned integers
+ # being compared to constants that happen to be 0, and 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-tautological-compare',
+ '-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++'])
+