Showing posts with label CFLAGS. Show all posts
Showing posts with label CFLAGS. Show all posts

Aug 10, 2008

Setting CFLAGS #2

It turns out that with GCC 4.2.1 and later there is a new 'native' architecture flag for '-march' and '-mtune' that simplifies the setting of 'CFLAGS' greatly. Now instead of having to manually determine the exact architecture you can let GCC do it for you. If you trust it. Example:

CFLAGS="-march=native"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS

previous post: 'Setting CFLAGS'

Apr 5, 2008

Setting CFLAGS

It turns out the gento-wiki has a great page indicating which GCC -march flag should be set for which CPUs. To determine which CPU you have, run the following at a command prompt:

#> cat /proc/cpuinfo

It will yield a page of output. The first few lines of output from my laptop are below:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz
stepping : 10

The part you're interested in is the 'cpu family' and 'model'. Once you know those find the corresponding entries on http://gentoo-wiki.com/Safe_Cflags. Then create an entry in $HOME/.bashrc file that looks something like this:
CFLAGS="-march=prescott -O3"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS

Of course substitute the -march value for the one you found on the wiki.