Default style (Cherry Eve). Switch styles (Capricorn). XML Feed Calendar
All | General | Programming | Shell
20040903 Friday September 03, 2004

AMD64 - compilation flag differences from cc to gcc

Well I've been asked more than once for this, so I decided that a publicly accessible version would help people.

Purposesun ccgnu 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
Optimization-xO<0-5>-O<0-5>
Warnings-v-W or -Wall (mini lint)
Warnings are errors-errwarn=%all-Werror
Build a shared object (.so)-G-shared
Accept C++ style comments-xCCNone (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). September 03, 2004 02:49 PM IST Permalink