Blair Sadewitz wrote:
> They do not set it on a per-architecture basis, but some packages do
> not use -O2 nonetheless, IIRC.
What do those use then? -O2 is a fairly conservative optimization level. In
fact, it's the best tested compiler setting for GCC. I've never seen anything
explicitely using -O1 resp. -O and most autoconf'ed software defaults to -O2.
-O0 resp. no -Ox at all is useful for debugging but not anything else as far I
can tell but I remember some cases in which this exposed compiler bugs. Some
software simply sets no default compiler flags because it relies on the user to
set them. Very few software has a strong opinion on what compiler flags it
wants. MPlayer for example has and compilation is likely to fail if you try to
fiddle the flags but MPlayer is rather exceptional.
Now, there are programs which actually fail if you use certain flags but most
of the time, this is a failure of the software and not GCC. It's just that a
lot of software ignores parts of the C standard so that assumptions that could
be made by the compiler do not hold and may interfere with certain
optimizations.
The performance differences between no optimization or -O1 and -O2 can be quite
significant even for simple applications. -O3 is a bit questionable especially
if your CPU has a small cache. Also at least for x86, the -march setting
usually makes quite a difference for some software because the optimizations
for a 80486, Pentium, P4, Athlon etc. differ a lot. GCC has also some
extensions which can only be enabled with a proper -march flag and which fall
otherwise default to a portable non-optimized variant. Well, I understand if
people find these dubious or dangerous but unfortunately, there's no 80386 with
1 THz available, so we have to find other means than clock frequencies to get
more out of the silicon.
--
Christian