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.' diff --git a/ext/libelf/SConscript b/ext/libelf/SConscript index 7f33990d8..5e92fe08b 100644 --- a/ext/libelf/SConscript +++ b/ext/libelf/SConscript @@ -94,6 +94,8 @@ if m4env['GCC']: 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 --git a/src/SConscript b/src/SConscript index 7fb03e821..679403020 100755 --- a/src/SConscript +++ b/src/SConscript @@ -854,6 +854,9 @@ def makeEnv(label, objsfx, strip = False, **kwargs): 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 @@ def makeEnv(label, objsfx, strip = False, **kwargs): # Debug binary ccflags = {} -if env['GCC']: +if env['GCC'] or env['CLANG']: if sys.platform == 'sunos5': ccflags['debug'] = '-gstabs+' else: diff --git a/src/arch/alpha/tlb.cc b/src/arch/alpha/tlb.cc index b211c4923..26d290a50 100644 --- a/src/arch/alpha/tlb.cc +++ b/src/arch/alpha/tlb.cc @@ -63,7 +63,7 @@ TLB::TLB(const Params *p) : 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 @@ void TLB::flushAll() { DPRINTF(TLB, "flushAll\n"); - memset(table, 0, sizeof(TlbEntry[size])); + memset(table, 0, sizeof(TlbEntry) * size); flushCache(); lookupTable.clear(); nlu = 0; diff --git a/src/arch/alpha/tlb.hh b/src/arch/alpha/tlb.hh index b6261769f..1d4b6c6f8 100644 --- a/src/arch/alpha/tlb.hh +++ b/src/arch/alpha/tlb.hh @@ -49,7 +49,7 @@ class ThreadContext; namespace AlphaISA { -class TlbEntry; +struct TlbEntry; class TLB : public BaseTLB { diff --git a/src/arch/arm/insts/static_inst.hh b/src/arch/arm/insts/static_inst.hh index fa850190f..5af97b796 100644 --- a/src/arch/arm/insts/static_inst.hh +++ b/src/arch/arm/insts/static_inst.hh @@ -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 --git a/src/arch/arm/insts/vfp.hh b/src/arch/arm/insts/vfp.hh index 57b74d040..b3582a351 100644 --- a/src/arch/arm/insts/vfp.hh +++ b/src/arch/arm/insts/vfp.hh @@ -107,6 +107,9 @@ enum VfpRoundingMode VfpRoundZero = 3 }; +static inline float bitsToFp(uint64_t, float); +static inline uint32_t fpToBits(float); + template static inline bool flushToZero(fpType &op) diff --git a/src/arch/arm/isa/templates/basic.isa b/src/arch/arm/isa/templates/basic.isa index 0728b66e3..b3878b89a 100644 --- a/src/arch/arm/isa/templates/basic.isa +++ b/src/arch/arm/isa/templates/basic.isa @@ -49,7 +49,7 @@ def template BasicDeclare {{ // 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 --git a/src/arch/arm/miscregs.cc b/src/arch/arm/miscregs.cc index db097c653..c31818377 100644 --- a/src/arch/arm/miscregs.cc +++ b/src/arch/arm/miscregs.cc @@ -411,7 +411,7 @@ decodeCP15Reg(unsigned crn, unsigned opc1, unsigned crm, unsigned opc2) } break; case 11: - if (opc1 >= 0 && opc1 <=7) { + if (opc1 <=7) { switch (crm) { case 0: case 1: diff --git a/src/arch/generic/memhelpers.hh b/src/arch/generic/memhelpers.hh index c753aaf2a..f7bbfa269 100644 --- a/src/arch/generic/memhelpers.hh +++ b/src/arch/generic/memhelpers.hh @@ -64,7 +64,7 @@ readMemAtomic(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem, 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 @@ writeMemAtomic(XC *xc, Trace::InstRecord *traceData, const MemT &mem, { 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 --git a/src/arch/mips/faults.cc b/src/arch/mips/faults.cc index 00471aece..26b7c7557 100644 --- a/src/arch/mips/faults.cc +++ b/src/arch/mips/faults.cc @@ -98,7 +98,7 @@ template <> FaultVals MipsFault::vals = template <> FaultVals MipsFault::vals = { "TLB Refill Exception", 0x180, ExcCodeDummy }; -template <> FaultVals MipsFault::vals = +template <> MipsFaultBase::FaultVals MipsFault::vals = { "TLB Modified Exception", 0x180, ExcCodeMod }; void diff --git a/src/arch/mips/faults.hh b/src/arch/mips/faults.hh index 76d4fff23..912b42cde 100644 --- a/src/arch/mips/faults.hh +++ b/src/arch/mips/faults.hh @@ -299,7 +299,7 @@ class TlbModifiedFault : public TlbFault TlbFault(asid, vaddr, vpn, false) {} - ExcCode code() const { return vals.code; } + ExcCode code() const { return MipsFault::code(); } }; } // namespace MipsISA diff --git a/src/arch/x86/bios/acpi.hh b/src/arch/x86/bios/acpi.hh index 5040c434c..b10b18092 100644 --- a/src/arch/x86/bios/acpi.hh +++ b/src/arch/x86/bios/acpi.hh @@ -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 --git a/src/arch/x86/bios/intelmp.cc b/src/arch/x86/bios/intelmp.cc index 974af28a5..4c9c61adb 100644 --- a/src/arch/x86/bios/intelmp.cc +++ b/src/arch/x86/bios/intelmp.cc @@ -72,7 +72,7 @@ template 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 --git a/src/arch/x86/bios/intelmp.hh b/src/arch/x86/bios/intelmp.hh index 0ddb62b8d..4b730ad4b 100644 --- a/src/arch/x86/bios/intelmp.hh +++ b/src/arch/x86/bios/intelmp.hh @@ -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 --git a/src/arch/x86/bios/smbios.hh b/src/arch/x86/bios/smbios.hh index 9fa6cd6dc..805b03fbb 100644 --- a/src/arch/x86/bios/smbios.hh +++ b/src/arch/x86/bios/smbios.hh @@ -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 --git a/src/base/fast_alloc.cc b/src/base/fast_alloc.cc index 0736d26e2..d370b93e8 100644 --- a/src/base/fast_alloc.cc +++ b/src/base/fast_alloc.cc @@ -40,10 +40,6 @@ #if USE_FAST_ALLOC -#ifdef __GNUC__ -#pragma implementation -#endif - void *FastAlloc::freeLists[Num_Buckets]; #if FAST_ALLOC_STATS diff --git a/src/base/range_map.hh b/src/base/range_map.hh index 7714a0049..5d6547f9b 100644 --- a/src/base/range_map.hh +++ b/src/base/range_map.hh @@ -215,7 +215,7 @@ class range_multimap { std::pair p; p = find(r); - if (p.first->first.start == r.start && p.first->first.end == r.end || + if ((p.first->first.start == r.start && p.first->first.end == r.end) || p.first == tree.end()) return tree.insert(std::make_pair,V>(r, d)); else diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh index 899c7c29e..15a725438 100644 --- a/src/base/remote_gdb.hh +++ b/src/base/remote_gdb.hh @@ -204,7 +204,7 @@ class BaseRemoteGDB public: HardBreakpoint(BaseRemoteGDB *_gdb, Addr addr); - std::string name() { return gdb->name() + ".hwbkpt"; } + const std::string name() const { return gdb->name() + ".hwbkpt"; } virtual void process(ThreadContext *tc); }; diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh index a34ca7bb6..689cb626b 100644 --- a/src/base/stl_helpers.hh +++ b/src/base/stl_helpers.hh @@ -72,7 +72,7 @@ class ContainerPrint // Treat all objects in an stl container as pointers to heap objects, // calling delete on each one and zeroing the pointers along the way -template class C, typename A> +template