# cflags.  core2 or nocona?

## RioFL

in jan 2008 i built up a q6600 core2-quad system and at the time my friend who has been running

a similar system for a while recommended i use march=nocona so i did and have continued to do so.

now i see there is a march=core2 flag. would there be enough performance benefit to warrant

a recompile? i am more than willing to do so if needed especially since i am getting ready to do

a major software upgrade to my entire system. i use an intense amount of processes

(typically more than 600) and system response time is extremely important to me.

recommendations?

my current emerge --info is below

```

Portage 2.1.6.13 (default/linux/amd64/2008.0, gcc-4.2.3, glibc-2.8_p20080602-r1, 2.6.25-gentoo-r7 x86_64)

=================================================================

System uname: Linux-2.6.25-gentoo-r7-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q6600_@_2.40GHz-with-glibc2.2.5

Timestamp of tree: Thu, 25 Jun 2009 03:20:01 +0000

app-shells/bash:     3.2_p39

dev-java/java-config: 1.3.7-r1, 2.1.7

dev-lang/python:     2.4.4-r13, 2.5.4-r2

dev-python/pycrypto: 2.0.1-r6

dev-util/cmake:      2.6.2-r1

sys-apps/baselayout: 2.0.1

sys-apps/openrc:     0.4.3-r2

sys-apps/sandbox:    1.6-r2

sys-devel/autoconf:  2.13, 2.63

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /opt/openfire/resources/security/ /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/bind /var/lib/hsqldb"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS="--with-bdeps y"

FEATURES="distlocks fixpackages parallel-fetch protect-owned sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://gentoo.chem.wisc.edu/gentoo/ ftp://ftp.ussg.iu.edu/pub/linux/gentoo http://gentoo.seren.com/gentoo"

LANG="en_US"

LC_ALL="en_US"

LDFLAGS="-Wl,-O1"

LINGUAS="en en_US"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://auggie/gentoo-portage"

USE="X Xaw3d a52 aac aalib acl acpi akode alsa amd64 amr amrnb amrwb apache2 arts asf audiofile bash-completion berkdb bluetooth branding browserplugin bzip2 cairo cddb cdio cdparanoia cli cracklib crypt cuda cups curl daap dbus dga djvu dri dts dv dvb dvd dvdr dvdread emovix encode exif extrafilters ffmpeg fftw flac foomatic foomaticdb fortran fping fpx ftp fuji gd gdbm gif gimp glitz gnokii gnome gnutls gphoto2 gpm graphviz gs gstreamer gtk hal hddtemp hdri iconv ieee1394 ifp imagemagick imap imlib inifile insecure-savers ipod isdnlog jack java java6 javascript jbig jingle jpeg jpeg2k kde lame libcaca libsamplerate live lm_sensors lzo mad matroska midi mjpeg mmap mmx mmxext mng modplug mp2 mp3 mp3rtp mp4 mpeg mplayer mtp mudflap multilib musepack musicbrainz mysql ncurses network nls nptl nptlonly nsplugin nvidia offensive ogg openexr opengl openmp pam pcre pda pdf perl php png pni povray ppds pppd python qt3 qt3support qt4 quicktime radiotap rar rdesktop readline reflection rplay samba scanner sdl session smp sms sndfile snmp sockets soup speex spell spl srt sse sse2 sse3 ssl ssse3 subtitles svg swat sysfs tcpd theora threads tidy tiff transcode truetype unicode usb v4l vcd visualization vorbis vorbis-psy wavpack wideband wifi x264 xanim xcb xcomposite xine xinerama xml xorg xpm xscreensaver xulrunner xv xvid xvmc yv12 zip zlib" ALSA_CARDS="hda" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" USERLAND="GNU" VIDEO_CARDS="nvidia"

Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY

```

----------

## d2_racing

Hi, the best for you is to use this :

```

CHOST="x86_64-pc-linux-gnu"

CFLAGS="-O2 -march=native -pipe"

CXXFLAGS="-O2 -march=native -pipe" 

```

----------

## RioFL

 *d2_racing wrote:*   

> Hi, the best for you is to use this :
> 
> ```
> 
> CHOST="x86_64-pc-linux-gnu"
> ...

 

interesting.. never knew native existed. just did  some reading on it and 

i believe you are correct it would be the best for me. i notice your cflags do not include

the -fomit-frame-pointer flag. 

major reason not to? i was under the impression it gave a reasonable performance boost.

----------

## RioFL

 *d2_racing wrote:*   

> Hi, the best for you is to use this :
> 
> ```
> 
> CHOST="x86_64-pc-linux-gnu"
> ...

 

also, if i am reading this correctly, native should be used for

best optimization for any machine, intel core series, p4 series, amd opteron series

etc.. if this is the case it simplifies my job tremendously since i also manage

a large number of servers with all of  those processors mentioned.

----------

## hielvc

I dont know if it would be better for you to use -fomit-frame-pointer for a heavily loaded box, but a couple of years ago I tested -Os and -O2 with and withpuit frame-pointer. I took a stage3 and dida emerge -e system. Basicly the code was smaller for both -Os and -O2  not using --fomit-frame-pointer.

It would be an interesting test to see how it would work on server like your s as oposed to a desktop.

----------

## RioFL

 *hielvc wrote:*   

> I dont know if it would be better for you to use -fomit-frame-pointer for a heavily loaded box, but a couple of years ago I tested -Os and -O2 with and withpuit frame-pointer. I took a stage3 and dida emerge -e system. Basicly the code was smaller for both -Os and -O2  not using --fomit-frame-pointer.
> 
> It would be an interesting test to see how it would work on server like your s as oposed to a desktop.

 

hehe this is my desktop.. my only workstation  :Smile:   i can try recompiling a few of my apps with and without, but i am afraid that unless the entire system is recompiled as well, there will be other side effects from possible libraries/support programs compiled with while the main code is without. it would probably be prohibitive given the size of my installation to simply recompile both ways for the heck of it. whichever i end up with my main requirement is my desktop and graphics be the most responsive possible under all load conditions. i have 4gb ram for this work and i never use above 2gb so size or ram usage is not an issue with me other than speed of calls, execution etc.. believe it or not the nocona flag produces acceptable results even though it is not optimized for my hardware which back then i thought it was.

i also have a number of 2x dual core opteron servers with no desktop software installed that maintain an average of 800 to 1400 processes (virtual server hosts) so it would be interesting to see what happens on that arch next time i update one of those machines. it will also be interesting to see what affect native has on the virtual servers themselves whether they will use less resources, be faster, or be worse, or the same. presently all the virtual servers and virtual server hosts are flagged with march=opteron

i am presently setting up a 2x xeon server with ht (i686) and i have set the native flag on that so i will have a chance to mess with it a bit before it goes into production and compare that one to a twin i prepped yesterday using the p4 flag. i recompile with -e world on all servers to get all code to my flags so it should be a valid test.

----------

## pdw_hu

 *RioFL wrote:*   

>  *d2_racing wrote:*   Hi, the best for you is to use this :
> 
> ```
> 
> CHOST="x86_64-pc-linux-gnu"
> ...

 

-fomit-frame-pointer on x64 and -O2 is enabled automatically, so there is no use for enabling it explicitly. See the gcc man page about -O2 for more info.

----------

## RioFL

 *pdw_hu wrote:*   

>  *RioFL wrote:*    *d2_racing wrote:*   Hi, the best for you is to use this :
> 
> ```
> 
> CHOST="x86_64-pc-linux-gnu"
> ...

 

ok. i guess that solves that issue solidly enough  :Smile: 

thanks!

----------

## hielvc

Actually thats wrong. From info gcc >>Invoking GCC>>Optimize Options

 *Quote:*   

> `-O' also turns on `-fomit-frame-pointer' on machines where doing
> 
>      so does not interfere with debugging.

  In an x86 it is used  for debugging so it is not turned on. To see for yourself run this echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test

```
 echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test

Using built-in specs.

Target: i686-pc-linux-gnu

Configured with: /var/tmp/portage/sys-devel/gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --disable-nls --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.2, pie-10.1.5'

Thread model: posix

gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.2, pie-10.1.5) 

COLLECT_GCC_OPTIONS='-v' '-Q'  '-O2' '-o' 'test'

 /usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/cc1 -v test.c -D_FORTIFY_SOURCE=2 -march=k8-sse3 -mcx16 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 -mtune=k8 -dumpbase test.c -auxbase test -O2 -version -o /tmp/cceAa8iX.s

ignoring nonexistent directory "/usr/local/include"

ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include

 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include-fixed

 /usr/include

End of search list.

GNU C (Gentoo 4.3.3-r2 p1.2, pie-10.1.5) version 4.3.3 (i686-pc-linux-gnu)

   compiled by GNU C version 4.3.3, GMP version 4.3.1, MPFR version 2.4.1-p5.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

options passed:  -v test.c -D_FORTIFY_SOURCE=2 -march=k8-sse3 -mcx16

 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 -mtune=k8

 -O2

options enabled:  -falign-labels -falign-loops -fargument-alias

 -fauto-inc-dec -fbranch-count-reg -fcaller-saves -fcommon

 -fcprop-registers -fcrossjumping -fcse-follow-jumps -fdefer-pop

 -fdelete-null-pointer-checks -fearly-inlining

 -feliminate-unused-debug-types -fexpensive-optimizations

 -fforward-propagate -ffunction-cse -fgcse -fgcse-lm

 -fguess-branch-probability -fident -fif-conversion -fif-conversion2

 -finline-functions-called-once -finline-small-functions -fipa-pure-const

 -fipa-reference -fivopts -fkeep-static-consts -fleading-underscore

 -fmath-errno -fmerge-constants -fmerge-debug-strings

 -fmove-loop-invariants -foptimize-register-move -foptimize-sibling-calls

 -fpcc-struct-return -fpeephole -fpeephole2 -fregmove -freorder-blocks

 -freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec

 -fsched-stalled-insns-dep -fschedule-insns2 -fsigned-zeros

 -fsplit-ivs-in-unroller -fsplit-wide-types -fstrict-aliasing

 -fstrict-overflow -fthread-jumps -ftoplevel-reorder -ftrapping-math

 -ftree-ccp -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-cselim

 -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im

 -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=

 -ftree-pre -ftree-reassoc -ftree-salias -ftree-scev-cprop -ftree-sink

 -ftree-sra -ftree-store-ccp -ftree-ter -ftree-vect-loop-version -ftree-vrp

 -funit-at-a-time -fvar-tracking -fvect-cost-model

 -fzero-initialized-in-bss -m32 -m3dnow -m80387 -m96bit-long-double

 -maccumulate-outgoing-args -malign-stringops -mcld -mcx16 -mfancy-math-387

 -mfp-ret-in-387 -mfused-madd -mglibc -mieee-fp -mmmx -mno-red-zone

 -mno-sse4 -mpush-args -msahf -msse -msse2 -msse3 -mtls-direct-seg-refs

Compiler executable checksum: a77f9e081a922a49ebbf25a3ae97ab64

 main

Analyzing compilation unit

Performing interprocedural optimizations

 <visibility> <early_local_cleanups> <inline> <static-var> <pure-const>Assembling functions:

 main

Execution times (seconds)

 symout                :   0.01 (100%) usr   0.00 ( 0%) sys   0.01 (20%) wall       0 kB ( 0%) ggc

 TOTAL                 :   0.01             0.00             0.05                590 kB

Internal checks disabled; compiler is not suited for release.

Configure with --enable-checking=release to enable checks.

COLLECT_GCC_OPTIONS='-v' '-Q'  '-O2' '-o' 'test'

 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/ccC6cMqL.o /tmp/cceAa8iX.s

GNU assembler version 2.19.1 (i686-pc-linux-gnu) using BFD version (GNU Binutils) 2.19.1

COMPILER_PATH=/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/bin/

LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../:/lib/:/usr/lib/

COLLECT_GCC_OPTIONS='-v' '-Q'  '-O2' '-o' 'test'

 /usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../.. /tmp/ccC6cMqL.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../crtn.o
```

EDIT: removed reference to " x86_64 ": See nightmorphs 2 cents below   :Razz: 

----------

## RioFL

 *hielvc wrote:*   

> Actually thats wrong. From info gcc >>Invoking GCC>>Optimize Options
> 
>  *Quote:*   `-O' also turns on `-fomit-frame-pointer' on machines where doing
> 
>      so does not interfere with debugging.  In an x86 and probably x86_64 it is used used for debugging so it is not turned on. To see for yourself run this echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test
> ...

 

yeah i see. that's ok i am leaving it in the flags anyway.

----------

## hielvc

This is just guess but I would think having an extra register would help with the load you have.

----------

## RioFL

 *hielvc wrote:*   

> This is just guess but I would think having an extra register would help with the load you have.

 

after having these conversations and reading a bit i think i agree. by keeping -fomit-frame-pointer i think it can only help

i dont't need/care about debugging anyway, and if i must debug something i can always recompile that as needed.

----------

## 96140

--Last edited by 96140 on Wed Sep 11, 2013 8:34 am; edited 1 time in total

----------

## d2_racing

 *RioFL wrote:*   

>  i notice your cflags do not include
> 
> the -fomit-frame-pointer flag. 
> 
> major reason not to? i was under the impression it gave a reasonable performance boost.

 

Because the native option will enable that automagically  :Razz: 

----------

## hielvc

Not on a x86 D2.  :Razz: 

----------

## hielvc

Well this interesting. I booted up SystemRescue and booted into the amd64 option. I ran the test code and NO  -fomit-frame-pointer

 *Quote:*   

> options passed:  -v -march=k8 -mtune=k8 -auxbase -O2
> 
> options enabled:  -falign-loops -fargument-alias -fbranch-count-reg
> 
>  -fcaller-saves -fcommon -fcprop-registers -fcrossjumping
> ...

 

I then ran  echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2  -fomit-frame-pointer test.c -o test && rm test.c test and got this  *Quote:*   

> options passed:  -v -march=k8 -mtune=k8 -auxbase -O2 -fomit-frame-pointer
> 
> options enabled:  -falign-loops -fargument-alias -fbranch-count-reg
> 
>  -fcaller-saves -fcommon -fcprop-registers -fcrossjumping
> ...

 

Im leary of this output but here is the emerge info  *Quote:*   

> root@sysresccd /root % emerge --info
> 
> Portage 2.1.4.5 (unavailable, gcc-4.2.4, glibc-2.7-r2, 2.6.27.07-std113-amd64 x86_64)
> 
> =================================================================
> ...

  Which looks to 64bit but it is using gcc-4.2.4 as opposed to 4.3 or 4.4

----------

## d2_racing

@hielvc, can you test on a x86 box with Gcc 4.3 or 4.4, just to see if native will enable some extra stuff ?

----------

## Hu

That system rescue CD looks to be using a 32-bit gcc.  The creator may have opted to save space by distributing both 32-bit and 64-bit kernels, but only 32-bit user programs.  Booting the 64-bit kernel would be necessary to execute 64-bit user programs on the system being rescued.  Everything else should be feasible with pure 32-bit.  A 64-bit kernel can be compiled to be able to run 32-bit user programs, and can even operate a system which has only 32-bit user programs.  Check the output of gcc -v to see whether it is a 32-bit gcc (Target: i686-pc-linux-gnu or similar) or a 64-bit gcc (Target: x86_64-pc-linux-gnu).

----------

## hielvc

I mostly installed a funtoo ~amd64 yesterday. 

```
gcc -v Target: x86_64-pc-linux-gnu gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.2, pie-10.1.5)
```

It does  have  "-fmove-loop-invariants  -fomit-frame-pointer -foptimize-register-move" from the "-O2".

----------

## d2_racing

So maybe it depends on what version of GCC we are using.

----------

## hielvc

That and your CHOST I would guess.  If you look at the SystemRescue its CHOST="i486-pc-linux-gnu" . My 32bit was "i686" and its now x86_64.

----------

