Well I've been asked more than once for this, so I decided that a publicly accessible version would help people.
|Purpose||sun cc||gnu cc|
|Compile in 64bit mode||-xarch=<sparcv9|amd64> (-xarch=generic64 soon)||-m64 (gcc really wins here!)|
|Compile a kernel module||-D_KERNEL||-D_KERNEL -mcmodel=kernel|
|Multi-Threaded||-D_REENTRANT (stop using -mt in S10)||-D_REENTRANT|
|Warnings||-v||-W or -Wall (mini lint)|
|Warnings are errors||-errwarn=%all||-Werror|
|Build a shared object (.so)||-G||-shared|
|Accept C++ style comments||-xCC||None (does it automatically)|
|Position independent code||-K PIC (32bit addresses - longer sparc instructions) -K pic (not 32bit addresses)||-fpic|
There are a few coding gotchas - string constants in gcc get into the .text segment of the application, not the data segment, thus you are not permitted to alter them.
Occasionally I find that the final link step of gcc fails with relocation errors - the code segment ends up addressing > 32bit values within itself, by adding -fpic to the compilation flags it works just fine (it's been the occasional test with char foo[MAX_LONG>>1]; in the global segment causing this).