Safe CFLAGS

Finding your CPU
To identify the model of your CPU, you can look inside for the "cpu family" and "model" numbers like so:

Once you find this information, you can then match your CPU to one listed on this page in order to find out the suggested "safe" CFLAGS.

Below you can find a list of CFLAGS which are to be considered "safe" for the given processors. These are the settings you should use if you are unsure which CFLAGS your processor needs.

Find cpu-specific options
At first, create two files and set language to english for get sed working:

Compile the first file like following:

Get march, which gcc will choose:

options passed:

Now compile second file:

Now clean the *.s files for easy comparing:

When you not set LANG on an localised system, you have now empty files.

Compare both *.s files:

Output empty? You found your -march=, use it. In other cases:

20,25c20,23 < # -maccumulate-outgoing-args -maes -malign-stringops -mavx < # -mavx256-split-unaligned-load -mavx256-split-unaligned-store -mcx16 < # -mf16c -mfancy-math-387 -mfp-ret-in-387 -mfsgsbase -mfxsr -mglibc < # -mieee-fp -mlong-double-80 -mmmx -mpclmul -mpopcnt -mpush-args -mrdrnd < # -mred-zone -msahf -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 < # -mtls-direct-seg-refs -mxsave -mxsaveopt --- > # -maccumulate-outgoing-args -malign-stringops -mcx16 -mfancy-math-387 > # -mfp-ret-in-387 -mfsgsbase -mfxsr -mglibc -mieee-fp -mlong-double-80 > # -mmmx -mpclmul -mpopcnt -mpush-args -mred-zone -msahf -msse -msse2 -msse3 > # -msse4 -msse4.1 -msse4.2 -mssse3 -mtls-direct-seg-refs

Now guess, which switches -march=core-avx-i enable and -march=native not: -maes -mavx and some more. Now we build march.cc again with this two switches disabled:

gcc -fverbose-asm -march=core-avx-i -mno-aes -mno-avx march.cc -S sed -i 1,/options\ enabled/d march.s diff march.s native.s

< # -mmmx -mpclmul -mpopcnt -mpush-args -mrdrnd -mred-zone -msahf -msse < # -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mtls-direct-seg-refs --- > # -mmmx -mpclmul -mpopcnt -mpush-args -mred-zone -msahf -msse -msse2 -msse3 > # -msse4 -msse4.1 -msse4.2 -mssse3 -mtls-direct-seg-refs

One switch we need to disable too: -mrdrnd

Finally set CFLAGS:

Core i3/i5/i7 & Xeon E3/E5/E7 *V2
vendor_id	: GenuineIntel cpu family	: 6 model		: 60 model name	: Intel(R) Xeon(R) CPU E3-1271 v3 @ 3.60GHz … model          : 60 model name     : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz

Core i3/i5/i7 & Xeon E3/E5/E7 *V1
vendor_id      : GenuineIntel cpu family     : 6 model          : 58 model name     : Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz

Pentium
vendor_id	: GenuineIntel cpu family	: 6 model		: 58 model name	: Intel(R) Pentium(R) CPU G2020 @ 2.90GHz

Core i3/i5/i7 & Xeon E3/E5/E7
vendor_id	: GenuineIntel cpu family	: 6 … model		: 42 model name	: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz … model		: 45 model name	: Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz … model		: 42 model name	: Intel(R) Xeon(R) CPU E31245 @ 3.30GHz … model          : 45 model name     : Intel(R) Xeon(R) CPU E5-2407 0 @ 2.20GHz

Pentium
vendor_id	: GenuineIntel cpu family	: 6 model		: 42 model name	: Intel(R) Pentium(R) CPU B960 @ 2.20GHz

Core i3/i5/i7
vendor_id	: GenuineIntel cpu family	: 6 model		: 42 model name	: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz

Intel Core
vendor_id      : GenuineIntel cpu family     : 6 … model		: 15 model name	: Intel(R) Core(TM)2 Duo CPU    T7500  @ 2.20GHz … model          : 15 model name     : Intel(R) Xeon(R) CPU            3040  @ 1.86GHz

Pentium M (Dothan)
vendor_id	: GenuineIntel cpu family	: 6 model		: 13 model name	: Intel(R) Pentium(R) M processor 2.13GHz

A4/A6/A8-XXXX / XXXXM
vendor_id	: AuthenticAMD cpu family	: 18 model		: 1 model name	: AMD A8-3500M APU with Radeon(tm) HD Graphics

FX-XXXX
vendor_id	: AuthenticAMD cpu family	: 21 model		: 1 model name	: AMD FX(tm)-8150 Eight-Core Processor

Make sure and check the number listed by  on your system, the -march flag should be bdverX where X is the model number.

Due to the FPU design of the Bulldozer architecture, -mprefer-avx128 gives better FPU preformance at the cost of precision.

The -mvzeroupper switch will give much less of a preformance penalty when using both SSE and AVX, it isn't much of a performance boost for most apps, but can provide a significant improvement when used with stuff like media-video/ffmpeg, net-misc/bfgminer or some apps in games-emulation that have some sections coded in assembly.

Geode LX
vendor_id	: AuthenticAMD cpu family	: 5 model		: 10 model name	: Geode(TM) Integrated Processor by AMD PCS

with optional VFPv3 FPU
processor      : 0 model name     : ARMv7 Processor rev 0 (v7l) BogoMIPS       : 2.00 Features       : half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls CPU implementer : 0x41 CPU architecture: 7 CPU variant    : 0x1 CPU part       : 0xc09 CPU revision   : 0

processor      : 1 model name     : ARMv7 Processor rev 0 (v7l) BogoMIPS       : 2.00 Features       : half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls CPU implementer : 0x41 CPU architecture: 7 CPU variant    : 0x1 CPU part       : 0xc09 CPU revision   : 0

Hardware       : NVIDIA Tegra SoC (Flattened Device Tree) Revision       : 0000 Serial         : 0000000000000000

ARMv6/ARM1136JF-S
Processor      : ARMv6-compatible processor rev 5 (v6l) BogoMIPS       : 791.34 Features       : swp half thumb fastmult vfp edsp java CPU implementer : 0x41 CPU architecture: 6TEJ CPU variant    : 0x1 CPU part       : 0xb36 CPU revision   : 5

Hardware       : IMAPX200 Revision       : 0000 Serial         : 0000000000000000

ppc/ppc64
Note: -march=native almost never works on PowerPC.

Cell
processor	: 0 cpu		: Cell Broadband Engine, altivec supported clock		: 3192.000000MHz revision	: 5.1 (pvr 0070 0501)

processor	: 1 cpu		: Cell Broadband Engine, altivec supported clock		: 3192.000000MHz revision	: 5.1 (pvr 0070 0501)

timebase	: 79800000 platform	: PS3 model		: SonyPS3

G3 (PPC 7XX)
processor      : 0 cpu            : 740/750 clock          : 400.000000MHz revision       : 131.0 (pvr 0008 8300) bogomips       : 49.93 timebase       : 24966218 platform       : PowerMac model          : PowerBook3,1 machine        : PowerBook3,1 motherboard    : PowerBook3,1 MacRISC2 MacRISC Power Macintosh detected as    : 70 (PowerBook Pismo) pmac flags     : 0000001f L2 cache       : 1024K unified pmac-generation : NewWorld

Not in the List
Try the following command to see if you will see something useful.

You will get something like below...

Notice the -march reply?

Get this info from Distcc Wiki Page

= External Resources =