This page is for discussion on gcc flags.
Offical page for x86 and AMD64 compiler options
On my AMD-64 machine at home, I use -ansi -ffor-scope -pedantic -Wall -Wnon-virtual-dtor -Wreorder -Woverloaded-virtual -Wno-long-long -Wno-unused-value -DNDEBUG -g -O2 -fno-math-errno -funroll-loops
Most of these are warning options, the optimization options are -O2 -fno-math-errno -funroll-loops
. I used to use -O3
but it takes too long to compile.
On the AMD-64 machine at the institute, I use
-ansi -ffor-scope -pedantic -Wall -Wnon-virtual-dtor -Wreorder -Woverloaded-virtual -Wno-long-long -Wsign-compare -Wno-unused-value -march=pentium4 -Wno-reorder -DNDEBUG -O3 -fno-math-errno -ffast-math
.
I'm not sure about the effect of -ffast-math
- it may well be harmful without providing much speedup. Why -march=pentium4
? I'm not sure about this, but `uname -m` gives i686, rather than the expected x86_64. Maybe it has something to do with running a 32-bit kernel rather than 64-bit. Probably better would be -march=athlon64 -m32
.
Ian