Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

8.1 Intel and AMD x86 options

The features of the widely used Intel and AMD x86 families of processors (386, 486, Pentium, etc) can be controlled with GCC platform-specific options.

On these platforms, GCC produces executable code which is compatible with all the processors in the x86 family by default--going all the way back to the 386. However, it is also possible to compile for a specific processor to obtain better performance.(21)

For example, recent versions of GCC have specific support for newer processors such as the Pentium 4 and AMD Athlon. These can be selected with the following option for the Pentium 4,

$ gcc -Wall -march=pentium4 hello.c

and for the Athlon:

$ gcc -Wall -march=athlon hello.c

A complete list of supported CPU types can be found in the GCC Reference Manual.

Code produced with a specific -march=CPU option will be faster but will not run on other processors in the x86 family. If you plan to distribute executable files for general use on Intel and AMD processors they should be compiled without any -march options.

As an alternative, the -mcpu=CPU option provides a compromise between speed and portability--it generates code that is tuned for a specific processor, in terms of instruction scheduling, but does not use any instructions which are not available on other CPUs in the x86 family.(22) The resulting code will be compatible with all the CPUs, and have a speed advantage on the CPU specified by -mcpu. The executables generated by -mcpu cannot achieve the same performance as -march, but may be more convenient in practice.


 
 
  Published under the terms of the GNU General Public License Design by Interspire