Compiler flags: -march vs -mcpu

Greg Schafer gschafer at
Sun Sep 22 14:51:57 PDT 2002

On Sun, Sep 22, 2002 at 08:05:20PM +0100, Matthew Gibbons wrote:
> The LFS book used to suggest setting including -march=<cpu> in the CFLAGS
> and CXXFLAGS environment variables to ensure that gcc/g++ optimised the
> object code for the given architecure. For example, I used to
> use -march=i686 when building for my Athlon. However, code build in this way
> will only work with that kind of processor, or higher, so I couldn't run the
> code on an i585, for example. This is supported by the compiler optimisation
> hint

Hmm, don't mean to sound rude but you've just stated the bleeding obvious.

> Now, wouldn't it be great to compile code optimised for the i686, but that
> would still run on an i586, or even and i386? Well, it is possible to do

Well, guess what? GCC does this already by default! Methinks you need to
read up on  "-S -fverbose-asm" in the GCC manual and do some testing.

Read this thread for some reference:-

Unsubscribe: send email to listar at
and put 'unsubscribe lfs-dev' in the subject header of the message

More information about the lfs-dev mailing list