Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

CFLAGS Central (Part 2)

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
408 posts
  • Page 3 of 17
    • Jump to page:
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 17
  • Next
Author
Message
Drysh
Apprentice
Apprentice
User avatar
Posts: 203
Joined: Wed Apr 06, 2005 1:12 am
Location: São Paulo, Brazil

  • Quote

Post by Drysh » Sat Jul 02, 2005 6:28 pm

Has anyone tested these two:

-frename-registers
-funit-at-a-time

I'm using them without any problem, but I would like to know what you think. The full line is:

CFLAGS="-march=pentium4m -O3 -pipe -fomit-frame-pointer -fno-ident -msse2 -falign-functions=4 -frename-registers -funit-at-a-time -mfpmath=sse"
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Sat Jul 02, 2005 6:48 pm

Drysh wrote:Has anyone tested these two:

-frename-registers
-funit-at-a-time

I'm using them without any problem, but I would like to know what you think. The full line is:

CFLAGS="-march=pentium4m -O3 -pipe -fomit-frame-pointer -fno-ident -msse2 -falign-functions=4 -frename-registers -funit-at-a-time -mfpmath=sse"
-frename-registers is already implied by -O3, and -funit-at-a-time is already implied by -O2, hence also by -O3. -frename-registers is not a good idea - it increases compile time considerably (up to 30% more compile time, depending on the code being compiled) and it produces no measurable speedups on IA32 architectures since IA32 is very register-starved. In the past it was also the cause for a lot of bugs due to invalid code being produced, and it's being dropped from the -O set of overall flags in the 4.x GCC line, AFAIK. I'd turn it off explicitely if you insist on -O3, by adding -fno-rename-registers.
So in short drop those two flags, they're pointless.
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
Top
rovingtarget
n00b
n00b
Posts: 11
Joined: Sat Jul 02, 2005 4:53 pm

  • Quote

Post by rovingtarget » Sun Jul 03, 2005 5:15 am

Even though I use -O2, I keep -funit-at-a-time around simply because it's one of the best CFLAGS and it never hurts to use a flag that is implied by another flag. Ebuilds may filter out -O2 for other reasons yet leave -funit-at-a-time alone.
Top
Satori80
Tux's lil' helper
Tux's lil' helper
Posts: 137
Joined: Tue Feb 24, 2004 6:33 pm

  • Quote

Post by Satori80 » Sun Jul 03, 2005 7:21 pm

I could use a little advice here. From what I understand GCC reads the last similar option as overriding the any previous similar flags. So if one were to put “-mtune=athlon-xp -march=athlon-xp” the -march flag should be used unless the ebuild filters out the -march flag, in which case the -mtune flag should be used. Correct?

If this is the case, why when I rebuild glibc are the flags switched to “-march=athlon-xp -mtune=athlon-xp”? Does this tune for athlon-xp rather than build for athlon-xp?
Top
bambam_
n00b
n00b
Posts: 6
Joined: Sun Jul 03, 2005 5:06 pm

  • Quote

Post by bambam_ » Sun Jul 03, 2005 8:02 pm

Satori80 wrote:I could use a little advice here. From what I understand GCC reads the last similar option as overriding the any previous similar flags. So if one were to put “-mtune=athlon-xp -march=athlon-xp” the -march flag should be used unless the ebuild filters out the -march flag, in which case the -mtune flag should be used. Correct?

If this is the case, why when I rebuild glibc are the flags switched to “-march=athlon-xp -mtune=athlon-xp”? Does this tune for athlon-xp rather than build for athlon-xp?
The only flags I know of (asside from the obvious -fno-* flags) that disable previous flags are of the -O variety, for which the last -O flag specified takes effect.
Top
Satori80
Tux's lil' helper
Tux's lil' helper
Posts: 137
Joined: Tue Feb 24, 2004 6:33 pm

  • Quote

Post by Satori80 » Sun Jul 03, 2005 9:45 pm

Not so, because if you put -w (suppress warnings) before -Wall (print all warnings) you will see all warnings are printed. If it's the other way around the warning messages are suppressed. Each switch that conflicts with another switch in your CFLAGS should supersede the one before it. I don't know if -mtune conflicts with -march, but I guess -march is supposed to imply -mtune anyway so it's probably irrelevant where it comes in unless, as I suggested previously, the ebuild filters out the -march switch.

I was just curious if anyone knows for sure.
Top
bambam_
n00b
n00b
Posts: 6
Joined: Sun Jul 03, 2005 5:06 pm

  • Quote

Post by bambam_ » Sun Jul 03, 2005 9:50 pm

Satori80 wrote:Not so, because if you put -w (suppress warnings) before -Wall (print all warnings) you will see all warnings are printed.
Um, well I was refering to flags that actually affect the code generated.
Top
rafaelkafka
n00b
n00b
Posts: 28
Joined: Thu Feb 03, 2005 1:48 am

  • Quote

Post by rafaelkafka » Fri Jul 08, 2005 11:11 pm

I have a pentium 3. I am using this line:

CFLAGS="-march=pentium3 -O3 -fomit-frame-pointer -momit-leaf-frame-pointer -pipe -ffast-math -fno-ident -fforce-addr -falign-functions=4 -fprefetch-loop-arrays"

Are they good flags?

Thank you

Rafael Kafka
Top
codergeek42
Bodhisattva
Bodhisattva
Posts: 5142
Joined: Mon Apr 05, 2004 4:44 am
Location: Anaheim, CA (USA)
Contact:
Contact codergeek42
Website

  • Quote

Post by codergeek42 » Fri Jul 08, 2005 11:17 pm

rafaelkafka wrote:-O3
Use "-O2" or "-Os" instead, since -O3 usually makes code actually go slower on x86 (which is due to its lack of many available registers).
-momit-leaf-frame-pointer
That's implied by "-fomit-frame-pointer" if I recall correctly.
-ffast-math
That breaks things. Don't use it.
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Top
Bartlet
n00b
n00b
Posts: 29
Joined: Sat Jul 09, 2005 2:03 am

  • Quote

Post by Bartlet » Sat Jul 09, 2005 3:06 am

codergeek42 wrote:
rafaelkafka wrote:-O3
Use "-O2" or "-Os" instead, since -O3 usually makes code actually go slower on x86 (which is due to its lack of many available registers).
-frename-registers slows code compilation, not code exectution (which it can still theoretically improve, even on x86)
-momit-leaf-frame-pointer
That's implied by "-fomit-frame-pointer" if I recall correctly.
You recall incorrectly.
-ffast-math
That breaks things. Don't use it.
It helps more than it hurts, but its not worth the hassle because of the packages you need to disable it for... Something to put on the backburner until package-specific cflags becomes friendlier.
Top
nxsty
Veteran
Veteran
User avatar
Posts: 1556
Joined: Wed Jun 23, 2004 7:00 pm
Location: .se
Contact:
Contact nxsty
Website

  • Quote

Post by nxsty » Sat Jul 09, 2005 12:13 pm

Bartlet wrote:-frename-registers slows code compilation, not code exectution (which it can still theoretically improve, even on x86)
-O3 also includes -finline-functions which causes unnecessary bloat in binaries which might make them execute slower. So -O2 is generally a better choice than -O3. -O3 should only be used for cpu intensive stuff, not everything.
Bartlet wrote:You recall incorrectly.
It's true that -fomit-frame-pointer doesn't include -momit-leaf-frame-pointer. But they are useless togheter since -momit-leaf-frame-pointer overrides -fomit-frame-pointer. So you will get faster code by just using -fomit-frame-pointer.
Top
rafaelkafka
n00b
n00b
Posts: 28
Joined: Thu Feb 03, 2005 1:48 am

  • Quote

Post by rafaelkafka » Sat Jul 09, 2005 6:14 pm

codergeek42 wrote:
rafaelkafka wrote:-O3
Use "-O2" or "-Os" instead, since -O3 usually makes code actually go slower on x86 (which is due to its lack of many available registers).
-momit-leaf-frame-pointer
That's implied by "-fomit-frame-pointer" if I recall correctly.
-ffast-math
That breaks things. Don't use it.
Thank you very much!

Rafael Kafka
Top
augury
l33t
l33t
User avatar
Posts: 722
Joined: Sat May 22, 2004 8:25 pm
Location: philadelphia

  • Quote

Post by augury » Sun Jul 10, 2005 6:03 am

-falign-labels= -falign-loops= are the more wasteful/worthless of the 4. -mtune will generate jumps in the code causing more work and memory use and will not fix poor arch code. the processor will be polled for capabilities and one path will always be followed.
Top
M1Sports20
Apprentice
Apprentice
Posts: 194
Joined: Thu Mar 25, 2004 6:21 pm
Location: Chicago, IL
Contact:
Contact M1Sports20
Website

recompile with new gcc flags

  • Quote

Post by M1Sports20 » Thu Jul 14, 2005 8:59 am

I made a mistake and compiled with CFLAG = -march=i686
i would like to change it to -march=pentium4.
i did this but now how do i get it to take effect in the ebuilds.
im sorry i found the answer on the forums. guess i just didn't look hard enough the first time
answer: emerge -e system && emerge -e world

So I have another question now. It looks like emerge -e world will compile more ebuilds in than i currently have. Would this be true?
Top
brfsa
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 121
Joined: Mon Aug 01, 2005 1:52 pm
Location: Brazil
Contact:
Contact brfsa
Website

  • Quote

Post by brfsa » Mon Aug 01, 2005 3:05 pm

I compiled all my packages with this settings. everything went smooth... no problems...
Even open-office compiled(took more than 10 hours, how insane!)

My insane flags are: :twisted:
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -mtune=athlon-xp"
CFLAGS="${CFLAGS} -pipe"
CFLAGS="${CFLAGS} -O3"
CFLAGS="${CFLAGS} -fweb"
CFLAGS="${CFLAGS} -frename-registers"
CFLAGS="${CFLAGS} -fforce-addr"
CFLAGS="${CFLAGS} -momit-leaf-frame-pointer"
CFLAGS="${CFLAGS} -fomit-frame-pointer"
CFLAGS="${CFLAGS} -ftracer"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
I know that some of these flags are already included in -O3, but just wanna keep them there.

Cheers :D
Top
codergeek42
Bodhisattva
Bodhisattva
Posts: 5142
Joined: Mon Apr 05, 2004 4:44 am
Location: Anaheim, CA (USA)
Contact:
Contact codergeek42
Website

  • Quote

Post by codergeek42 » Mon Aug 01, 2005 4:18 pm

New P4-based system. CFLAGS is as follows:

Code: Select all

CFLAGS="-Os -march=pentium4 -fomit-frame-pointer -pipe -funit-at-a-time"
I've got -funit-at-a-time in there because I'm not sure whether or not it's implied by -Os and the GCC docs aren't exactly fun to read through. :P

I've found that, at least on my hardware, -Os instead of -O2 seems to create a more responsive and interactive environment. Perhaps it's all pyschological though. :?
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Top
wyv3rn
Apprentice
Apprentice
Posts: 154
Joined: Thu Aug 18, 2005 11:36 pm
Location: USA

  • Quote

Post by wyv3rn » Sun Aug 21, 2005 6:00 pm

It's true that -fomit-frame-pointer doesn't include -momit-leaf-frame-pointer. But they are useless togheter since -momit-leaf-frame-pointer overrides -fomit-frame-pointer. So you will get faster code by just using -fomit-frame-pointer.
+1. I don't add any flags until I search high and low for what they do any all their drawbacks (thus my global CFLAGS are rather plain). I thought it would be nice to include -momit-leaf-frame-pointer for the packages that filter out -fomit-frame-pointer. I discovered -momit-leaf-frame-pointer actually OVERRIDES -fomit-frame-pointer for whatever reason. This seems illogical, one would think it should be the other way around, but it is not.

Anyone know if there are any stability/runtime correctness drawbacks to -Qn? I haven't found any. Even though the gcc man page says this is the default, that is not true. I've compared executable sizes with and w/o and they are always smaller with -Qn set.
Top
xordan
Tux's lil' helper
Tux's lil' helper
Posts: 148
Joined: Mon Aug 30, 2004 4:33 pm

  • Quote

Post by xordan » Sun Aug 21, 2005 6:21 pm

Well I use:

CFLAGS="-march=athlon64 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

which seem quite sensible :) Is there anything I can add which will give a noticable performance increase, without making things very unstable? I've read through quite a lot, and I haven't seen anything which doesn't either break things or bloat code so there's performance decrease due to that. Is there any point in having anything more than this in my flags?
Top
nxsty
Veteran
Veteran
User avatar
Posts: 1556
Joined: Wed Jun 23, 2004 7:00 pm
Location: .se
Contact:
Contact nxsty
Website

  • Quote

Post by nxsty » Sun Aug 21, 2005 7:34 pm

xordan wrote:Well I use:

CFLAGS="-march=athlon64 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

which seem quite sensible :) Is there anything I can add which will give a noticable performance increase, without making things very unstable? I've read through quite a lot, and I haven't seen anything which doesn't either break things or bloat code so there's performance decrease due to that. Is there any point in having anything more than this in my flags?
you could add -fvisibility-inlines-hidden to your CXXFLAGS. It has good effect on c++ stuff like KDE, mozilla, Openoffice etc by reducing bloat.
Top
IvanZD
Apprentice
Apprentice
Posts: 166
Joined: Mon Jul 04, 2005 10:03 am

  • Quote

Post by IvanZD » Wed Aug 24, 2005 6:10 pm

Hi!

What flags do you recommend for building a rock stable server? Speed is least important thing; only maximum stability is goal. X86 system.

Thx!
http://www.meteoadriatic.net/
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Wed Aug 24, 2005 9:29 pm

IvanZD wrote:Hi!

What flags do you recommend for building a rock stable server? Speed is least important thing; only maximum stability is goal. X86 system.

Thx!
"x86" doesn't cut it, be a little more specific. But the CFLAGS and CXXFLAGS when aiming for stability over all are always:

Code: Select all

CFLAGS="-march=<yourarch> -mtune=<yourarch> -O2 -fomit-frame-pointer -pipe -fno-ident"
CXXFLAGS="${CFLAGS}"
where you replace <yourarch> by pentium4 if you have a Pentium 4, pentium3 if you have a P3, athlon-xp if you have an Athlon XP, etc etc. For example, for a Pentium 3 system they'd be

Code: Select all

CFLAGS="-march=pentium3 -mtune=pentium3 -O2 -fomit-frame-pointer -pipe -fno-ident"
CXXFLAGS="${CFLAGS}"
Don't add or change anything else - all other flags trade off stability.
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
Top
IvanZD
Apprentice
Apprentice
Posts: 166
Joined: Mon Jul 04, 2005 10:03 am

  • Quote

Post by IvanZD » Thu Aug 25, 2005 7:31 am

moocha wrote:

Code: Select all

CFLAGS="-march=<yourarch> -mtune=<yourarch> -O2 -fomit-frame-pointer -pipe -fno-ident"
CXXFLAGS="${CFLAGS}"
Don't add or change anything else - all other flags trade off stability.
Thx, that was I looking for, but that I am wondering is: will -O1 or even without -O flag give more stable system than -O2 flag? Or I will get only equally stable and slower system?
http://www.meteoadriatic.net/
Top
nxsty
Veteran
Veteran
User avatar
Posts: 1556
Joined: Wed Jun 23, 2004 7:00 pm
Location: .se
Contact:
Contact nxsty
Website

  • Quote

Post by nxsty » Thu Aug 25, 2005 8:37 am

IvanZD wrote:Thx, that was I looking for, but that I am wondering is: will -O1 or even without -O flag give more stable system than -O2 flag? Or I will get only equally stable and slower system?
No, -O2 is the stable choice and there is no reason going any lower except if you care about compile times.
Top
J0sep
n00b
n00b
Posts: 6
Joined: Fri Sep 02, 2005 4:26 am

  • Quote

Post by J0sep » Sat Sep 03, 2005 2:17 am

0k, 0k, 0k.... t00 much...

I've installed gentoo as an x86 in a athlon 64 and it is working after a lot of battle, now... i've got to the part after the
#emerge -e system

and #etc-update is also checked

What i would like to know, since (forgive me if i'm wrong!) no one has asked it, when can -march=athlon64 be applied to the CFLAGS 'cause when i was installing I couldn't use any other than -march=i686

After installing and the first reboot, gcc passed to 3.4.4 as gcc-config -l reported, so I applied those 2 commands above.

Now i would able to change the CFLAGS and maybe run a

#emerge -e system
#emerge -e system

maybe?
and what else?


First I want to thank u all in this community it feels like a real family here.
I could get it all done and well only by searching in the forums and reading as much manual and review as i could, and only registered to be part of this and ask this one :wink:
;(
Top
nxsty
Veteran
Veteran
User avatar
Posts: 1556
Joined: Wed Jun 23, 2004 7:00 pm
Location: .se
Contact:
Contact nxsty
Website

  • Quote

Post by nxsty » Sat Sep 03, 2005 8:15 am

If you have gcc 3.4 you can use -march=athlon64 already. If you want everything compiled with it just do an emerge -e world.
Top
Post Reply

408 posts
  • Page 3 of 17
    • Jump to page:
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 17
  • Next

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic