Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CFLAGS Central (Part 1)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3 ... , 35, 36, 37  Next  
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
moocha
Watchman
Watchman


Joined: 21 Oct 2003
Posts: 5722

PostPosted: Thu Mar 03, 2005 12:57 am    Post subject: Reply with quote

nightfrost wrote:
I think you definitely should remove -fPIC from your CFLAGS. Your basic idea, though, is very good I think- at least that's what I'm trying to do myself somehow :)


Your approach, while it works, has one significant drawback. It requires you to remember to switch the make.confs manually. Which means that you can't for example do an emerge -e world and get the same system back since the settings aren't persisted.
You could use a per-package CFLAGS system as outlined here: https://forums.gentoo.org/viewtopic-t-266454.html
_________________
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Back to top
View user's profile Send private message
moocha
Watchman
Watchman


Joined: 21 Oct 2003
Posts: 5722

PostPosted: Thu Mar 03, 2005 12:59 am    Post subject: Reply with quote

amon-ra wrote:
My amd64 laptop's make.conf. I enble bigger optimizations in programs such as xorg. What do you think about it?

Code:

CFLAGS="-O2 -march=k8 -fforce-addr -funit-at-a-time -fomit-frame-pointer -frename-registers -fprefetch-loop-arrays -fPIC"
#CFLAGS="-march=k8 -O3 -fforce-addr -funit-at-a-time -fomit-frame-pointer -frename-registers -fprefetch-loop-arrays -ftracer -funroll-loops -funswitch-loops -fpeel-loops -ffast-math -fPIC"
CHOST="x86_64-pc-linux-gnu"
#CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden -frepo"
CXXFLAGS="${CFLAGS}"
#LDFLAGS="-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s"


Don't use -fPIC in your CFLAGS. Horrible things will befall you. Use the pic USE flag instead.
Don't use -funroll-loops. The chances are it'll slow things down.
Get rid of -fpeel-loops, it's pointless. It only works in the second pass of a profile-guided optimization. You'd have to compile twice, with profiling enabled, and that's something you can only do manually since portage doesn't support something like that (yet).
_________________
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Back to top
View user's profile Send private message
nxsty
Veteran
Veteran


Joined: 23 Jun 2004
Posts: 1556
Location: .se

PostPosted: Thu Mar 03, 2005 10:19 am    Post subject: Reply with quote

elocal wrote:

Any benefit from -Os?

I am about to emerge -eD world with these::
CFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer -fweb -ftracer"
LDFLAGS="-Wl,-O1"
CXXFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer -fweb -ftracer"


64 bit binaries are about 10% larger than 32 bit binaries. With -Os they become almost equl in size and the speed loss is not that bad. I'm very happy with -Os.
Back to top
View user's profile Send private message
marekn123
n00b
n00b


Joined: 04 Mar 2005
Posts: 1

PostPosted: Fri Mar 04, 2005 11:26 am    Post subject: installation on IBM R50e ThinkPad Reply with quote

Hi,
could ouy advice me how should I set cflags for my notebook:
IBM R50e processor Intel M 1.5 GHz

thank's
Marek

This and the post below merged in. --Maedhros
Back to top
View user's profile Send private message
hw-tph
l33t
l33t


Joined: 08 Jan 2004
Posts: 768
Location: Uppsala, Sweden

PostPosted: Fri Mar 04, 2005 2:56 pm    Post subject: Reply with quote

If you're using gcc 3.3.x (which is the standard), use -march=pentium3, and possibly also -mfpmath=sse. If you use gcc 3.4.3 or newer, use -march=pentium-m.


Håkan
Back to top
View user's profile Send private message
nomind
Apprentice
Apprentice


Joined: 03 Feb 2005
Posts: 270

PostPosted: Thu Mar 10, 2005 3:44 am    Post subject: Reply with quote

My CFLAGS:

Code:
"-O3 -pipe -march=prescott -msse -msse2 -msse3 -m3dnow -mmmx -fforce-addr -fbranch-probabilities -ftracer -fprefetch-loop-arrays -fomit-frame-pointer"


For some reason, this doesn't work (xorg doesn't get past a blasted "[fonts.cache] illegal instruction" problem). However, I'm currently using the gcc-3.3.4 version that came with 2004.3 Universal, so I think that may be the problem. Hopefully 3.4.3 actually supports Prescott architecture, instead of just mentioning it in its man page :evil: .
Back to top
View user's profile Send private message
nxsty
Veteran
Veteran


Joined: 23 Jun 2004
Posts: 1556
Location: .se

PostPosted: Thu Mar 10, 2005 10:15 am    Post subject: Reply with quote

nomind wrote:
My CFLAGS:

Code:
"-O3 -pipe -march=prescott -msse -msse2 -msse3 -m3dnow -mmmx -fforce-addr -fbranch-probabilities -ftracer -fprefetch-loop-arrays -fomit-frame-pointer"


For some reason, this doesn't work (xorg doesn't get past a blasted "[fonts.cache] illegal instruction" problem). However, I'm currently using the gcc-3.3.4 version that came with 2004.3 Universal, so I think that may be the problem. Hopefully 3.4.3 actually supports Prescott architecture, instead of just mentioning it in its man page :evil: .


-m3dnow is your problem, no Intel CPU's supports 3dnow. You should drop all -msse*, -m3dnow and -mmmx flags anyway.
Back to top
View user's profile Send private message
nomind
Apprentice
Apprentice


Joined: 03 Feb 2005
Posts: 270

PostPosted: Fri Mar 11, 2005 12:16 am    Post subject: Reply with quote

Quote:
-m3dnow is your problem, no Intel CPU's supports 3dnow. You should drop all -msse*, -m3dnow and -mmmx flags anyway.


That sure burst my bubble! :oops:
Back to top
View user's profile Send private message
msa
n00b
n00b


Joined: 01 Oct 2004
Posts: 59
Location: Odense, Denmark

PostPosted: Mon Mar 14, 2005 5:03 pm    Post subject: For my Transmeta TM5800 Reply with quote

I have been trying a lot of different optimizing settings for my Transmeta CPU (ECS iBuddie A530), and I have found some settings, that should not be used for this one ...

I don't use LDFLAGS. Until now they have just made everything slower. And I have excluded -mmmx from the CFLAGS.

(If you are going to install Gentoo on this machine, set your USE flags to "-apm acpi mmx nptl")

This is the best configuration I have used for Gentoo.

EDIT: -mcpu=i686 seems to work just fine.


Last edited by msa on Wed Mar 16, 2005 7:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
charlieg
Advocate
Advocate


Joined: 30 Jul 2002
Posts: 2149
Location: Manchester UK

PostPosted: Mon Mar 14, 2005 6:18 pm    Post subject: Reply with quote

If anybody is feeling particluarly inclined, I just created a very simple CFLAGS matrix on gentoo-wiki.com and it could do with some more input other than my own (rather basic) experiences.
_________________
Want Free games?
Free Gamer - open source games list & commentary

Open source web-enabled rich UI platform: Vexi
Back to top
View user's profile Send private message
plaguethenet
n00b
n00b


Joined: 14 Mar 2005
Posts: 1

PostPosted: Mon Mar 14, 2005 8:21 pm    Post subject: Re: Here are mine Reply with quote

Scott Frappier wrote:
Code:

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O3 -mmmx -msse -mfpmath=sse -pipe -fomit-frame-pointer -funroll-loops -funroll-all-loops -fthread-jumps -fforce-addr -frerun-cse-after-loop -frerun-loop-opt -fexpensive-optimizations -falign-functions=4 -falign-jumps=4"
CXXFLAGS="-march=pentium3 -O3 -mmmx -msse -mfpmath=sse -pipe -fomit-frame-pointer -funroll-loops -funroll-all-loops -fthread-jumps -fforce-addr -frerun-cse-after-loop -frerun-loop-opt -fexpensive-optimizations -falign-functions=4 -falign-jumps=4"


Works great...haven't had a problem yet...using GCC 3.1 :)

Scott Frappier



I Have similar flags. Works great too...

CFLAGS="-O2 -march=pentium4 -mmmx -msse -mfpmath=sse -pipe -fomit-frame-pointer -fthread-jumps -fforce-addr -frerun-cse-after-loop -frerun-loop-opt -fexpensive-optimizations -falign-functions=4 -falign-jumps=4"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
Back to top
View user's profile Send private message
Xake
Guru
Guru


Joined: 11 Feb 2004
Posts: 588
Location: Göteborg, the rainy part of scandinavia

PostPosted: Tue Mar 15, 2005 11:09 am    Post subject: Reply with quote

@charlieg

You Matrix looks like it could be nice in the end if it will be given attention.
What could be nice to would be a field for witch ARCH some particular CFLAGS could be used on (and maybe makeing it a good guide for noobs having alot of CFLAGS without knowing why.

And just a general question:
Does -march=pentium3 include some things like -mmmx? If it does then why have defined also in the CFLAGS?
What would be nice in the CFLAGmatrix would be some of those -march/-mtune flags and in the description list what other flags those includes.
Back to top
View user's profile Send private message
nxsty
Veteran
Veteran


Joined: 23 Jun 2004
Posts: 1556
Location: .se

PostPosted: Tue Mar 15, 2005 2:03 pm    Post subject: Reply with quote

Xake wrote:
And just a general question:
Does -march=pentium3 include some things like -mmmx? If it does then why have defined also in the CFLAGS?
What would be nice in the CFLAGmatrix would be some of those -march/-mtune flags and in the description list what other flags those includes.


-march=pentium3 includes -mmmx, -msse and -mcpu/-mtune=pentium3 so there is no reason having them if you have -march. Just -mcpu/-mtune however doesn't include any extra flags.
Back to top
View user's profile Send private message
Xake
Guru
Guru


Joined: 11 Feb 2004
Posts: 588
Location: Göteborg, the rainy part of scandinavia

PostPosted: Tue Mar 15, 2005 2:26 pm    Post subject: Reply with quote

nxsty wrote:
Xake wrote:
And just a general question:
Does -march=pentium3 include some things like -mmmx? If it does then why have defined also in the CFLAGS?
What would be nice in the CFLAGmatrix would be some of those -march/-mtune flags and in the description list what other flags those includes.


-march=pentium3 includes -mmmx, -msse and -mcpu/-mtune=pentium3 so there is no reason having them if you have -march. Just -mcpu/-mtune however doesn't include any extra flags.


Then there is guys out there without a general clue what their CFLags really do and still temper with them? A lot of people have both defined. Are all -mflags arch-specefic? What I mean: if you set an -march/-mtune then you should leave the rest of the -mflags UNLESS if you are absolutly sure that your processor supports something you -march/-mtune does not specify (unicluded debugging or those sort of things like xorg-x11 compiled with the early gcc3.4 needed to disable sse to not chrash)?
Back to top
View user's profile Send private message
kimchi_sg
Advocate
Advocate


Joined: 26 Nov 2004
Posts: 2968

PostPosted: Tue Mar 15, 2005 2:30 pm    Post subject: Reply with quote

Xake wrote:
Then there is guys out there without a general clue what their CFLags really do and still temper with them? A lot of people have both defined.

That is in case a package filters out -O3 or some other flag from CFLAGS during compiling. With the redundancy, some of the optimisations can still be preserved, if only -O3 is stripped out.
Xake wrote:
Are all -mflags arch-specefic?

No.
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Tue Mar 15, 2005 3:37 pm    Post subject: Reply with quote

Xake wrote:
What could be nice to would be a field for witch ARCH some particular CFLAGS could be used on (and maybe makeing it a good guide for noobs having alot of CFLAGS without knowing why.

Uhm... If you don't specify CFLAGS in make.conf, you get the profile-provided sane defaults that'll be just fine for your system.
Back to top
View user's profile Send private message
Xake
Guru
Guru


Joined: 11 Feb 2004
Posts: 588
Location: Göteborg, the rainy part of scandinavia

PostPosted: Tue Mar 15, 2005 4:41 pm    Post subject: Reply with quote

ciaranm wrote:
Xake wrote:
What could be nice to would be a field for witch ARCH some particular CFLAGS could be used on (and maybe makeing it a good guide for noobs having alot of CFLAGS without knowing why.

Uhm... If you don't specify CFLAGS in make.conf, you get the profile-provided sane defaults that'll be just fine for your system.


Sorry to say, but a previous post in this thread about a person unable to compile things becouse of he had 3dnow in his CFLAGs for a intel-processor is not the first of its kind I have encountered.
And what I meant with the previous was people having CFLAGs someone said womewhere may improved their system performance. But they don have a single clue why and maybe what drawbacks it could have. I know, I once was something like them but encountered some problems and did reduce the CLFAGS to something I can control until I get time to learn what they do.
Everybody is a noob in one way sooner or later. And easy, proper information may very well reduce the amount of bugs on b.g.o and complains in the forums about stuff not working. What I mean: going through GCCs manual to learn CFLAGs is fun, indeed. Really. Fun. But if you do not have the time to read it deeply it does not give that much. And if you not are a very experienced programmer it sometimes does not even help to read it deeply.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Wed Mar 16, 2005 10:25 am    Post subject: Reply with quote

The acovea site had a ver nice , consice table of all flags and what they did , including a list of what was included by each of the Ox flag groups.

Sadly it looks like the site has been pulled (he probably got tired of being emailed by ricers!)

Anyone know of a copy of that site / page. It was an excellent reference.

8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
cast0r
Tux's lil' helper
Tux's lil' helper


Joined: 15 Dec 2004
Posts: 89

PostPosted: Sun Apr 03, 2005 5:47 pm    Post subject: Reply with quote

Hi,
I've read once that --fomit-frame-pointer should be only used with CFLAGS and not CXXFLAGS .
The author says, when using --fomit-frame-pointer the compiled C++ code unnecessarily grows and maybe faulty and cause segfaults (whatever it is ;) )
What do you think about that? Or maybe have you made such a experience too?
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Sun Apr 03, 2005 6:16 pm    Post subject: Reply with quote

can you post a reference to that info?

I always use that flag since it was recommended by Bob Moss in this thread a year back and I have never had any issues.

8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
cast0r
Tux's lil' helper
Tux's lil' helper


Joined: 15 Dec 2004
Posts: 89

PostPosted: Sun Apr 03, 2005 7:43 pm    Post subject: Reply with quote

I would have already posted a link to that info if it was in english. The article which Im talking about is in polish 8)
.....but please ::arrow: http://www.dobremiasto.net/~hoppke/too_much_to_learn/kompilat.html ;) The article was last updated in april 2004.

These are some of his words about -fomit-frame-pointer translated to english:
Quote:

[...]
-fomit-frame-pointer is unusable with C++ code. There is an ununderstandable reason for me why the target code compiled from C++ with this flag grows to mutch.[...] It may also cause a faulty code. A code which doesn't work properly or even causes segfaults.
That's why I suggest to not using this flag with a C++ code, at least untill it will be repaird in GCC (but this failure appears for long time now, so I don't think that something will change very soon).


If anybody has made his own experience which could negate or confirm what I've wrote , so please let me know.
[...]



The other thing this author is suggesting is to use -Os rather than -O2 :? He says that -Os works as -O2 with some little bonuses such as smaller target code. ;)


What do you think about these?
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Sun Apr 03, 2005 8:37 pm    Post subject: Reply with quote

Thanks, I guess what we need to know is who is saying this , is a dev , someone we should put some trust in?

Quote:
What do you think about these?

For the Os vs O2 just read the other 36 pages of this thread! It's a long way from being the same but in some _special_ cases can be better.

I'll stick with Rob Moss's advice , he's a Gentoo gcc dev.

8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
moocha
Watchman
Watchman


Joined: 21 Oct 2003
Posts: 5722

PostPosted: Sun Apr 03, 2005 9:19 pm    Post subject: Reply with quote

cast0r wrote:
Hi,
I've read once that --fomit-frame-pointer should be only used with CFLAGS and not CXXFLAGS .
The author says, when using --fomit-frame-pointer the compiled C++ code unnecessarily grows and maybe faulty and cause segfaults (whatever it is ;) )
What do you think about that? Or maybe have you made such a experience too?
That's not hard fact from that person, that's the usual half-informed pseudo-scientific opinion.
-fomit-frame-pointer causes code to grow larger, for both C and C++, that's true. The reason is that disabling the frame pointer frees an additional register for use in functions (in some cases even two registers, if you also use -momit-leaf-frame-pointer - note though that -momit-leaf-frame-pointer doesn't work for PPC architectures!). And additional registers usually means the compiler can rearrange code to be faster, but usually at the cost of more instructions. It's a trade-off, as always. But the generated code will be faster on IA32 architectures (32-bit Intel and AMD processors) than code with frame pointers, even taking into account the slightly larger cache space it takes up. It's a true optimization, not some debatable thing like -funroll-loops that in most cases slows things down due to extreme cache trashing.
The reason the code increase due to -fomit-frame-pointer is bigger in C++ than in C is the use of template classes and functions. If there are a lot of those and the compiler decides to inline them, the increase will be somewhat surprising for someone who doesn't know the way the compiler handles templates. However, I have *yet* to see a case where -fomit-frame-pointer ended up being a counter-optimization, reducing the general performance.
As far as bugs are concerned - as far as I know the last time -fomit-frame-pointer exposed compiler bugs was around GCC 2.96 (Red Hat's pseudo-version ;-)). I've seen no current documented bugs involving -fomit-frame-pointer. The next time someone tells you a compiler flag is buggy, ask them to provide evidence.
This flag is safe and recommended for use.
_________________
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Sun Apr 03, 2005 9:26 pm    Post subject: Reply with quote

Quote:
The next time someone tells you a compiler flag is buggy, ask them to provide evidence.
I did :wink:

Thanks for the low down Moocha, and for dispelling the rumour. 8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Sun Apr 03, 2005 9:58 pm    Post subject: Reply with quote

moocha wrote:
-fomit-frame-pointer causes code to grow larger, for both C and C++, that's true. The reason is that disabling the frame pointer frees an additional register for use in functions (in some cases even two registers, if you also use -momit-leaf-frame-pointer. ...) And additional registers usually means the compiler can rearrange code to be faster, but usually at the cost of more instructions. It's a trade-off, as always. But the generated code will be faster on IA32 architectures (32-bit Intel and AMD processors) than code with frame pointers, even taking into account the slightly larger cache space it takes up. It's a true optimization, not some debatable thing like -funroll-loops that in most cases slows things down due to extreme cache trashing.

i enjoyed reading that part of your post so much that i just could not resist the temptation to quote it. that's exactly the rationale behind the use of -fomit-frame-pointer and -momit-leaf-frame-pointer on my x86 systems.
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page Previous  1, 2, 3 ... , 35, 36, 37  Next
Page 36 of 37

 
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