changeset 770ccf3af571 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=770ccf3af571
description:
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:
SConstruct | 21 +-
ext/libelf/SConscript | 2 +
src/SConscript | 5 +-
src/arch/alpha/tlb.cc | 4 +-
src/arch/alpha/tlb.hh | 2 +-
src/arch/arm/insts/static_inst.hh | 1 +
src/arch/arm/insts/vfp.hh | 3 +
src/arch/arm/isa/templates/basic.isa | 2 +-
src/arch/arm/miscregs.cc | 2 +-
src/arch/generic/memhelpers.hh | 4 +-
src/arch/mips/faults.cc | 2 +-
src/arch/mips/faults.hh | 2 +-
src/arch/x86/bios/acpi.hh | 8 +-
src/arch/x86/bios/intelmp.cc | 2 +-
src/arch/x86/bios/intelmp.hh | 24 +-
src/arch/x86/bios/smbios.hh | 6 +-
src/base/fast_alloc.cc | 4 -
src/base/range_map.hh | 2 +-
src/base/remote_gdb.hh | 2 +-
src/base/stl_helpers.hh | 4 +-
src/cpu/base.cc | 4 +-
src/cpu/base.hh | 12 +-
src/cpu/func_unit.hh | 6 +-
src/cpu/inorder/cpu.cc | 12 +-
src/cpu/inorder/cpu.hh | 8 +-
src/cpu/inorder/resource.cc | 2 +-
src/cpu/inorder/resource.hh | 12 +-
src/cpu/inorder/resource_pool.cc | 2 +-
src/cpu/inorder/resource_pool.hh | 2 +-
src/cpu/inorder/resources/cache_unit.hh | 3 -
src/cpu/inorder/thread_context.cc | 4 +-
src/cpu/nativetrace.hh | 2 +-
src/cpu/o3/bpred_unit.hh | 2 +-
src/cpu/o3/commit.hh | 4 +-
src/cpu/o3/cpu.cc | 11 +-
src/cpu/o3/cpu.hh | 4 +-
src/cpu/o3/decode.hh | 2 +-
src/cpu/o3/decode_impl.hh | 4 +-
src/cpu/o3/fetch.hh | 2 +-
src/cpu/o3/fu_pool.cc | 2 +-
src/cpu/o3/fu_pool.hh | 3 +-
src/cpu/o3/iew.hh | 5 +-
src/cpu/o3/iew_impl.hh | 2 +-
src/cpu/o3/inst_queue.hh | 4 +-
src/cpu/o3/inst_queue_impl.hh | 4 +-
src/cpu/o3/lsq.hh | 2 +-
src/cpu/o3/lsq_unit.hh | 2 +-
src/cpu/o3/mem_dep_unit.cc | 8 +-
src/cpu/o3/mem_dep_unit.hh | 2 +-
src/cpu/o3/rename.hh | 2 +-
src/cpu/o3/sat_counter.hh | 3 +-
src/cpu/quiesce_event.hh | 3 +-
src/cpu/sched_list.hh | 180 ----------
src/cpu/simple/atomic.cc | 6 +-
src/cpu/simple/atomic.hh | 4 +-
src/cpu/simple/base.cc | 4 +-
src/cpu/simple/base.hh | 6 +-
src/cpu/simple/timing.cc | 6 +-
src/cpu/simple/timing.hh | 4 +-
src/cpu/static_inst.hh | 2 +-
src/dev/alpha/tsunami_cchip.cc | 1 -
src/dev/alpha/tsunami_io.cc | 6 +-
src/dev/arm/pl111.cc | 9 +-
src/dev/arm/pl111.hh | 4 +-
src/dev/copy_engine.cc | 1 -
src/dev/disk_image.cc | 6 +-
src/dev/disk_image.hh | 2 +-
src/dev/ide_ctrl.cc | 5 +-
src/dev/ns_gige.cc | 42 +-
src/dev/pciconfigall.cc | 2 -
src/dev/pcidev.cc | 4 +-
src/mem/cache/base.hh | 5 +-
src/mem/cache/tags/iic.cc | 2 +-
src/mem/cache/tags/iic_repl/gen.cc | 2 +-
src/mem/cache/tags/iic_repl/gen.hh | 2 +-
src/mem/cache/tags/iic_repl/repl.hh | 2 +-
src/mem/packet.hh | 2 +-
src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc | 11 +-
src/mem/ruby/system/Sequencer.hh | 2 +-
src/python/m5/SimObject.py | 2 +-
src/sim/core.hh | 2 +-
src/sim/process.cc | 4 +-
src/sim/process.hh | 4 +-
src/sim/process_impl.hh | 2 +-
src/sim/serialize.cc | 7 +-
src/sim/sim_object.cc | 2 +-
src/sim/sim_object.hh | 3 +-
src/sim/syscall_emul.hh | 56 +-
88 files changed, 255 insertions(+), 391 deletions(-)
diffs (truncated from 1979 to 300 lines):
diff -r 2d8a57343fe3 -r 770ccf3af571 SConstruct
--- a/SConstruct Tue Jan 31 11:51:19 2012 -0500
+++ b/SConstruct Tue Jan 31 12:05:52 2012 -0500
@@ -473,7 +473,8 @@
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 @@
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.'
diff -r 2d8a57343fe3 -r 770ccf3af571 ext/libelf/SConscript
--- a/ext/libelf/SConscript Tue Jan 31 11:51:19 2012 -0500
+++ b/ext/libelf/SConscript Tue Jan 31 12:05:52 2012 -0500
@@ -94,6 +94,8 @@
major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')]
if major >= 4:
m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
+if m4env['CLANG']:
+ m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
m4env.Append(CCFLAGS=['-Wno-implicit'])
del m4env['CPPPATH']
diff -r 2d8a57343fe3 -r 770ccf3af571 src/SConscript
--- a/src/SConscript Tue Jan 31 11:51:19 2012 -0500
+++ b/src/SConscript Tue Jan 31 12:05:52 2012 -0500
@@ -854,6 +854,9 @@
swig_env.Append(CCFLAGS='-Wno-unused-label')
if compareVersions(env['GCC_VERSION'], '4.6.0') != -1:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
+ if env['CLANG']:
+ swig_env.Append(CCFLAGS=['-Wno-unused-label'])
+
werror_env = new_env.Clone()
werror_env.Append(CCFLAGS='-Werror')
@@ -928,7 +931,7 @@
# Debug binary
ccflags = {}
-if env['GCC']:
+if env['GCC'] or env['CLANG']:
if sys.platform == 'sunos5':
ccflags['debug'] = '-gstabs+'
else:
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/alpha/tlb.cc
--- a/src/arch/alpha/tlb.cc Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/alpha/tlb.cc Tue Jan 31 12:05:52 2012 -0500
@@ -63,7 +63,7 @@
: BaseTLB(p), size(p->size), nlu(0)
{
table = new TlbEntry[size];
- memset(table, 0, sizeof(TlbEntry[size]));
+ memset(table, 0, sizeof(TlbEntry) * size);
flushCache();
}
@@ -279,7 +279,7 @@
TLB::flushAll()
{
DPRINTF(TLB, "flushAll\n");
- memset(table, 0, sizeof(TlbEntry[size]));
+ memset(table, 0, sizeof(TlbEntry) * size);
flushCache();
lookupTable.clear();
nlu = 0;
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/alpha/tlb.hh
--- a/src/arch/alpha/tlb.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/alpha/tlb.hh Tue Jan 31 12:05:52 2012 -0500
@@ -49,7 +49,7 @@
namespace AlphaISA {
-class TlbEntry;
+struct TlbEntry;
class TLB : public BaseTLB
{
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/arm/insts/static_inst.hh
--- a/src/arch/arm/insts/static_inst.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/arm/insts/static_inst.hh Tue Jan 31 12:05:52 2012 -0500
@@ -46,6 +46,7 @@
#include "arch/arm/utility.hh"
#include "base/trace.hh"
#include "cpu/static_inst.hh"
+#include "sim/byteswap.hh"
namespace ArmISA
{
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/arm/insts/vfp.hh
--- a/src/arch/arm/insts/vfp.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/arm/insts/vfp.hh Tue Jan 31 12:05:52 2012 -0500
@@ -107,6 +107,9 @@
VfpRoundZero = 3
};
+static inline float bitsToFp(uint64_t, float);
+static inline uint32_t fpToBits(float);
+
template <class fpType>
static inline bool
flushToZero(fpType &op)
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/arm/isa/templates/basic.isa
--- a/src/arch/arm/isa/templates/basic.isa Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/arm/isa/templates/basic.isa Tue Jan 31 12:05:52 2012 -0500
@@ -49,7 +49,7 @@
// Basic instruction class constructor template.
def template BasicConstructor {{
- inline %(class_name)s::%(class_name)s(ExtMachInst machInst) :
%(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
+ %(class_name)s::%(class_name)s(ExtMachInst machInst) :
%(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
{
%(constructor)s;
if (!(condCode == COND_AL || condCode == COND_UC)) {
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/arm/miscregs.cc
--- a/src/arch/arm/miscregs.cc Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/arm/miscregs.cc Tue Jan 31 12:05:52 2012 -0500
@@ -411,7 +411,7 @@
}
break;
case 11:
- if (opc1 >= 0 && opc1 <=7) {
+ if (opc1 <=7) {
switch (crm) {
case 0:
case 1:
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/generic/memhelpers.hh
--- a/src/arch/generic/memhelpers.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/generic/memhelpers.hh Tue Jan 31 12:05:52 2012 -0500
@@ -64,7 +64,7 @@
memset(&mem, 0, sizeof(mem));
Fault fault = readMemTiming(xc, traceData, addr, mem, flags);
if (fault == NoFault) {
- mem = gtoh(mem);
+ mem = TheISA::gtoh(mem);
if (traceData)
traceData->setData(mem);
}
@@ -92,7 +92,7 @@
{
Fault fault = writeMemTiming(xc, traceData, mem, addr, flags, res);
if (fault == NoFault && res != NULL) {
- *res = gtoh((MemT)*res);
+ *res = TheISA::gtoh((MemT)*res);
}
return fault;
}
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/mips/faults.cc
--- a/src/arch/mips/faults.cc Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/mips/faults.cc Tue Jan 31 12:05:52 2012 -0500
@@ -98,7 +98,7 @@
template <> FaultVals MipsFault<TlbRefillFault>::vals =
{ "TLB Refill Exception", 0x180, ExcCodeDummy };
-template <> FaultVals MipsFault<TlbModifiedFault>::vals =
+template <> MipsFaultBase::FaultVals MipsFault<TlbModifiedFault>::vals =
{ "TLB Modified Exception", 0x180, ExcCodeMod };
void
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/mips/faults.hh
--- a/src/arch/mips/faults.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/mips/faults.hh Tue Jan 31 12:05:52 2012 -0500
@@ -299,7 +299,7 @@
TlbFault<TlbModifiedFault>(asid, vaddr, vpn, false)
{}
- ExcCode code() const { return vals.code; }
+ ExcCode code() const { return MipsFault<TlbModifiedFault>::code(); }
};
} // namespace MipsISA
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/x86/bios/acpi.hh
--- a/src/arch/x86/bios/acpi.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/x86/bios/acpi.hh Tue Jan 31 12:05:52 2012 -0500
@@ -48,11 +48,11 @@
class Port;
-class X86ACPIRSDPParams;
+struct X86ACPIRSDPParams;
-class X86ACPISysDescTableParams;
-class X86ACPIRSDTParams;
-class X86ACPIXSDTParams;
+struct X86ACPISysDescTableParams;
+struct X86ACPIRSDTParams;
+struct X86ACPIXSDTParams;
namespace X86ISA
{
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/x86/bios/intelmp.cc
--- a/src/arch/x86/bios/intelmp.cc Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/x86/bios/intelmp.cc Tue Jan 31 12:05:52 2012 -0500
@@ -72,7 +72,7 @@
uint8_t
writeOutField(PortProxy* proxy, Addr addr, T val)
{
- T guestVal = X86ISA::htog(val);
+ uint64_t guestVal = X86ISA::htog(val);
proxy->writeBlob(addr, (uint8_t *)(&guestVal), sizeof(T));
uint8_t checkSum = 0;
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/x86/bios/intelmp.hh
--- a/src/arch/x86/bios/intelmp.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/x86/bios/intelmp.hh Tue Jan 31 12:05:52 2012 -0500
@@ -54,24 +54,24 @@
class PortProxy;
// Config entry types
-class X86IntelMPBaseConfigEntryParams;
-class X86IntelMPExtConfigEntryParams;
+struct X86IntelMPBaseConfigEntryParams;
+struct X86IntelMPExtConfigEntryParams;
// General table structures
-class X86IntelMPConfigTableParams;
-class X86IntelMPFloatingPointerParams;
+struct X86IntelMPConfigTableParams;
+struct X86IntelMPFloatingPointerParams;
// Base entry types
-class X86IntelMPBusParams;
-class X86IntelMPIOAPICParams;
-class X86IntelMPIOIntAssignmentParams;
-class X86IntelMPLocalIntAssignmentParams;
-class X86IntelMPProcessorParams;
+struct X86IntelMPBusParams;
+struct X86IntelMPIOAPICParams;
+struct X86IntelMPIOIntAssignmentParams;
+struct X86IntelMPLocalIntAssignmentParams;
+struct X86IntelMPProcessorParams;
// Extended entry types
-class X86IntelMPAddrSpaceMappingParams;
-class X86IntelMPBusHierarchyParams;
-class X86IntelMPCompatAddrSpaceModParams;
+struct X86IntelMPAddrSpaceMappingParams;
+struct X86IntelMPBusHierarchyParams;
+struct X86IntelMPCompatAddrSpaceModParams;
namespace X86ISA
{
diff -r 2d8a57343fe3 -r 770ccf3af571 src/arch/x86/bios/smbios.hh
--- a/src/arch/x86/bios/smbios.hh Tue Jan 31 11:51:19 2012 -0500
+++ b/src/arch/x86/bios/smbios.hh Tue Jan 31 12:05:52 2012 -0500
@@ -52,9 +52,9 @@
#include "sim/sim_object.hh"
class PortProxy;
-class X86SMBiosBiosInformationParams;
-class X86SMBiosSMBiosStructureParams;
-class X86SMBiosSMBiosTableParams;
+struct X86SMBiosBiosInformationParams;
+struct X86SMBiosSMBiosStructureParams;
+struct X86SMBiosSMBiosTableParams;
namespace X86ISA
{
diff -r 2d8a57343fe3 -r 770ccf3af571 src/base/fast_alloc.cc
--- a/src/base/fast_alloc.cc Tue Jan 31 11:51:19 2012 -0500
+++ b/src/base/fast_alloc.cc Tue Jan 31 12:05:52 2012 -0500
@@ -40,10 +40,6 @@
#if USE_FAST_ALLOC
-#ifdef __GNUC__
-#pragma implementation
-#endif
-
void *FastAlloc::freeLists[Num_Buckets];
#if FAST_ALLOC_STATS
diff -r 2d8a57343fe3 -r 770ccf3af571 src/base/range_map.hh
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev