Starting Off

Make sure you’ve at least looked at the following document: Gentoo Optimization Guide.

Checking Flags

The only real change we want to make to our system are simple things we know will not break it. Thus, we only look at making sure that we have the correct flags for enabling all of the instruction sets that our processor has available.

Checking Processor

grep flags /proc/cpuinfo | grep uniq

This pulls out all of the features of the processor as detected by the kernel. Example output is shown (line breaks added for readability):

alunduil@elijah ~ $ grep flags /proc/cpuinfo | uniq
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 rdtscp lm 3dnowext 3dnow rep_good
extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic
cr8_legacy 3dnowprefetch

Checking Default Flags

gcc does a great job of determining what flags should be set by using the new -march=native flag (which you should have set by this point). Using the following command we can double check that all of the instructions we want enabled are enabled:

gcc -Q -c -v -march=native –help=target | grep disabled

If anything appears in the resulting list, it’s not enabled and should be enabled by adding the appropriate -m flag. For my cpu this results in: -msse3 -m3dnow.

Putting it Together

By adding the original guide with a check for instructions, we allow gcc to utilize the instructions that were specifically created for uses we may have (multimedia, extended math, etc).

The resulting CFLAG variable that I placed in my make.conf from the above discussion:

CFLAGS=”-march=native -O2 -pipe -msse3 -m3dnow”

Alex Brandt

An avid Linux user for many years (since 2004). Have moved through Fedora, Slackware, and finally settled on Gentoo as a distribution of choice. Hacking Gentoo and other software as well as playing bass pass the time and add a flair of fun.

  One Response to “Optimizing Gentoo CFLAGS”

  1. [...] For more information on how -march and -m work together I've written a small article on the matter: http://www.alunduil.com/2009/12/18/o…gentoo-cflags/. Regards, [...]

Sorry, the comment form is closed at this time.

   
© 2011 Alunduil's Hosting Suffusion theme by Sayontan Sinha