diff options
author | Koan-Sin Tan <koansin.tan@gmail.com> | 2012-01-31 12:05:52 -0500 |
---|---|---|
committer | Koan-Sin Tan <koansin.tan@gmail.com> | 2012-01-31 12:05:52 -0500 |
commit | 7d4f18770073d968c70cd3ffcdd117f50a6056a2 (patch) | |
tree | d28ffbee135c6cac0bc89224d2bf7f98224aeb51 /SConstruct | |
parent | 4590b91fb8842f6a3b823bbc06334132de43d54b (diff) | |
download | gem5-7d4f18770073d968c70cd3ffcdd117f50a6056a2.tar.xz |
clang: Enable compiling gem5 using clang 2.9 and 3.0
This patch adds the necessary flags to the SConstruct and SConscript
files for compiling using clang 2.9 and later (on Ubuntu et al and OSX
XCode 4.2), and also cleans up a bunch of compiler warnings found by
clang. Most of the warnings are related to hidden virtual functions,
comparisons with unsigneds >= 0, and if-statements with empty
bodies. A number of mismatches between struct and class are also
fixed. clang 2.8 is not working as it has problems with class names
that occur in multiple namespaces (e.g. Statistics in
kernel_stats.hh).
clang has a bug (http://llvm.org/bugs/show_bug.cgi?id=7247) which
causes confusion between the container std::set and the function
Packet::set, and this is currently addressed by not including the
entire namespace std, but rather selecting e.g. "using std::vector" in
the appropriate places.
Diffstat (limited to 'SConstruct')
-rwxr-xr-x | SConstruct | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/SConstruct b/SConstruct index 0630cbd79..eb633c0fc 100755 --- a/SConstruct +++ b/SConstruct @@ -473,7 +473,8 @@ CXX_V = readCommand([main['CXX'],'-V'], exception=False) main['GCC'] = CXX_version and CXX_version.find('g++') >= 0 main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0 main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0 -if main['GCC'] + main['SUNCC'] + main['ICC'] > 1: +main['CLANG'] = CXX_V and CXX_V.find('clang') >= 0 +if main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1: print 'Error: How can we have two at the same time?' Exit(1) @@ -501,6 +502,24 @@ elif main['SUNCC']: main.Append(CCFLAGS=['-library=stlport4']) main.Append(CCFLAGS=['-xar']) #main.Append(CCFLAGS=['-instances=semiexplicit']) +elif main['CLANG']: + clang_version_re = re.compile(".* version (\d+\.\d+)") + clang_version_match = clang_version_re.match(CXX_version) + if (clang_version_match): + clang_version = clang_version_match.groups()[0] + if compareVersions(clang_version, "2.9") < 0: + print 'Error: clang version 2.9 or newer required.' + print ' Installed version:', clang_version + Exit(1) + else: + 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']) else: print 'Error: Don\'t know what compiler options to use for your compiler.' print ' Please fix SConstruct and src/SConscript and try again.' |