Compiler flags: -march vs -mcpu

Matthew Gibbons mg018a0183 at
Sun Sep 22 12:05:20 PDT 2002

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

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
this using the -mcpu=<cpu> option. This will optimise the code for the given
processor, whilst still supporting older processors. This might not give
such optimised code as when using the -march=<cpu> option, but will result
in more flexible code.

Hope this helps!


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