Initial patch to make gem5 compile with clang/llvm
Review Request #986 - Created Jan. 10, 2012 and submitted
| Information | |
|---|---|
| Koan-Sin Tan | |
| gem5 | |
| Reviewers | |
| Default | |
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.
Posted (Jan. 11, 2012, 2:48 a.m.)
This is awesome! Thanks for the work. There are two things I don't like: the namespace moves and the pkt->Packet:: stuff. I'd like to figure out ways to make it work without that. Also, did you make sure that this all still compiles with GCC?
-
src/arch/alpha/process.cc (Diff revision 1) -
Can you explain a little bit about what's going on here that this is necessary? I'd like to figure out another way to do this that doesn't seem so hackish.
-
src/arch/x86/intmessage.hh (Diff revision 1) -
This is odd. Any idea what's going on here?
-
src/base/fast_alloc.cc (Diff revision 1) -
Anyone know why this pragma is here in the first place? Be nice to see a comment if anyone has a clue. Steve? Your code :)
-
src/cpu/func_unit.hh (Diff revision 1) -
Why is this done? Does clang differentiate between classes and structs?
-
src/cpu/o3/inst_queue.hh (Diff revision 1) -
Don't comment out code. Just delete it.
-
src/dev/copy_engine.cc (Diff revision 1) -
I'd like to figure out why this is necessary and make it go away.
-
src/python/m5/SimObject.py (Diff revision 1) -
Dont' comment out code, please remove it.
Review request changed
Updated (Jan. 11, 2012, 8:38 p.m.)
Change Summary:
1. remove pkt->Packet:: stuff, by removing 'using namespace std' and adding std:: when necessary 2. get rid of namespace move, by adding 'using namespace xxx' to src/arc/xxx/isa_traits.hh 3. add '-Wno-mismatched-tags' to CCFLAGS so that we can avoid class/struct changes
Diff: |
Revision 2 (+60 -60) |
|---|
Posted (Jan. 11, 2012, 10:05 p.m.)
-
src/arch/x86/bios/intelmp.cc (Diff revision 2) -
Should we do this based on if(sizeof(T) > 1), else guestVal = 0?
-
src/arch/x86/isa_traits.hh (Diff revision 2) -
Opening namespaces in headers is never a good idea. This essentially means every place we include it this namespace is now opened. Is this really what we want?
-
src/dev/copy_engine.cc (Diff revision 2) -
Why does the std cause a problem with the packet->set? Packet does not inherit from any STL container class. I don't get why there is any potential overloading.
Review request changed
Updated (Jan. 12, 2012, 3:36 p.m.)
Change Summary:
1. use TheISA:: instead of introducing 'using namespace' in headers, as suggested by Nathan 2. check sizeof(guestVal) before doing "guestVal >>= 8", as suggested by Andreas
Diff: |
Revision 3 (+92 -93) |
|---|
Posted (Jan. 17, 2012, 3 a.m.)
Overall, this looks a lot better. The only thing I really want an answer on is why you got rid fo the "using namespace std" in those .cc files. Other than that, this is basically ready.
-
SConstruct (Diff revision 3) -
I'm happy to have you fix the struct/class stuff and get rid of -Wno-mismatched-tags
-
src/arch/arm/isa/templates/basic.isa (Diff revision 3) -
Don't need the comment here.
-
src/dev/ide_ctrl.cc (Diff revision 3) -
This should be ok (it's in a .cc file). What's wrong?
-
src/dev/ns_gige.cc (Diff revision 3) -
Same here
Posted (Jan. 17, 2012, 6:56 p.m.)
-
src/arch/x86/bios/intelmp.cc (Diff revision 3) -
Just change T to uint64_t and you won't need the if (sizeof(...
Posted (Jan. 18, 2012, 6:45 p.m.)
-
SConstruct (Diff revision 3) -
I would imagine we should also add "+ main[CLANG]" in this test.
-
SConstruct (Diff revision 3) -
The CheckHeader test fails when I try to build using clang, and the reason seems to be that clang in contrast to gcc cannot find asm/errno.h that is included via Python.h. On a x86_64 machine I had to forcefully add "-I/usr/include/x64_64-linux-gnu" for the build to proceed. Did anyone else have these issues?
I think is this good and plan to commit it. I assume you're fine with your name being on the patch? Thanks for all of your effort.
Review request changed
Updated (Jan. 29, 2012, 2:18 p.m.)
Change Summary:
1. Andreas Hansson provided informative description for the patch 2. remove -Wno-mismatched-tags and make class/struct consistent 3. some small changes discussed during review
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+251 -388) |
Review request changed
Updated (Jan. 29, 2012, 2:21 p.m.)
Ship It!
This is great. Thanks for the effort!
