Compiler Flags for the Athlon

The following compiler flags will create binaries that will try to get the most out of the Athlon processor.

When using GCC or PentiumGCC use the following:

CFLAGS = -s -O3 -fomit-frame-pointer -Wall -mpentiumpro -march=pentiumpro -malign-functions=4 -funroll-loops -fexpensive-optimizations -malign-double -fschedule-insns2 -mwide-multiply

When using AthlonGCC use the following:

CFLAGS = -s -O3 -fomit-frame-pointer -Wall -mathlon -mcpu=athlon -march=athlon -malign-functions=4 -funroll-loops -fexpensive-optimizations -malign-double -fschedule-insns2 -mwide-multiply

But what do these flags do?

This is a linker option that remove all symbol table and relocation information from the executable.

This is an optimization setting, it enables all `-O2' optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size. If you use multiple `-O' options, with or without level numbers, the last such option is the one that is effective. 

This is an optimization setting. It doesn't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. It also makes debugging impossible on some machines. On some machines, such as the Vax, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag.

This is a warning option. This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. It includes numerous "-W" which you can find here.

-mathlon or -mpentiumpro
This is an i386 option that will schedule things appropriately for that particular cpu(The Athlon or PentiumPro)

-march=athlon or -march=pentiumpro
This is another i386 option that works with the previous option. It generates instructions for the machine type cpu type.

This is an i386 option. Aligns the start of functions to a 2 raised to 4 byte boundary. If `-malign-functions' is not specified, the default is 2 if optimizing for a 386, and 4 if optimizing for a 486. 

This is an optimization option. Performs the optimization of loop unrolling. This is only done for loops whose number of iterations can be determined at compile time or run time. `-funroll-loops' implies both `-fstrength-reduce' and `-frerun-cse-after-loop'. 

Another optimzation option that performs a number of minor optimizations that are relatively expensive.

This is an i386 option. Controls whether GCC aligns double, long double, and long long variables on a two word boundary or a one word boundary. Aligning double variables on a two word boundary will produce code that runs somewhat faster on a `Pentium' at the expense of more memory. Warning: if you use the `-malign-double' switch, structures containing the above types will be aligned differently than the published application binary interface specifications for the 386. 

This is an optimization option. Similar to `-fschedule-insns', but requests an additional pass of instruction scheduling after register allocation has been done. This is especially useful on machines with a relatively small number of registers and where memory load instructions take more than one cycle. 

This is an i386 option. Controls whether GCC uses the mul and imul that produce 64 bit results in eax:edx from 32 bit operands to do long long multiplies and 32-bit division by constants. 

Other Options you may want to add or replace.

This is a linker option that prevents linking with the shared libraries on systems that support dynamic linking. This option was included with the original set of options from, but I decided to omit this option for many reasons. This option will create a larger executable and unless the statically linked libraries were compiled with the same flags, you will have a partially optimized program where the core code is optimized and the linked libraries are no. The real trade-off is launch speed vs. executable file size. 

Don't be afraid if all of this information confuses you, its not like you need to know what everything does. Feel free to try out different options and see what works best for you, if you do find something that works better then the options here, drop us a line. For more information consult the GCC manual.

Athlon Linux
  • Empty
  • About
  • Empty
  • General
  • Distribution
  • AGCC
  • Compiling

Privacy Policy
( c ) 2000 AthlonLinux. All rights reserved.
All trademarks and copyrights on this page are owned by their respective owners. Comments are owned by the Poster.
Hosted by our good friends at Eyemedia.