compiler optimizations

Dean Hall dean-lists at deanpence.com
Sun May 9 15:37:31 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ilja wrote:

> Hi,
> 
> I know the LFS book strongly advices agains using compiler
> optimizations, but I'm in my 4th LFS compile, and to keep things
> excited, I'm going ahead with:
> "-O3 -march=pentium3". I'm just to currious about the effect.
> I'm in chapter 6 and Glibc has just compiled and been checked. No errors
> found.
> So, I'm about to install the first and most important library, but then
> again, I'm no fool. -in contrast to what some of my friends think ;)-.
> Is this a project bound to hit the wall or do you give me a chance in
> succeeding?
> 
> Kind regards,
> 
> Ilja

I've only done LFS 5.0 twice, but both times, I used '-O3
- -march=pentium2' (for my PII box), but I only used it when the book did not
say something to the effect of "using compiler optimizations has been known
to produce compilation failures" or some such warning. Also, I only used it
after the chroot when the book suggests would be the only appropriate time
to use them.

Just to note, I wouldn't be surprised at all if -O3 produced larger
binaries; the man page says this about -O2:

"GCC performs nearly all supported optimizations that do not involve a
space-speed tradeoff."

and this about -O3:

"-O3 turns on all optimizations specified by -O2 and also turns on the
- -finline-functions and -frename-registers options."

Obviously -O3 turns on optimizations that *do* involve a space-speed
tradeoff, so you will end up with larger binaries than you would with -O2
and -O. The idea is that inlining appropriate functions will increase
speed. Whether the compiler is capable of doing this when appropriate is
another question.

As someone else said, you're unlikely to see any performance increase in
anything in the base LFS, and he's probably right in the short-term. I
suppose it only makes sense if you're going to be running x program over
and over millions of times. Then, obviously, if -O3 did make a faster
binary, you'll see the difference.


Dean
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD4DBQFAnrKrBnn70KGO4CURAo83AJjk8kcI3RzntkaSFU1YAUM8t0JFAJ48h99U
sAFpM9u0a7PdOE+br8gT6w==
=XSwU
-----END PGP SIGNATURE-----



More information about the lfs-support mailing list