Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CFlags This Guy Left = WTF?
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
bobber205
Guru
Guru


Joined: 23 Aug 2006
Posts: 561
Location: Oregon

PostPosted: Tue Sep 04, 2007 5:10 pm    Post subject: CFlags This Guy Left = WTF? Reply with quote

Quote:

#CFLAGS="-O3 -march=pentium3 -msse -mmmx -funroll-loops -pipe"

While trying to fix the expat issue on our server, I was having seriously weird segfault errors.
What do you know. I looked at the cflags and saw that...

I replaced them with more sane ones and reemerged gcc 4. I am now on my way to recovery.

What I want to know is why the guy that did the server before me decided those were a good idea. :roll:
_________________
Never Forget The Expat 2.0!
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Tue Sep 04, 2007 5:12 pm    Post subject: Reply with quote

Moved from Kernel & Hardware to Gentoo Chat.
Not the kind of question we can answer. Ask that person himself, or perhaps his shrink.
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
jabol
Apprentice
Apprentice


Joined: 05 Oct 2005
Posts: 269

PostPosted: Tue Sep 04, 2007 5:55 pm    Post subject: Reply with quote

I myself did stuff like that on my personal computer. Now, I was having strange segfaults all the time (or maybe, say, from time to time), especially with big packages... Although I remember also having sth. about fast-math and sse2 or even 3dnow in CFLAGS. Then I understood that Gentoo is not about being mad, but about being lazy :lol: .

Have a emerge -e world. A good pizza, film and a coffee will do in the meantime ;).
Back to top
View user's profile Send private message
transient
l33t
l33t


Joined: 13 Jan 2005
Posts: 759

PostPosted: Wed Sep 05, 2007 6:49 am    Post subject: Reply with quote

In the words of a great ex-dev, HOLY COW I'M GOING SO FAST OH F***
Back to top
View user's profile Send private message
enderandrew
l33t
l33t


Joined: 25 Oct 2005
Posts: 731

PostPosted: Wed Sep 05, 2007 7:10 am    Post subject: Re: CFlags This Guy Left = WTF? Reply with quote

bobber205 wrote:
Quote:

#CFLAGS="-O3 -march=pentium3 -msse -mmmx -funroll-loops -pipe"

I replaced them with more sane ones and reemerged gcc 4. I am now on my way to recovery.


If your cup support sse and mmx instruction sets (almost everyone does) those flags are listed as being completely stable. The official Gentoo stable flags start with -march=foo, where foo is your march, and that tag actually implies the use of msse and mmmx, so those flags are redundant, but not unsafe. The only unsafe flag there is -funroll-loops. The weird thing is that I was pretty sure the toolchain eclass (and the gcc makefile) filtered out pretty much most every flag, so the toolchain is always built with safe flags. However, the segfaults probably came from another package that was borked from -funroll-loops.
_________________
Nihilism makes me smile.
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Wed Sep 05, 2007 10:40 am    Post subject: Reply with quote

Thanks transient :) That was hilarious!
_________________
creaker wrote:
systemd. It is a really ass pain

update - "a most excellent portage wrapper"

#friendly-coders -- We're still here for you™ ;)
Back to top
View user's profile Send private message
aidanjt
Veteran
Veteran


Joined: 20 Feb 2005
Posts: 1118
Location: Rep. of Ireland

PostPosted: Wed Sep 05, 2007 11:42 am    Post subject: Re: CFlags This Guy Left = WTF? Reply with quote

enderandrew wrote:
bobber205 wrote:
Quote:

#CFLAGS="-O3 -march=pentium3 -msse -mmmx -funroll-loops -pipe"

I replaced them with more sane ones and reemerged gcc 4. I am now on my way to recovery.


If your cup support sse and mmx instruction sets (almost everyone does) those flags are listed as being completely stable. The official Gentoo stable flags start with -march=foo, where foo is your march, and that tag actually implies the use of msse and mmmx, so those flags are redundant, but not unsafe. The only unsafe flag there is -funroll-loops. The weird thing is that I was pretty sure the toolchain eclass (and the gcc makefile) filtered out pretty much most every flag, so the toolchain is always built with safe flags. However, the segfaults probably came from another package that was borked from -funroll-loops.


-O3 can be dodgy as well.
_________________
juniper wrote:
you experience political reality dilation when travelling at american political speeds. it's in einstein's formulas. it's not their fault.
Back to top
View user's profile Send private message
transient
l33t
l33t


Joined: 13 Jan 2005
Posts: 759

PostPosted: Wed Sep 05, 2007 11:49 am    Post subject: Reply with quote

steveL wrote:
Thanks transient :) That was hilarious!

Indeed, my favourite part was the global enabling of the truetype BCI define in his CFLAGS.
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Sep 05, 2007 12:08 pm    Post subject: Re: CFlags This Guy Left = WTF? Reply with quote

bobber205 wrote:
Quote:

#CFLAGS="-O3 -march=pentium3 -msse -mmmx -funroll-loops -pipe"

While trying to fix the expat issue on our server, I was having seriously weird segfault errors.
What do you know. I looked at the cflags and saw that...

I replaced them with more sane ones and reemerged gcc 4. I am now on my way to recovery.

What I want to know is why the guy that did the server before me decided those were a good idea. :roll:


As someone said, mmx and sse are included in the pentium3 specification

gcc man page wrote:

pentium3, pentium3m
Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set support.


They are redundant, in any case, and not needed. But they aren't dangerous. On the opposite side, -funroll-loops (like almost anything starting with "fun" :P) is risky.

-O3 is known to cause some minor trouble here and there. But usually the packages that have problems with it, filter that flag (it doesn't mean that it can't cause some trouble still). Usually, -O2 is considered to be safer (and in my opinion, smarter). So it is the default.


Last edited by i92guboj on Wed Sep 05, 2007 12:23 pm; edited 2 times in total
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Sep 05, 2007 12:11 pm    Post subject: Reply with quote

transient wrote:
steveL wrote:
Thanks transient :) That was hilarious!

Indeed, my favourite part was the global enabling of the truetype BCI define in his CFLAGS.


That demonstrates the big big big capacity that the human brain has to absorb completely unsorted, and useless information. People see things into the forums, google or TV and they just assume that it must be true. Obviously, he did not even know what he was writing on his make.conf. He just assumed that the most "optimizations" the better, and just threw they all into his make.conf without even having a clue on what the hell we was doing.

If he knew what he was doing, in first place, he would have been ashamed to post such a thing on bugzilla.
Back to top
View user's profile Send private message
bobber205
Guru
Guru


Joined: 23 Aug 2006
Posts: 561
Location: Oregon

PostPosted: Wed Sep 05, 2007 1:49 pm    Post subject: Reply with quote

The package that was failing was apr-util btw. :)
_________________
Never Forget The Expat 2.0!
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Wed Sep 05, 2007 1:49 pm    Post subject: Reply with quote

i92guboj wrote:
That demonstrates the big big big capacity that the human brain has to absorb completely unsorted, and useless information. People see things into the forums, google or TV and they just assume that it must be true. Obviously, he did not even know what he was writing on his make.conf. He just assumed that the most "optimizations" the better, and just threw they all into his make.conf without even having a clue on what the hell we was doing.

True.
Quote:
If he knew what he was doing, in first place, he would have been ashamed to post such a thing on bugzilla.

Yeah, but it was funny ;) IMO he'll just look back it with humour.
Back to top
View user's profile Send private message
StifflerStealth
Retired Dev
Retired Dev


Joined: 03 Jul 2002
Posts: 968

PostPosted: Wed Sep 05, 2007 6:27 pm    Post subject: Reply with quote

Those flags actually look stable compared to some flags I found before. I saved the config just to remember it.

Quote:
CFLAGS="-Os -march=pentium4 -fweb -pipe -mmmx -msse2 -mfpmath=sse -masm=intel -fforce-addr -frename-registers -finline-functions -freorder-blocks"


I think he/she/it was trying to break the system. :P It worked too.
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Wed Sep 05, 2007 6:34 pm    Post subject: Reply with quote

Yeee... now you've all got me worried... How safe is my CFLAGS?

Quote:
CFLAGS="-O2 -march=opteron -msse3 -mfpmath=sse -pipe -fomit-frame-pointer"


I want to go back to -Os, but it caused problems in the past :(
I wonder if it's stable yet? The allure of smaller binaries is very strong for me...
Back to top
View user's profile Send private message
96140
Retired Dev
Retired Dev


Joined: 23 Jan 2005
Posts: 1324

PostPosted: Wed Sep 05, 2007 9:11 pm    Post subject: Reply with quote

--

Last edited by 96140 on Fri Sep 13, 2013 9:06 am; edited 1 time in total
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Wed Sep 05, 2007 9:27 pm    Post subject: Reply with quote

nightmorph wrote:
Also, -Os is definitely not safe; I heard from a few developers on this when I wrote my guide. -Os is one of the most filtered flags by ebuilds; many, many things don't like it. The binaries will only maybe be a tiny bit smaller anyway; it's more useful for applications that have to run on CPUs with miniscule cache sizes. Opterons/Athlon64s have generous cache sizes. Stick with -O2.
Hmmm I've been using Os on my laptop for some time now and never had a problem, but maybe that's just because it's mostly filtered out. Maybe I should switch back to O2.....
Back to top
View user's profile Send private message
Corona688
Veteran
Veteran


Joined: 10 Jan 2004
Posts: 1204

PostPosted: Thu Sep 06, 2007 3:12 pm    Post subject: Reply with quote

transient wrote:
steveL wrote:
Thanks transient :) That was hilarious!

Indeed, my favourite part was the global enabling of the truetype BCI define in his CFLAGS.
What, not even a chuckle over USE="GAPING_SECURITY_HOLE"?

I've never seen executables made more than a miniscule fraction smaller with -Os. I'm left to wonder if it's doing something less than obvious -- minimizing jumps, etc. to stay in the same area of code memory longer, rather than making code smaller in general.
_________________
Petition for Better 64-bit ATI Drivers - Sign Here
http://www.petitiononline.com/atipet/petition.html
Back to top
View user's profile Send private message
Phenax
l33t
l33t


Joined: 10 Mar 2006
Posts: 972

PostPosted: Thu Sep 06, 2007 8:12 pm    Post subject: Reply with quote

BlackEdder wrote:
nightmorph wrote:
Also, -Os is definitely not safe; I heard from a few developers on this when I wrote my guide. -Os is one of the most filtered flags by ebuilds; many, many things don't like it. The binaries will only maybe be a tiny bit smaller anyway; it's more useful for applications that have to run on CPUs with miniscule cache sizes. Opterons/Athlon64s have generous cache sizes. Stick with -O2.
Hmmm I've been using Os on my laptop for some time now and never had a problem, but maybe that's just because it's mostly filtered out. Maybe I should switch back to O2.....


Generally, a lot of -O* and other non-O* CFLAGs are filtered, and not much of any specific -O option.

Code:

(/usr/portage/) grep -R filter-flags . | grep "\-O3" | wc -l
4
(/usr/portage/) grep -R filter-flags . | grep "\-Os" | wc -l
8
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Thu Sep 06, 2007 10:08 pm    Post subject: Reply with quote

nightmorph wrote:
Don't set the floating point math instructions; let the compiler decide what's appropriate. Forcing it to a specific one is begging for trouble. Search around the forums; iirc there's a good post explaining this by dirtyepic. Leave out -mfpmath.


I don't suppose you have any recommendations of better search terms than "dirtyepic mfpmath"?

I found a few posts saying not to use it because it was slower than x87, but those posts were 2+ years old (And I'm sure GCC must have been improved by then - Even with the context-switching overhead, SSE/3DNow! should be measurably faster than raw x87, if only because the x87 is a badly thought out piece of crap...!)

Also, since AMD64's *can't* use the x87 copper, and have to use SSE, I figured it should be okay since most of the (admittedly small) speed boost 64-bit mode gets seems to be from its FPU and extra registers...

The general consensus from the 2005-2006 postings seems to be let the compiler decide, which in my case means just let it compile it to x87 on 32-bit x86...

Hmm... Does anyone know of a good benchtest program for FPU math that I could try compiling with the different flags? I'm curious now... ;)
Back to top
View user's profile Send private message
omp
Retired Dev
Retired Dev


Joined: 10 Sep 2005
Posts: 1018
Location: Glendale, California

PostPosted: Thu Sep 06, 2007 10:55 pm    Post subject: Reply with quote

Cyker wrote:
nightmorph wrote:
Don't set the floating point math instructions; let the compiler decide what's appropriate. Forcing it to a specific one is begging for trouble. Search around the forums; iirc there's a good post explaining this by dirtyepic. Leave out -mfpmath.


I don't suppose you have any recommendations of better search terms than "dirtyepic mfpmath"?

Hrm, I found this post by him; not sure if it's the one nightmorph is talking about, but it's possible. :)
_________________
meow.
Back to top
View user's profile Send private message
Corona688
Veteran
Veteran


Joined: 10 Jan 2004
Posts: 1204

PostPosted: Fri Sep 07, 2007 12:50 am    Post subject: Reply with quote

Cyker wrote:
I found a few posts saying not to use it because it was slower than x87, but those posts were 2+ years old (And I'm sure GCC must have been improved by then - Even with the context-switching overhead, SSE/3DNow! should be measurably faster than raw x87, if only because the x87 is a badly thought out piece of crap...!)

Also, since AMD64's *can't* use the x87 copper, and have to use SSE, I figured it should be okay since most of the (admittedly small) speed boost 64-bit mode gets seems to be from its FPU and extra registers...
It can't? Better tell AMD :) The x87 unit is actually more accurate than SSE, it computes 80-bit floats. I'll also note that SSE is now the default choice for amd64 according to the gcc manpage, so there's little point in forcing sse. If I had to guess why, I'd say it's because floating point operations and MMX/XMM/SSE operations don't mix all that well, and gcc uses the XMM registers quite a lot in general-purpose amd64 code.
_________________
Petition for Better 64-bit ATI Drivers - Sign Here
http://www.petitiononline.com/atipet/petition.html
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Fri Sep 07, 2007 5:55 am    Post subject: Reply with quote

Cyker wrote:
The allure of smaller binaries is very strong for me...

You might find this discussion interesting: C Flags Central Pt 2 as we've been talking about -falign to get smaller binaries. I don't have any figures to share though.
Back to top
View user's profile Send private message
Corona688
Veteran
Veteran


Joined: 10 Jan 2004
Posts: 1204

PostPosted: Fri Sep 07, 2007 4:13 pm    Post subject: Reply with quote

steveL wrote:
Cyker wrote:
The allure of smaller binaries is very strong for me...

You might find this discussion interesting: C Flags Central Pt 2 as we've been talking about -falign to get smaller binaries. I don't have any figures to share though.
Alignment is there to make things in memory line up nicely along and inside the width of the data bus. The x86 -- unlike most processors -- can fetch things at arbitrary misalignments for nearly all instructions, but there is a performance cost. In some cases it might even need to fetch twice.

It's weirditudes like this which make x86 relatively simple to design a generic compiler for, but difficult to design a good compiler for...
_________________
Petition for Better 64-bit ATI Drivers - Sign Here
http://www.petitiononline.com/atipet/petition.html
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Fri Sep 07, 2007 6:45 pm    Post subject: Reply with quote

StifflerStealth wrote:
Quote:
CFLAGS="-Os -march=pentium4 -fweb -pipe -mmmx -msse2 -mfpmath=sse -masm=intel -fforce-addr -frename-registers -finline-functions -freorder-blocks"


I think he/she/it was trying to break the system. :P It worked too.

Except for -masm=intel and -fforce-addr (whose advantage is more than doubtful) these flags don't look that bad: There's nothing which wouldn't also set by -O3 except -pipe and -mfpmath=sse which is also not really dangerous.
Back to top
View user's profile Send private message
enderandrew
l33t
l33t


Joined: 25 Oct 2005
Posts: 731

PostPosted: Thu Sep 13, 2007 3:34 am    Post subject: Reply with quote

CFLAGS="-Os -march=pentium4 -fweb -pipe -mmmx -msse2 -mfpmath=sse -masm=intel -fforce-addr -frename-registers -finline-functions -freorder-blocks"

can be reworked to:

CFLAGS="-Os -march=pentium4 -fweb -pipe -fforce-addr -frename-registers -finline-functions -freorder-blocks"

Pretty safe and stable. The other flags shouldn't really be explicitly declared, but rather handled by march. Generally I run with:

CFLAGS="-O2 -march=athlon64 -fweb -pipe -fomit-frame-pointer -ftracer -ftree-vectorize"

I've compiled my whole box with -Os -O2 and -O3, and can't really declare any a winner for your entire system. Some apps are better optimized for size, and some run faster with heavier optimizations. I've been flagging certain apps for -O3 like media encoders and emulators for performance, and I'm going to start trying to target certain packages for -Os while leaving most packages at -O2.

I've messed around with a bunch of other flags such as -freorder-blocks -frename-registers, hell half the flags in the GCC manual. Oddly enough, I rarely run into serious breakage. Either one program won't compile and I take the flags out. I'm not one of those who insist any flags beyond the listed stable ones are guaranteed to break your box, in fact I've found most of what people declare to be inherently unsafe really isn't that dangerous. However, at the same time, I usually don't see a whole bunch of major improvements noticably with a laundry list of flags, and if anything, it slows compile time down.

If anything, I think most major improvements in performance come from linker optimizations.
_________________
Nihilism makes me smile.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum