Gentoo Wiki ArchivesGentoo Wiki

Safe_Cflags

Warning: THIS PAGE IS FOR SAFE FLAGS ONLY.

Please do not include any flags that aren't 100% safe. Just because it works for you doesn't mean it will for everyone else.

We aren't interested in benchmark scores, personal anecdotes, rumors, things your really smart uncle once told you, random -m flags that made your box dispense root beer, or any other discussion or debate. It will be removed. Take it to the talk page or the appropriate forum. Thanks.


Warning: UPDATING CHOST
Please note that you will get into a lot of trouble if you just change CHOST as suggested here - I would leave it as is and just change CFLAGS. Right way to change CHOST is explained here: http://www.gentoo.org/doc/en/change-chost.xml


Note: GCC 4.2 introduces a new -march option, -march=native, which automatically detects the features your CPU supports and sets the options appropriately. If you have an Intel or AMD CPU and are using >=sys-devel/gcc-4.2.0, using -march=native is recommended. Do NOT use -march=native if you use distcc on nodes with different architectures as this may produce unusable code.


Contents

Safe CFLAGS to use for Gentoo

These CFLAGS are for gcc 3.x and 4.x. To check your version:

gcc --version

You can see which CPU you have with the following command:

cat /proc/cpuinfo

If you're running Intel, you can also use x86info to get more detailed info about your chip:

emerge -av x86info

This page is for those who don't want to experiment, and want a stable system, but still optimized for their CPU. But remember, by using these flags, binaries from your system might not work on another one with a different CPU. So if you compiled with optimizations for a Pentium 4 (-march=pentium4), you can't share a hard disk or packages with a friend who only has a Pentium MMX (-march=pentium-mmx). Though the other way around should work, see below.

This is the case if you are using the -march flags. If you use -mtune instead without any -march option, your binaries are backward compatible down to i386, but the scheduling is optimized for your chosen architecture. CPUs are also backward compatible so if you update your system with a new CPU you can still use your old packages. There is one exception though; if your old CPU supports a feature, like AMD's 3dnow, that your new CPU doesn't. So if you have an athlon (-march=athlon) and upgrade to a pentium4 your old packages might not work. You can mix -march and -mtune if you, for example, would like to create binaries that would run on any i686 but are optimized for a pentium4. This would be accomplished by using -march=i686 and -mtune=pentium4.

Note that -O2 is regarded as safer than "-O3", and "-O3" can often be a counter-productive attempt at optimization. On computers with limited cache and/or memory, "-Os" may provide better performance in some cases through smaller binaries, although it is slower when using the OpenSSL library with small keys (DSA keys with less than 2048 bits on VIA C3-2, 1200 MHz and 64 kb on-die cache).

Note: This is only true if the platform has unusually fast unaligned access capability since -Os disables some alignment. A better solution is "-O2 -fno-reorder-blocks -fno-reorder-functions"

GCC has a number of flags for CPU features like MMX and SSE; -mmx -msse etc. They are implied if you use a correct -march option so you usually donīt need them, with some exceptions. They should not be confused with the similar USE-flags for CPU features. The flag -mfpmath=sse however is not enabled by -march but it usually makes binaries slower due to limitations in the glibc headers. So it's better to not use this flag, even if you have an SSE capable CPU. Also -mfpmath=sse,387 is experimental and unstable.

The flag -fomit-frame-pointer is enabled at -O1, -O2, -O3 and -Os on arches where it doesn't interfere with debugging, such as AMD64, but not x86. So if you're on x86 you should add it to your CFLAGS. Also don't use -momit-leaf-frame-pointer together with -fomit-frame-pointer. It's pointless as -fomit-frame-pointer already omits all frame pointers. In fact if you use both, -momit-leaf-frame-pointer overrides -fomit-frame-pointer creating less optimized code.

Note that the -O3 and, specially, the -fomit-frame-pointer flag can hamper debugging (specially generating stack traces). This is important for developers and people who want to report certain kinds of bugs (such as bugs which result in crashes). See http://bugs.gentoo.org/show_bug.cgi?id=68282 for a discussion.

gcc-4.2.0 or newer

If you are using gcc-4.2.0 or newer (and do not intend to create packages to be run on other machines), it is easiest and probably best to just use -march=native, which tells GCC to automatically detect the settings it should use for your specific machine.

E.g.:

32-bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"

64-bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"

i386

Note: Gentoo's minimum hardware requirement for x86 CPUs is the i486. This is due to glibc-2.4 dropping linuxthreads support and requiring NPTL which doesn't work on i386.


If you would like to use a newer machine (eg. a Pentium III) to compile code that will still run on i386 machines use the following:

CHOST="i386-pc-linux-gnu"
CFLAGS="-mtune=pentium3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

or

CHOST="i386-pc-linux-gnu"
CFLAGS="-march=i386 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

The former will create code optimized for a PIII that will still run on a i386, while the latter will be optimized for the i386 alone.

i486

CHOST="i486-pc-linux-gnu"
CFLAGS="-march=i486 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Intel Processors

Pentium

vendor_id : GenuineIntel
cpu family : 5
model : 2
model name : Pentium 75 - 200

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=pentium -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Pentium w/ MMX

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=pentium-mmx -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Cyrix MediaGX / AMD Geode GX1

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=pentium-mmx -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Pentium Pro

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentiumpro -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

or

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=i686 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

(these are identical)

Pentium II

vendor_id : GenuineIntel
cpu family : 6
model : 3, 5

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : Mobile Pentium II
stepping        : 10
cpu MHz         : 397.082
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr
bogomips        : 794.75
clflush size    : 32

Celeron (Mendocino), aka Celeron1

vendor_id : GenuineIntel
cpu family : 6
model : 6
stepping : 0

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : Celeron (Mendocino)
stepping        : 0
cpu MHz         : 334.108
cache size      : 128 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr up
bogomips        : 686.94
clflush size    : 32

Pentium III/ Mobile Celeron

vendor_id : GenuineIntel
cpu family : 6
model : 7, 8, 11

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 8
model name      : Pentium III (Coppermine)
stepping        : 6
cpu MHz         : 863.934
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse
bogomips        : 1728.97
clflush size    : 32

Celeron (Coppermine)

vendor_id  : GenuineIntel
cpu family  : 6
model  : 8
stepping  : 10

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Celeron (Willamette)

vendor_id  : GenuineIntel
cpu family  : 15
model  : 1
model name  : Intel(R) Celeron(R) CPU 1.70GHz
stepping  : 3

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Pentium M(Centrino)/Celeron M

vendor_id  : GenuineIntel
cpu family  : 6
model  : 9 or 13
model name  : Intel(R) Pentium(R) M processor XXXXMHz

For gcc 3.3 or older (Warning: dev-java/sun-jdk needs old libstdc++-3.3.so on X86 Systems) :

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -msse2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

For gcc 3.4 and later:

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium-m -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

The Celeron M is based on the Pentium M but it has half the L2 cache and does not support the SpeedStep technology.

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : Intel(R) Pentium(R) M processor 2.00GHz
stepping        : 8
cpu MHz         : 800.000
cache size      : 2048 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx up bts est tm2
bogomips        : 1597.70
clflush size    : 64

Mobile Pentium 4-M (Northwood)

vendor_id  : GenuineIntel
cpu family  : 15
model  : 2
model name  : Mobile Intel(R) Pentium(R) 4 - M CPU X.XXGHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Pentium 4

vendor_id  : GenuineIntel
cpu family  : 15
model  : 0 or 1 or 2
model name  : Intel(R) Pentium(R) 4 CPU XXXXMHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Pentium 4 (Prescott) / Celeron D

vendor_id : GenuineIntel
cpu family : 15
model : 3 or 4
model name  : Intel(R) Pentium(R) 4 CPU XXXGHz -or- Intel(R) Celeron(R) CPU XXXGHz

32-bit profile (x86)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64-bit profile (amd64)

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
Note: You can verify the chip is a Prescott by looking for pni in the flags section of /proc/cpuinfo. This indicates support for SSE3.

In 2004, Intel started branding processors with the Prescott core as Intel Celeron D.

Pentium D 8xx / 9xx

vendor_id : GenuineIntel
cpu family : 15
model  : 4, 6
model name  : Intel(R) Pentium(R) D CPU x.xxGHz

32-bit profile (x86)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64-bit profile (amd64)

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Xeon w/o EM64T

vendor_id  : GenuineIntel
cpu family  : 15
model  : 2
model name  : Intel(R) Xeon(R) CPU XXXXMHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Xeon w/EM64T (also Pentium 4 P6xx or Celeron M 5xx)

vendor_id  : GenuineIntel
cpu family  : 15
model  : 4,6
model name  : Intel(R) Xeon(R) CPU XXXXMHz
model name  : Intel(R) Celeron(R) M CPU 5xx @ XXXGHz

32-bit profile (x86)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64-bit profile (amd64)

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Intel Core Solo/Duo, Pentium Dual-Core T20xx/T21xx

vendor_id  : GenuineIntel
cpu family  : 6
model  : 14, 22
model name  : Genuine Intel(R) CPU TXXXX @ XXXGHz
model name  : Intel(R) Celeron(R) CPU 220 @ 1.20GHz
model name  : Intel(R) Celeron(R) CPU 4X0 @ XXXGHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Notes:

Intel Core 2 Duo/Quad / Xeon 51xx/53xx, Pentium Dual-Core T23xx+/Exxxx

vendor_id  : GenuineIntel
cpu family  : 6
model  : 15
model name  : Intel(R) Core(TM)2 CPU XXXX @ XXXGHz

32 bit profile (x86)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit profile (amd64)

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CXXFLAGS="${CFLAGS}"

32 bit Gentoo FreeBSD

CHOST="i686-gentoo-freebsd6.2"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="$CFLAGS"

Note:

Atom N270

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

VIA Processors

Note: EPIA is the name of all VIA's mini-ITX and nano-ITX motherboards with onboard VIA processor. Eden is low-power CPU variant, this name itself also does not tell anything about CPU core.

Eden

GCC 4.2.x

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=c3-2 -mtune=c3-2 -pipe  -mfpmath=sse,387 -msse2 -mmmx -msse"

Esther C5J (Via C7)

vendor_id  : CentaurHauls
cpu family  : 6
model  : 10
model name  : VIA Esther processor 2000MHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=i686 -mmmx -msse -msse2 -msse3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

As the C7 has the pni flag in /proc/cpuinfo, it supports SSE3. Search for pni on this page to get the explanation.

C3 Nehemiah (C5X/C5XL/C5P) (VIA)

vendor_id : CentaurHauls
cpu family : 6
model : 9
model name : VIA Nehemiah

Note: Despite the C5 core name, these processors are marketed as C3s.

GCC 3.3 and earlier

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=i686 -msse -mmmx -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

GCC 3.4 and later

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=c3-2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
Note: These cores do support the cmov instruction and hence are supported by i686 - and of course c3-2. If you must be compatible with all VIA C3 versions, do not use the settings in this section and instead use the flags in the C3 entry below.


C3 Samuel/Ezra (Via EPIA)

processor  : 0
vendor_id  : CentaurHauls
cpu family  : 6
model  : 7
model name  : VIA Samuel 2

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=c3 -m3dnow -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
Warning: Do not use any stages or packages containing i686 instructions (such as cmov) with the Samuel 2 and Ezra versions of the C3.

The Ezra doesn't have any special instructions that you could optimize for, just consider it a K6-3 - basically a Pentium 2 with 3DNow.

Note: The Mini-ITX EPIA-SP features a VIA C3 Eden processor, even if /proc/cpuinfo answers: model name: VIA Nehemiah

Transmeta Processors

Transmeta Crusoe

vendor_id  : GenuineTMx86
cpu family  : 6
model  : 4
model name  : Transmeta(tm) Crusoe(tm) Processor TM5800
stepping  : 3

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=i686 -Os -mmmx -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Note: TM5800 CPU's do not fully support all i686 instructions. Specifically, code alignment options are not supported. Using the '-Os' optimisation disables these; other optimisation flags should not be considered safe.

Transmeta Efficeon

vendor_id  : GenuineTMx86
cpu family  : 15
model  : 2
model name  : Transmeta Efficeon(tm) Processor TM8000
stepping  : 4

CHOST="i686-pc-linux-gnu"
CFLAGS="-mtune=pentium3 -msse2 -O2 -pipe -falign-functions=0 -falign-jumps=0 -falign-loops=0"
CXXFLAGS="${CFLAGS}"

Note: The Efficeon processor will reorder and realign instructions on translating from x86 to VLIW (Very Long Instruction Word), so not aligning functions/jumps/loops will produce smaller executable without any effect on speed.

AMD Processors

K6 (AMD)

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=k6 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

K6-2 (AMD)

vendor_id  : AuthenticAMD
cpu family  : 5
model  : 8

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=k6-2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 5
model           : 8
model name      : AMD-K6(tm) 3D processor
stepping        : 12
cpu MHz         : 451.031
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr up
bogomips        : 902.84
clflush size    : 32

Note: /proc/cpuinfo may be confusing. The model name may say "AMD-K6(tm) 3D Processor" but it is not a AMD K6-3. Rely on the vendor_id, CPU family, and model number.
Note: If you get "Illegal Instruction" errors on compiles (especially long ones), you may be running into a cooling problem, or worse yet, a Sig11 (segmentation fault/bad ram) problem. Bug #24379 has a discussion about it.

Geode LX (AMD)

vendor_id  : AuthenticAMD
cpu family  : 5
model  : 10

NOTE: -march=k6-2 didnt work for me using stage3-x86-uclibc-hardened-2008.0.tar.bz2, i ended up getting compilation issues to the tune of 'C compiler cannot create executables'

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=k6-2 -Os -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
Warning: Only use this if you have at least gcc-4.3.0 and kernel-2.6.25-rc5 or higher
CHOST="i586-pc-linux-gnu"
CFLAGS="-march=geode -Os -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 5
model		: 10
model name	: Geode(TM) Integrated Processor by AMD PCS
stepping	: 2
cpu MHz		: 498.059
cache size	: 128 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu de pse tsc msr cx8 sep pge cmov clflush mmx mmxext 3dnowext 3dnow
bogomips	: 992.87
clflush size    : 32

K6-3 (AMD)

CHOST="i586-pc-linux-gnu"
CFLAGS="-march=k6-3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Duron (AMD)

From 600 to 900 MHz (these models have a tbird-alike core model)

product: AMD Duron(tm) Processor version: 6.3.1

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-tbird -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Mobile Duron (AMD)

vendor_id : AuthenticAMD
cpu family : 6
model : 3
model name : AMD Duron(tm) Processor

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-tbird -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Duron Morgan (AMD)

From 900 to 1300 MHz
The Morgan Durons are based on the Palomino core, and hence can be treated as Athlon XP's.

vendor_id : AuthenticAMD
cpu family : 6
model : 7
model name : AMD Duron(tm) Processor
stepping : 1

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Athlon (AMD)

vendor_id : AuthenticAMD
cpu family : 6
model : 4 or 2 or 1
model name : AMD Athlon(TM)Processor or AMD-K7(TM)Processor
stepping : 4 or 2
note: This processor is only available as a Slot A processor; if you have a Socket A/462 Athlon, it's a Thunderbird (see below)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Athlon-tbird (AMD)

vendor_id : AuthenticAMD
cpu family : 6
model : 4
model name : AMD Athlon(tm) Processor

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-tbird -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Athlon (Palomino) XP/Duron (AMD)

vendor_id  : AuthenticAMD
cpu family  : 6
model  : 8
model name  : AMD Athlon(tm)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Sempron 2400+ (2000MHz) is also identified as cpu family:6 model:8 model_name:AMD Sempron(TM) 2400+ (256kB cache). The Duron 1800+ is also included in this list.

# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 8
model name      : AMD Sempron(tm)   2400+
stepping        : 1
cpu MHz         : 1659.979
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mp mmxext 3dnowext 3dnow up ts
bogomips        : 3328.55
clflush size    : 32

Athlon 4 (AMD)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Athlon XP/Geode NX (AMD)

vendor_id  : AuthenticAMD
cpu family  : 6
model  : 6 or 8
stepping  : 2
Some CPUs have also been observed with the following:
model : 10
model name : AMD Athlon(tm) XP 2500+
stepping : 0

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 6
model name      : AMD Athlon(tm) XP 2000+
stepping        : 2
cpu MHz         : 1670.597
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow up ts
bogomips        : 3343.54
# cat /proc/cpuinfo 
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 8
model name      : AMD Geode NX 1750  
stepping        : 1
cpu MHz         : 1400.115
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mp mmxext 3dnowext 3dnow up ts fid vid
bogomips        : 2801.55
clflush size    : 32

Athlon MP (AMD)

vendor_id  : AuthenticAMD
cpu family  : 6
model  : 10
model name  : AMD Sempron(tm)
stepping  : 0

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-mp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Athlon 64 (AMD)

32 bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit
cpu family  :15
model  :4
model name  :AMD Athlon(tm) 64 Processor 3200+
stepping  :8

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 63
model name      : AMD Athlon(tm) 64 Processor 3200+
stepping        : 2
cpu MHz         : 1999.821
cache size      : 512 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni lahf_lm
bogomips        : 4001.79
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

Athlon 64 X2 (AMD)

vendor_id: AuthenticAMD
cpu family: 15
model: 35, 43, 75 or 107
stepping: 1 or 2
model name: AMD Athlon(tm) 64 X2 Dual Core Processor


32 bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 43
model name      : AMD Athlon(tm)64 X2 Dual Core Processor  4200+
stepping        : 1
cpu MHz         : 2200.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow rep_good pni lahf_lm cmp_legacy
bogomips        : 4424.71
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 43
model name      : AMD Athlon(tm)64 X2 Dual Core Processor  4200+
stepping        : 1
cpu MHz         : 2200.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow rep_good pni lahf_lm cmp_legacy
bogomips        : 4424.71
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

If you have a newer Athlon64("Venice" or "San Diego")/Athlon64-X2("Manchester", "Toledo", or "Windsor") (check for pni in cat /proc/cpuinfo) you can also add -msse3 to your CFLAGS to enable SSE3 support. Any chip using the 90nm process except for the "Winchester" class Athlon64 supports SSE3.

If you're having gcc-4.3+ and "pni" in flags, you may want to use -march=k8-sse3 instead of -march=k8. You can take out the -msse3 by doing this.

Also bear in mind that all Athlon64 X2 and Opteron 165, 170, 175, 180, and 185 processors are dual-core CPUs so make sure that you use MAKEOPTS="-j3" in your make.conf. This doesn't affect the code but might reduce compile times.

All socket AM2 processors are SSE3 capable as well.

1xx Opteron (AMD)

vendor_id : AuthenticAMD
cpu family : 15
model : 5
model name : AMD Opteron(tm) Processor 1xx
stepping : 8

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CXXFLAGS="${CFLAGS}"
socket 939
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 39
model name      : AMD Opteron(tm) Processor 144
stepping        : 1
cpu MHz         : 1800.000
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow up pni lahf_lm
bogomips        : 3593.50
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

2xx/8xx Opteron (AMD)

vendor_id : AuthenticAMD
cpu family : 15
model : 5
model name : AMD Opteron(tm) Processor xxx
stepping : 8

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CXXFLAGS="${CFLAGS}"

22xx Dual-Core Opteron (AMD)

vendor_id : AuthenticAMD
cpu family : 15
model : 65
model name : Dual-Core AMD Opteron(tm) Processor 22xx
stepping : 2

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 65
model name      : Dual-Core AMD Opteron(tm) Processor 2212 HE
stepping        : 3
cpu MHz         : 2010.298
cache size      : 1024 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush mmx fxsr sse sse2
ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy
bogomips        : 4022.18
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

23xx Quad-Core Barcelona (AMD)

vendor_id  : AuthenticAMD
cpu family  : 16
model  : 2
model name  : Quad-Core AMD Opteron(tm) Processor 23xx
stepping  : 10

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 16
model           : 2
model name      : Quad-Core AMD Opteron(tm) Processor 2354
stepping        : 3
cpu MHz         : 2200.000
cache size      : 512 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs
bogomips        : 4402.66
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate
Note: Maybe -march=barcelona will result in even better performance? please check!

Phenom X3/X4 (AMD)

vendor_id  : AuthenticAMD
cpu family  : 16
model  : 2
model name  : AMD Phenom(tm) xxxx Triple/Quad-Core Processor
stepping  : 2/3

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -msse3 -pipe"
CXXFLAGS="${CFLAGS}"
Note: The -march=amdfam10 option was added to gcc 4.3.0. You probably won't want to use that version yet.

Sempron/Sempron64 (AMD)

vendor_id : AuthenticAMD
cpu family : 15
model : 44
model name : AMD Sempron(tm) Processor

Note: The model number may differ.

32 bit (Socket A)

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

64 bit (SSE3 capable)

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -msse3 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

Sempron64 - 32 bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -msse3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Sempron64 - 64 bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -msse3 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

Turion64 / X2 (AMD)

32 bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -msse3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -msse3 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

SSE3 is called pni in /proc/cpuinfo for this Central Processing Unit.

Mobile Sempron (AMD)

vendor_id : AuthenticAMD
cpu family : 15
model : 8
model name : Mobile AMD Sempron Processor 2800+


32 bit

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -msse3 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

64 bit

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -msse3 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

If you have a Sempron without SSE3 (earlier chips), omit "-msse3".
SSE3 is called pni (prescott new instuction) by cpuinfo (cat /proc/cpuinfo).

Check it out, there are many different sempron mobile CPUs on sale, those that work at 1.8GHz are K8 (i.e. AMD SM 3000+), some others, older, aren't yet k8 but they're still k7 so you must specify athlon-xp instead of athlon64, anyway AMD announced in 2006 there will be 64bit Sempron Mobile CPUs so be carefull and pay attention, run a cat /proc/cpuinfo and then ask on AMD forums if you don't know what to do.

processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 44
model name	: Mobile AMD Sempron(tm) Processor 3000+
stepping	: 2
cpu MHz		: 1800.000
cache size	: 128 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt 3dnowext 3dnow pni lahf_lm ts fid vid ttp tm stc
bogomips	: 3602.19
clflush size	: 64

PowerPC Processors

PowerPC 601

The PowerPC 601 CPU is a mixture between POWER and PowerPC architectures and it is a must you specify -mcpu=601 for taking advantage of the POWER part of the processor and do not use unimplemented PowerPC instructions (implementation of both ISAs is incomplete on 601).

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=601 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

NOTE: Code created with this flags will not run in any other CPU but PowerPC 601, if you want to run on 601 and others use -mcpu=common and code will run in ANY POWER or PowerPC CPU.

PowerPC 603

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=603 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

PowerPC 603e

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=603e -O2 -pipe"
CXXFLAGS="${CFLAGS}"

PowerPC 604

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=604 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

PowerPC 604e

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=604e -O2 -pipe"
CXXFLAGS="${CFLAGS}"

-Os may be beneficial on older processors (of any kind, not just PowerPCs).

PowerPC 604e

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=604e -O2 -pipe -fno-strict-aliasing"
CXXFLAGS="${CFLAGS}"

PowerPC 750 (G3)

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=750 -Os -pipe -fno-strict-aliasing"
CXXFLAGS="${CFLAGS}"

Given the smaller cache sizes, and the fact that the L2 cache is off-die on the G3, better performance may be achieved with -Os rather than -O2.

PowerPC 750cx (G3e) (Nintendo Gamecube / Wii)

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=750 -O2 -pipe -fno-strict-aliasing"
CXXFLAGS="${CFLAGS}"

The 750cx offers more L2 cache than its predecessor, and moves it on-die for a performance boost. Better performance may be achieved with -O2.

PowerPC 7400 (G4)

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=7400 -O2 -pipe -maltivec -mabi=altivec"
CXXFLAGS="${CFLAGS}"

Note: -O3 is unstable on G4

PowerPC 7450 (G4 second generation)

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=7450 -O2 -pipe -maltivec -mabi=altivec"
CXXFLAGS="${CFLAGS}"

PowerPC 970 (G5)

CHOST="powerpc64-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mcpu=970"
CXXFLAGS="${CFLAGS}"

Cell Broadband Engine (Playstation 3)

CHOST="powerpc64-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mcpu=cell"
CXXFLAGS="${CFLAGS}"

PowerPC (If you don't know which one)

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"

Embedded PowerPC CPUs

You should check /proc/cpuinfo for the CPU model and then for a correct -mcpu flag on man gcc. If you do not find it, use powerpc.

CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-mcpu=<flag> -Os -pipe"
CXXFLAGS="${CFLAGS}"

Other Processors

Sparc

CHOST="sparc-unknown-linux-gnu"
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"

Sparc 64

CHOST="sparc-unknown-linux-gnu"
CFLAGS="-mcpu=ultrasparc -O2 -pipe"
CXXFLAGS="${CFLAGS}"

Be careful! The CHOST for Sparc64 is still sparc-unknown-linux-gnu, not sparc64-!

HPPA 1.1

CHOST="hppa1.1-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mschedule=7100LC -march=1.1 -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

HPPA 2.0

CHOST="hppa2.0-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mschedule=8000 -march=2.0 -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Alpha ev56

CHOST="alpha-unknown-linux-gnu"
CFLAGS="-mcpu=ev56 -mieee -O2 -pipe"
CXXFLAGS="${CFLAGS}"

Alpha ev67

CHOST="alpha-unknown-linux-gnu"
CFLAGS="-mieee -mcpu=ev67 -Wa,-mev6 -O2 -pipe "
CXXFLAGS="${CFLAGS}"

This applies to ev68 (Compaq Alpha DS25) machines too. Without -mcpu=ev67 -Wa,-mev6 flags it cannot bootstrap at all.

See Also

gcccpuopt

gcccpuopt is a script which reports the optimum (32 bit) CPU specific options for your CPU and gcc version.

Relevant files in gcc source code

These files may be interesting if you want to know what does exactly your -march= mean.

Arch File Location Search for
x86/x86-64 gcc/config/i386/i386.c processor_alias_table[]
POWER gcc/config/rs6000/rs6000.c processor_target_table[]
SPARC gcc/config/sparc/sparc.c cpu_table[]
Alpha gcc/config/alpha/alpha.c cpu_table[]
HPPA gcc/config/pa/pa.c pa_handle_option (size_t code
ARM gcc/config/arm/arm-cores.def

Other links

Retrieved from "http://www.gentoo-wiki.info/Safe_Cflags"

Last modified: Tue, 07 Oct 2008 07:27:00 +1100 Hits: 440,235

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.