scons: Bump the compiler version to gcc 4.6 and clang 3.0

This patch bumps the supported version of gcc from 4.4 to 4.6, and
clang from 2.9 to 3.0. This enables, amongst other things, range-based
for loops, lambda expressions, etc. The STL implementation shipping
with 4.6 also has a full functional implementation of unique_ptr and
shared_ptr.
This commit is contained in:
Andreas Hansson 2014-06-10 17:44:39 -04:00
parent 4a98b0cd59
commit fdb965f5c1
2 changed files with 25 additions and 33 deletions

View file

@ -568,52 +568,46 @@ else:
Exit(1) Exit(1)
if main['GCC']: if main['GCC']:
# Check for a supported version of gcc, >= 4.4 is needed for c++0x # Check for a supported version of gcc. >= 4.6 is chosen for its
# support. See http://gcc.gnu.org/projects/cxx0x.html for details # level of c++11 support. See
# http://gcc.gnu.org/projects/cxx0x.html for details. 4.6 is also
# the first version with proper LTO support.
gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
if compareVersions(gcc_version, "4.4") < 0: if compareVersions(gcc_version, "4.6") < 0:
print 'Error: gcc version 4.4 or newer required.' print 'Error: gcc version 4.6 or newer required.'
print ' Installed version:', gcc_version print ' Installed version:', gcc_version
Exit(1) Exit(1)
main['GCC_VERSION'] = gcc_version main['GCC_VERSION'] = gcc_version
# Check for versions with bugs # Add the appropriate Link-Time Optimization (LTO) flags
if not compareVersions(gcc_version, '4.4.1') or \ # unless LTO is explicitly turned off. Note that these flags
not compareVersions(gcc_version, '4.4.2'): # are only used by the fast target.
print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' if not GetOption('no_lto'):
main.Append(CCFLAGS=['-fno-tree-vectorize']) # 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')]
# LTO support is only really working properly from 4.6 and beyond # Use the same amount of jobs for LTO as we are running
if compareVersions(gcc_version, '4.6') >= 0: # scons with, we hardcode the use of the linker plugin
# Add the appropriate Link-Time Optimization (LTO) flags # which requires either gold or GNU ld >= 2.21
# unless LTO is explicitly turned off. Note that these flags main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'),
# are only used by the fast target. '-fuse-linker-plugin']
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, we hardcode the use of the linker plugin
# which requires either gold or GNU ld >= 2.21
main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'),
'-fuse-linker-plugin']
main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc', main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
'-fno-builtin-realloc', '-fno-builtin-free']) '-fno-builtin-realloc', '-fno-builtin-free'])
elif main['CLANG']: elif main['CLANG']:
# Check for a supported version of clang, >= 2.9 is needed to # Check for a supported version of clang, >= 3.0 is needed to
# support similar features as gcc 4.4. See # support similar features as gcc 4.6. See
# http://clang.llvm.org/cxx_status.html for details # http://clang.llvm.org/cxx_status.html for details
clang_version_re = re.compile(".* version (\d+\.\d+)") clang_version_re = re.compile(".* version (\d+\.\d+)")
clang_version_match = clang_version_re.search(CXX_version) clang_version_match = clang_version_re.search(CXX_version)
if (clang_version_match): if (clang_version_match):
clang_version = clang_version_match.groups()[0] clang_version = clang_version_match.groups()[0]
if compareVersions(clang_version, "2.9") < 0: if compareVersions(clang_version, "3.0") < 0:
print 'Error: clang version 2.9 or newer required.' print 'Error: clang version 3.0 or newer required.'
print ' Installed version:', clang_version print ' Installed version:', clang_version
Exit(1) Exit(1)
else: else:

View file

@ -925,10 +925,8 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
# warnings about uninitialized variables and missing field # warnings about uninitialized variables and missing field
# initializers. # initializers.
swig_env.Append(CCFLAGS=['-Wno-uninitialized', swig_env.Append(CCFLAGS=['-Wno-uninitialized',
'-Wno-missing-field-initializers']) '-Wno-missing-field-initializers',
'-Wno-unused-but-set-variable'])
if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
# If gcc supports it, also warn for deletion of derived # If gcc supports it, also warn for deletion of derived
# classes with non-virtual desctructors. For gcc >= 4.7 we # classes with non-virtual desctructors. For gcc >= 4.7 we