scons: Use c++0x with gcc >= 4.4 instead of 4.6

This patch shifts the version of gcc for which we enable c++0x from
4.6 to 4.4 The more long term plan is to see what the c++0x features
can bring and what level of support would be enabled simply by bumping
the required version of gcc from 4.3 to 4.4.

A few minor things had to be fixed in the code base, most notably the
choice of a hashmap implementation. In the Ruby Sequencer there were
also a few minor issues that gcc 4.4 was not too happy about.
This commit is contained in:
Andreas Hansson 2012-09-14 12:13:18 -04:00
parent ae1652b813
commit 806a1144ce
3 changed files with 20 additions and 11 deletions

View file

@ -502,7 +502,9 @@ if main['GCC']:
not compareVersions(gcc_version, '4.4.2'): not compareVersions(gcc_version, '4.4.2'):
print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
main.Append(CCFLAGS=['-fno-tree-vectorize']) main.Append(CCFLAGS=['-fno-tree-vectorize'])
if compareVersions(gcc_version, '4.6') >= 0: # c++0x support in gcc is useful already from 4.4, see
# http://gcc.gnu.org/projects/cxx0x.html for details
if compareVersions(gcc_version, '4.4') >= 0:
main.Append(CXXFLAGS=['-std=c++0x']) main.Append(CXXFLAGS=['-std=c++0x'])
elif main['ICC']: elif main['ICC']:
pass #Fix me... add warning flags once we clean up icc warnings pass #Fix me... add warning flags once we clean up icc warnings
@ -535,6 +537,8 @@ elif main['CLANG']:
# of if-statements # of if-statements
main.Append(CCFLAGS=['-Wno-parentheses']) main.Append(CCFLAGS=['-Wno-parentheses'])
# clang 2.9 does not play well with c++0x as it ships with C++
# headers that produce errors, this was fixed in 3.0
if compareVersions(clang_version, "3") >= 0: if compareVersions(clang_version, "3") >= 0:
main.Append(CXXFLAGS=['-std=c++0x']) main.Append(CXXFLAGS=['-std=c++0x'])
else: else:

View file

@ -50,9 +50,9 @@
// clang, use unordered_map // clang, use unordered_map
// we need to determine what is available, as in the non-c++0x case, // we need to determine what is available, as in the non-c++0x case,
// e.g. gcc >= 4.3 and <= 4.5, the containers are in the std::tr1 // i.e. gcc == 4.3, the containers are in the std::tr1 namespace, and
// namespace, and only gcc >= 4.6 (with -std=c++0x) adds the final // only gcc >= 4.4 (with -std=c++0x) adds the final container
// container implementation in the std namespace // implementation in the std namespace
#if defined(__clang__) #if defined(__clang__)
// align with -std=c++0x only for clang >= 3.0 in CCFLAGS and also // align with -std=c++0x only for clang >= 3.0 in CCFLAGS and also
@ -67,9 +67,9 @@
#define HAVE_STD_TR1_UNORDERED_MAP 1 #define HAVE_STD_TR1_UNORDERED_MAP 1
#endif #endif
#else #else
// align with -std=c++0x only for gcc >= 4.6 in CCFLAGS, contrary to // align with -std=c++0x only for gcc >= 4.4 in CCFLAGS, contrary to
// clang we can rely entirely on the compiler version // clang we can rely entirely on the compiler version
#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __GNUC__ > 4)
#define HAVE_STD_UNORDERED_MAP 1 #define HAVE_STD_UNORDERED_MAP 1
#else #else
#define HAVE_STD_TR1_UNORDERED_MAP 1 #define HAVE_STD_TR1_UNORDERED_MAP 1
@ -101,17 +101,17 @@
#if HAVE_STD_UNORDERED_MAP #if HAVE_STD_UNORDERED_MAP
// clang or gcc >= 4.6 // clang or gcc >= 4.4
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
// note that this assumes that -std=c++0x is added to the command line // note that this assumes that -std=c++0x is added to the command line
// which is done in the SConstruct CXXFLAGS for gcc >= 4.6 and clang // which is done in the SConstruct CXXFLAGS for gcc >= 4.4 and clang
// >= 3.0 // >= 3.0
#define __hash_namespace std #define __hash_namespace std
#define __hash_namespace_begin namespace std { #define __hash_namespace_begin namespace std {
#define __hash_namespace_end } #define __hash_namespace_end }
#else #else
// clang <= 3.0, gcc >= 4.3 and < 4.6 // clang <= 3.0, gcc == 4.3
#include <tr1/unordered_map> #include <tr1/unordered_map>
#include <tr1/unordered_set> #include <tr1/unordered_set>
#define __hash_namespace std::tr1 #define __hash_namespace std::tr1

View file

@ -214,6 +214,11 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type)
Address line_addr(pkt->getAddr()); Address line_addr(pkt->getAddr());
line_addr.makeLineAddress(); line_addr.makeLineAddress();
// Create a default entry, mapping the address to NULL, the cast is
// there to make gcc 4.4 happy
RequestTable::value_type default_entry(line_addr,
(SequencerRequest*) NULL);
if ((request_type == RubyRequestType_ST) || if ((request_type == RubyRequestType_ST) ||
(request_type == RubyRequestType_RMW_Read) || (request_type == RubyRequestType_RMW_Read) ||
(request_type == RubyRequestType_RMW_Write) || (request_type == RubyRequestType_RMW_Write) ||
@ -231,7 +236,7 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type)
} }
pair<RequestTable::iterator, bool> r = pair<RequestTable::iterator, bool> r =
m_writeRequestTable.insert(RequestTable::value_type(line_addr, 0)); m_writeRequestTable.insert(default_entry);
if (r.second) { if (r.second) {
RequestTable::iterator i = r.first; RequestTable::iterator i = r.first;
i->second = new SequencerRequest(pkt, request_type, i->second = new SequencerRequest(pkt, request_type,
@ -251,7 +256,7 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type)
} }
pair<RequestTable::iterator, bool> r = pair<RequestTable::iterator, bool> r =
m_readRequestTable.insert(RequestTable::value_type(line_addr, 0)); m_readRequestTable.insert(default_entry);
if (r.second) { if (r.second) {
RequestTable::iterator i = r.first; RequestTable::iterator i = r.first;