Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP: Clean out your CFLAGS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Fri Jan 06, 2006 9:20 pm    Post subject: TIP: Clean out your CFLAGS Reply with quote

When people post their /etc/make.conf it's a common case that they use a grouped optimization flag like -O2 but have put in other optimization flags aswell even though they don't need to since the -O2 covers that flag aswell.

That's my main idea when I sat down and read through the GCC manual and made an index of the different -O levels of optimization and what they cover:
CFLAGS Optimization Lookup


_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.


Last edited by nlindblad on Fri Feb 03, 2006 11:01 pm; edited 4 times in total
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Fri Jan 06, 2006 10:06 pm    Post subject: Reply with quote

that's a kind of good job, thx

makes me wanna read gcc manual :)
Back to top
View user's profile Send private message
bladus
Apprentice
Apprentice


Joined: 27 Jul 2005
Posts: 233

PostPosted: Fri Jan 06, 2006 10:58 pm    Post subject: Reply with quote

good to know, thanks!
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Fri Jan 06, 2006 11:24 pm    Post subject: Reply with quote

http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Optimize-Options.html#Optimize-Options :wink:
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Azzazzazz
n00b
n00b


Joined: 10 Nov 2005
Posts: 14

PostPosted: Sat Jan 07, 2006 5:51 am    Post subject: Reply with quote

Thank you sir 8)
Back to top
View user's profile Send private message
slycordinator
Advocate
Advocate


Joined: 31 Jan 2004
Posts: 3059
Location: Korea

PostPosted: Sat Jan 07, 2006 8:43 am    Post subject: Reply with quote

One small thing with that...

There might be a good reason to leave redundant CFLAGS in.

Lets say one ebuild automatically strips CFLAGS and changes O3 to O2 (since O2 is "safer"). Lets then say that one of the options that O3 provides is perfectly safe. If you add it in redundantly, then you'll still get the effect of it after the ebuild does the change.

Food for thought.
Back to top
View user's profile Send private message
lucabotti
n00b
n00b


Joined: 01 Sep 2005
Posts: 8

PostPosted: Sat Jan 07, 2006 8:55 am    Post subject: I agreee, but Reply with quote

i agree that leaving the redundant CFLAGS enables them even if the ebuild disables the optimization level.
But It also slows don e compile times...
I saw this for the Os (which i think is the best one).
Back to top
View user's profile Send private message
slycordinator
Advocate
Advocate


Joined: 31 Jan 2004
Posts: 3059
Location: Korea

PostPosted: Sat Jan 07, 2006 9:37 am    Post subject: Re: I agreee, but Reply with quote

lucabotti wrote:
i agree that leaving the redundant CFLAGS enables them even if the ebuild disables the optimization level.
But It also slows don e compile times...
I saw this for the Os (which i think is the best one).


Well of course it would make for longer compile times on the programs that disable that optimization to re-enable part of it.
Back to top
View user's profile Send private message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Sat Jan 07, 2006 9:59 am    Post subject: Reply with quote

Think4UrS11 wrote:
http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Optimize-Options.html#Optimize-Options :wink:


I know, that was part of my reading, but I didn't think it was indexed enough.
_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Sat Jan 07, 2006 10:20 am    Post subject: Re: I agreee, but Reply with quote

lucabotti wrote:
i agree that leaving the redundant CFLAGS enables them even if the ebuild disables the optimization level.
But It also slows don e compile times...
I saw this for the Os (which i think is the best one).


Well I suggest yuo to utilize the 02 flags if you didn't have a processor that have a small L2 CACHE, please read this to understand it.

Bye Bye :D
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
frenkel
Veteran
Veteran


Joined: 13 May 2003
Posts: 1034
Location: .nl

PostPosted: Sat Jan 07, 2006 10:46 am    Post subject: Reply with quote

Great job on that document! :)

Does anybody know if the things like -mmmx, -msse and -m3dnow are set by the -march=athlon-xp flag?
I think it does, but I didn't understand that part of the gcc manual.
Back to top
View user's profile Send private message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Sat Jan 07, 2006 10:52 am    Post subject: Reply with quote

Frenkel wrote:
Does anybody know if the things like -mmmx, -msse and -m3dnow are set by the -march=athlon-xp flag?
I think it does, but I didn't understand that part of the gcc manual.


Good question, I guess it should since it's mentioned like this:

The GCC Manual wrote:
athlon-4, athlon-xp, athlon-mp
Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE instruction set support.

_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Sat Jan 07, 2006 10:53 am    Post subject: Reply with quote

Frenkel wrote:
Great job on that document! :)

Does anybody know if the things like -mmmx, -msse and -m3dnow are set by the -march=athlon-xp flag?
I think it does, but I didn't understand that part of the gcc manual.


Yes the flags are included wheb you specify the -march=athlon-xp :wink:
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
frenkel
Veteran
Veteran


Joined: 13 May 2003
Posts: 1034
Location: .nl

PostPosted: Sat Jan 07, 2006 10:59 am    Post subject: Reply with quote

Ok, that will clean up my CFLAGS even more :D, thanks!
Back to top
View user's profile Send private message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Sat Jan 07, 2006 12:41 pm    Post subject: Reply with quote

Frenkel wrote:
Ok, that will clean up my CFLAGS even more :D, thanks!


You gave me a new idea for doing:
CFLAGS -march Lookup
_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.
Back to top
View user's profile Send private message
frenkel
Veteran
Veteran


Joined: 13 May 2003
Posts: 1034
Location: .nl

PostPosted: Sat Jan 07, 2006 1:34 pm    Post subject: Reply with quote

nlindblad wrote:
Frenkel wrote:
Ok, that will clean up my CFLAGS even more :D, thanks!


You gave me a new idea for doing:
CFLAGS -march Lookup

:lol: Thanks again! :P
Back to top
View user's profile Send private message
yoyo
Bodhisattva
Bodhisattva


Joined: 04 Mar 2003
Posts: 4273
Location: Lyon - France

PostPosted: Mon Jan 09, 2006 9:35 am    Post subject: Re: I agreee, but Reply with quote

DranXXX wrote:
lucabotti wrote:
i agree that leaving the redundant CFLAGS enables them even if the ebuild disables the optimization level.
But It also slows don e compile times...
I saw this for the Os (which i think is the best one).

Well I suggest yuo to utilize the 02 flags if you didn't have a processor that have a small L2 CACHE, please read this to understand it.
Bye Bye :D
Well ... Hope this wasn't a troll but what is a "processor that have a small L2 CACHE" ??
Mine as "only" 256kb cache but may I use -Os or -O2 ??

Thanks
_________________
La connaissance s'accroît quand on la partage.
JCB
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Mon Jan 09, 2006 9:50 am    Post subject: Re: I agreee, but Reply with quote

yoyo wrote:
Well ... Hope this wasn't a troll but what is a "processor that have a small L2 CACHE" ??
Mine as "only" 256kb cache but may I use -Os or -O2 ??


Nope I wasn't a troll :wink:

Ok, the 256kb cache size is small, I have dual Athlon-mp processors that have the same cache size and I have to compile with the Os option to gain some performance on load and excecute the code, for processors that have 512 kb or upper cache size the improvementes isn't significant... I have tested that configuration with a test binary that make a fast fourier transform compiled with -O2 and -Os.

Byez :D
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
yoyo
Bodhisattva
Bodhisattva


Joined: 04 Mar 2003
Posts: 4273
Location: Lyon - France

PostPosted: Mon Jan 09, 2006 10:13 am    Post subject: Re: I agreee, but Reply with quote

DranXXX wrote:
Ok, the 256kb cache size is small, I have dual Athlon-mp processors that have the same cache size and I have to compile with the Os option to gain some performance on load and excecute the code, for processors that have 512 kb or upper cache size the improvementes isn't significant... I have tested that configuration with a test binary that make a fast fourier transform compiled with -O2 and -Os.
Thanks a lot for the quick and clear answer. 8)
_________________
La connaissance s'accroît quand on la partage.
JCB
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Mon Jan 09, 2006 10:18 am    Post subject: Reply with quote

hey no prob, I'm glad to help you :D
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
Surye
n00b
n00b


Joined: 19 Jun 2003
Posts: 29

PostPosted: Mon Jan 09, 2006 3:36 pm    Post subject: Re: TIP: Clean out your CFLAGS Reply with quote

nlindblad wrote:
2006-01-07 Today I wrote: CFLAGS -march Lookup


k8 implies SSE3? What if people have a pre-venice core AMD64 (I have venice, but I know that it was the first core with sse3).
Back to top
View user's profile Send private message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Mon Jan 09, 2006 3:52 pm    Post subject: Re: TIP: Clean out your CFLAGS Reply with quote

Surye wrote:
nlindblad wrote:
2006-01-07 Today I wrote: CFLAGS -march Lookup


k8 implies SSE3? What if people have a pre-venice core AMD64 (I have venice, but I know that it was the first core with sse3).


You're right, I need to seperate them...

EDIT
According to the GCC docs they still fall under the same group though:

GCC docs wrote:

k8, opteron, athlon64, athlon-fx
AMD K8 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)


EDIT2
Making a database over x86/x86_64 CPU-cores and their capabilities would be usefull for many users.
_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.
Back to top
View user's profile Send private message
Surye
n00b
n00b


Joined: 19 Jun 2003
Posts: 29

PostPosted: Mon Jan 09, 2006 4:44 pm    Post subject: Re: TIP: Clean out your CFLAGS Reply with quote

nlindblad wrote:

EDIT
According to the GCC docs they still fall under the same group though:

GCC docs wrote:

k8, opteron, athlon64, athlon-fx
AMD K8 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)



When I said that, I ment all the marchs. In fact, the piece you quoted leaves out sse3. ;P I think that people who know they have a core supporting it will have to add it, as it can never be implied (untill k9 :O) by march for an AMD chip.
Back to top
View user's profile Send private message
nlindblad
Guru
Guru


Joined: 30 Jun 2005
Posts: 476
Location: Lund, Sweden

PostPosted: Mon Jan 09, 2006 4:56 pm    Post subject: Re: TIP: Clean out your CFLAGS Reply with quote

Surye wrote:
nlindblad wrote:

EDIT
According to the GCC docs they still fall under the same group though:

GCC docs wrote:

k8, opteron, athlon64, athlon-fx
AMD K8 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)



When I said that, I ment all the marchs. In fact, the piece you quoted leaves out sse3. ;P I think that people who know they have a core supporting it will have to add it, as it can never be implied (untill k9 :O) by march for an AMD chip.


Right, I see.
_________________
Please provide detailed tracebacks and your emerge --info when posting compile errors.
Add [SOLVED] to the thread's topic if you feel that your question has been anwered or your problem is solved.
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Wed Jan 11, 2006 12:03 pm    Post subject: Reply with quote

THX for nice and clean explanation with CFLAGS
Regards
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
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