summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:07 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:07 -0500
commit08a5fd328b25d2ff431dc8f593c2d1bf3816b36e (patch)
tree085f00bcddb25887b90c68ed41fcd87dc01f91a6
parent5eddb6387765240730bfb1c57f481133d3a3c737 (diff)
downloadgem5-08a5fd328b25d2ff431dc8f593c2d1bf3816b36e.tar.xz
scons: Unify the flags shared by gcc and clang
This patch restructures and unifies the flags used by gcc and clang as they are largely the same. The common parts are now dealt with in a shared block of code, and the few bits and pieces that are specifically affecting either gcc or clang are done separately.
-rwxr-xr-xSConstruct59
-rwxr-xr-xsrc/SConscript33
2 files changed, 63 insertions, 29 deletions
diff --git a/SConstruct b/SConstruct
index 0540ba80f..4ca4ae56d 100755
--- a/SConstruct
+++ b/SConstruct
@@ -515,6 +515,38 @@ if main['GCC'] + main['CLANG'] > 1:
Exit(1)
# Set up default C++ compiler flags
+if main['GCC'] or main['CLANG']:
+ # As gcc and clang share many flags, do the common parts here
+ main.Append(CCFLAGS=['-pipe'])
+ main.Append(CCFLAGS=['-fno-strict-aliasing'])
+ # Enable -Wall and then disable the few warnings that we
+ # consistently violate
+ main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
+ # We always compile using C++11, but only gcc >= 4.7 and clang 3.1
+ # actually use that name, so we stick with c++0x
+ main.Append(CXXFLAGS=['-std=c++0x'])
+ # Add selected sanity checks from -Wextra
+ main.Append(CXXFLAGS=['-Wmissing-field-initializers',
+ '-Woverloaded-virtual'])
+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)
+
if main['GCC']:
# Check for a supported version of gcc, >= 4.4 is needed for c++0x
# support. See http://gcc.gnu.org/projects/cxx0x.html for details
@@ -525,12 +557,6 @@ if main['GCC']:
Exit(1)
main['GCC_VERSION'] = gcc_version
- main.Append(CCFLAGS=['-pipe'])
- main.Append(CCFLAGS=['-fno-strict-aliasing'])
- main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
- main.Append(CXXFLAGS=['-Wmissing-field-initializers',
- '-Woverloaded-virtual'])
- main.Append(CXXFLAGS=['-std=c++0x'])
# Check for versions with bugs
if not compareVersions(gcc_version, '4.4.1') or \
@@ -571,17 +597,16 @@ elif main['CLANG']:
print 'Error: Unable to determine clang version.'
Exit(1)
- main.Append(CCFLAGS=['-pipe'])
- main.Append(CCFLAGS=['-fno-strict-aliasing'])
- main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
- main.Append(CCFLAGS=['-Wno-tautological-compare'])
- main.Append(CCFLAGS=['-Wno-self-assign'])
- # Ruby makes frequent use of extraneous parantheses in the printing
- # of if-statements
- main.Append(CCFLAGS=['-Wno-parentheses'])
- main.Append(CXXFLAGS=['-Wmissing-field-initializers',
- '-Woverloaded-virtual'])
- main.Append(CXXFLAGS=['-std=c++0x'])
+ # 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'])
+
# On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
# opposed to libstdc++ to make the transition from TR1 to
# C++11. See http://libcxx.llvm.org. However, clang has chosen a
diff --git a/src/SConscript b/src/SConscript
index 465bae70e..8dccd0900 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -893,25 +893,34 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
swig_env = new_env.Clone()
swig_env.Append(CCFLAGS='-Werror')
+
+ # Both gcc and clang have issues with unused labels and values in
+ # the SWIG generated code
+ swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value'])
+
+ # Add additional warnings here that should not be applied to
+ # the SWIG generated code
+ new_env.Append(CXXFLAGS='-Wmissing-declarations')
+
if env['GCC']:
- swig_env.Append(CCFLAGS=['-Wno-uninitialized', '-Wno-sign-compare',
- '-Wno-parentheses', '-Wno-unused-label',
- '-Wno-unused-value'])
+ # Depending on the SWIG version, we also need to supress
+ # warnings about missing field initializers.
+ swig_env.Append(CCFLAGS='-Wno-missing-field-initializers')
+
if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
- # Add additional warnings here that should not be applied to
- # the SWIG generated code
- new_env.Append(CXXFLAGS='-Wmissing-declarations')
+ # If gcc supports it, also warn for deletion of derived
+ # classes with non-virtual desctructors. For gcc >= 4.7 we
+ # also have to disable warnings about the SWIG code having
+ # potentially uninitialized variables.
if compareVersions(env['GCC_VERSION'], '4.7') >= 0:
new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor')
+ swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized')
if env['CLANG']:
- swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value'])
-
- # Add additional warnings here that should not be applied to
- # the SWIG generated code
- new_env.Append(CXXFLAGS=['-Wmissing-declarations',
- '-Wdelete-non-virtual-dtor'])
+ # Always enable the warning for deletion of derived classes
+ # with non-virtual destructors
+ new_env.Append(CXXFLAGS=['-Wdelete-non-virtual-dtor'])
werror_env = new_env.Clone()
werror_env.Append(CCFLAGS='-Werror')