You are not logged in.

#1 2004-10-06 03:35:35

ruwach
Member
Registered: 2004-06-14
Posts: 143

CFLAGS and CXXFLAGS question

Hey there, little geeky question here.
I am currently recompiling all my main packages with srcpac. Its so cool to do. I have noticed an awesome difference in speed with the heavier apps, like X and Mozilla.
by the suggestion from the gentoo.org website, i have this entered into my makepkg.conf file.

export CFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer"
export CXXFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer"

Now, when i do a cat /proc/cpu info, there are all these flags listed like mmx mmxext, 3dnow, 3dnowext, and some others. Would i have anything to gain adding them also to my makepkg.conf ? Or are these flags for something else?

Any suggestions ?

Thanks.

Offline

#2 2004-10-06 04:22:55

paranoos
Member
From: thornhill.on.ca
Registered: 2004-07-22
Posts: 442

Re: CFLAGS and CXXFLAGS question

You've noticed an awesome difference?
Gentoo propagandists are famous for saying compiler optimizations make a huge difference, when they have no proof of the fact.

Quite the contrary, there is evidence that compiling your kernel and your apps with different optimizations will hinder performance. Sure, you could compile your kernel with those same optimizations. But then all your other apps will be hindered. So then what? Custom compile everything? Firstly, that's not what Arch is for, and secondly, it is a HUGE waste of time.

Even if you could measure that your custom Mozilla build starts up a whole second faster, take into consideration that it could take an hour to compile. Is it worth it? Is it really?

Anyway, as I was saying about compiling your apps with optimization. My old PC was powered by a Duron 800. It wasn't fast enough to play the highest resolution Matrix Revolutions trailer with MPlayer, my favourite video player for Linux. The audio and video were out of sync with each other. I compiled mplayer with march=i686, and march=athlon. Believe it or not, the video was consistently and measurably more out of sync when compiled for athlon (most likely because i'm running an i686 kernel provided by Arch).

And about your question about SSE and MMX 3Dnow! etc... compiling with -march=athlon enables all those optimizations. Compiling with i686 enables MMX, as all 686 processors include those instructions.

Offline

#3 2004-10-06 04:33:51

ruwach
Member
Registered: 2004-06-14
Posts: 143

Re: CFLAGS and CXXFLAGS question

good enough, thanks for the info, didn't know that about the 686 stuff.
i like compiling stuff locally just because it looks neat in a transparent aterm.

thanks again

Offline

#4 2004-10-06 15:10:14

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: CFLAGS and CXXFLAGS question

nothing wrong with those optimizations but be warned that compiling things like glibc with those options is not wise. my understanding is glibc should only be compile with basic flags.

i am very surprised you noticed a difference with those options because i never did. in fact alot of things ran very poorly with -O3 for me. when you get into things like -O3 you are tlking not about speed improvement but efficiency. the more you optimize to your processor the more efficiently it will run but efficiency does not mean speed.


AKA uknowme

I am not your friend

Offline

#5 2004-10-06 15:39:31

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: CFLAGS and CXXFLAGS question

I have to agree, I did not notice anything when using the specific flags.  I have some school apps that take about an hour to run over some data and I thought that I would recompile the kernel (and the c++ analysis code) and it would be better, but there was no difference.  It must really depend upon what the application does as well.

Offline

#6 2004-10-06 16:40:11

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: CFLAGS and CXXFLAGS question

the only optimization i've seen do a noticable difference was unroll_loops - and that only on soem custom programs.... I was actually testing some loop progression and how unroll_loops behaved....
but IIRC loops are unrolled by default?  maybe not as it will increase execuatable size... who knows

Offline

#7 2005-01-13 16:43:46

jp_fielding
Member
Registered: 2004-08-28
Posts: 85

Re: CFLAGS and CXXFLAGS question

along these lines of goofing with compiler options, i rebuilt my kernel and was working on recompiling xorg targeted for the pentium4, but after setting the CXX/CFLAGS, they do not appear to be getting used.  when playing around with gentoo and doing an 'emerge' i would notice that the flags were directly included in the gcc line.  i even tried sourcing the makepkg to ensure the variables where available.

am i missing something, how are these included?

# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon exclusive (binaries
# will use the P6 instruction set and only run on P6+ systems)
export CFLAGS="-march=pentium4 -O2 -pipe"
export CXXFLAGS="-march=pentium4 -O2 -pipe"
gcc -m32 -c -O2 -fno-strength-reduce -fno-strict-aliasing  -ansi -pedantic -Wall -Wpointer-arith -Wundef    -I../.. -I../../exports/include   -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L                           -D_POSIX_SOURCE -D_XOPEN_SOURCE                                 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE                             -DFUNCPROTO=15 -DNARROWPROTO -DXTHREADS  -D_REENTRANT -DXUSE_MTSAFE_API    -DMALLOC_0_RETURNS_NULL  -DHAS_SNPRINTF -DLIBX1-DPOSTLOCALELIBDIR="lib"  -I../../lib/xtrans -DUNIXCONN -DTCPCONN -DHAS_STICKY_DIR_BIT -DHAS_FCHOWN -DIPv6  -DX11_t -DTRANS_CLIENT -DFAIL_HARD    -fPIC x11trans.c
rm -f ximtrans.o

thx,
jp

Offline

#8 2005-01-13 17:27:50

luisfelipe
Member
Registered: 2004-05-06
Posts: 96

Re: CFLAGS and CXXFLAGS question

Hey,

you can enter specific information about mmx, sse and stuff on the CFLAGS and CXXFLAGS.
Here are the ones I use :

export CFLAGS="-march=pentium3 -mfpmath=sse,387 -msse -mmmx -O3 -pipe -fomit-frame-pointer"
export CXXFLAGS="-march=pentium3 -mfpmath=sse,387 -msse -mmmx -O3 -pipe -fomit-frame-pointer"

Depending on the application you're compiling, you can do further optimization.
There is a nice text about a guy optimizing those flags on an athlon-xp system here :
http://home.comcast.net/~jcunningham63/ … ation.html

But he was doing those optimizations to compile code he wrote himself, so be warned
that lots of stuff he uses can't really be used on the regular applications (like -ffast-math).

By the way, if you were wondering how to pronounce Dijkstra's name , here is a wave :
http://badibulgator.free.fr/Dijkstra.wav
(I know it had nothing to do with the subject, but I just found that wave file and I always
wondered what was the real way to pronounce it)

Offline

#9 2005-01-13 17:30:35

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: CFLAGS and CXXFLAGS question

luisfelipe wrote:

By the way, if you were wondering how to pronounce Dijkstra's name , here is a wave :
http://badibulgator.free.fr/Dijkstra.wav
(I know it had nothing to do with the subject, but I just found that wave file and I always
wondered what was the real way to pronounce it)



always thought it was "die-k stra"... but cant hear the wav (at work, no sound card, lol)

Offline

#10 2005-01-13 17:34:48

luisfelipe
Member
Registered: 2004-05-06
Posts: 96

Re: CFLAGS and CXXFLAGS question

No problem. Just take a look here :
http://badibulgator.free.fr/Dijkstra.wav

Hope that helped you smile

EDIT: Well, I was in a hurry and didn't even realize I just pasted the same address again.
Here's the correct one :
http://c2.com/cgi/wiki?PronouncingDutch


Sorry tongue

Offline

#11 2005-01-13 17:52:45

jp_fielding
Member
Registered: 2004-08-28
Posts: 85

Re: CFLAGS and CXXFLAGS question

actually, it's not what i can set that seems to be the problem, but rather that the settings don't 'appear' to be used. 

after setting those flags, and calling srcpac, i do not see the string 'pentium4' ever referenced on a gcc compilation

Offline

#12 2005-01-13 18:07:01

luisfelipe
Member
Registered: 2004-05-06
Posts: 96

Re: CFLAGS and CXXFLAGS question

some packages just ignore the CFLAGS and CXXFLAGS that are set on makepkg.conf
try editing their PKGBUILD and put that stuff there yourself

Offline

#13 2005-01-13 18:19:40

jp_fielding
Member
Registered: 2004-08-28
Posts: 85

Re: CFLAGS and CXXFLAGS question

cool, i'll try that, thx

Offline

#14 2005-01-13 18:26:41

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: CFLAGS and CXXFLAGS question

jp_fielding wrote:

actually, it's not what i can set that seems to be the problem, but rather that the settings don't 'appear' to be used. 

after setting those flags, and calling srcpac, i do not see the string 'pentium4' ever referenced on a gcc compilation

alot of Makefiles do not use the CFLAGS and CXXFLAGS environment variables.... for this reason, sed is sometimes used to inject the CFLAGS into the Makefile....

for instance, the mozilla-firefox PKGBUILD uses the token "#CFLAGS#" for the makefile, and has sed replace #CFLAGS# with the environment variable at the time of the build....

I am assuming srcpac doesn't have the capability to do this (it's be very very hard to do...)

Offline

Board footer

Powered by FluxBB