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 10 of 17
    • Jump to page:
  • Previous
  • 1
  • …
  • 8
  • 9
  • 10
  • 11
  • 12
  • …
  • 17
  • Next
Author
Message
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 May 27, 2006 9:00 am

_loki_ wrote:I just upgraded to gcc-4.1.1 which is now ~x86 in portage and stumbled over the LDFLAGS I setted before. After some research I got it working, but still I just don't really know what I'M doing here, so if anyone does I'd appreciate his recommodation regarding LDFLAGS and CFLAGS for my system. I have a 1,8 GHz Pentium 4M Laptop

I'll you whatever you also need to know if you ask! Thanks in advance!!!
Try with:
CFLAGS="-march=pentium4 -O2 -fomit-frame-pointer -pipe"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1"
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 May 27, 2006 9:07 am

Ray ishido wrote:hi,

quite a newb question (sorry, I am leraning ;) ): if I change some CFLAG, I will need to do an emerge -e --deep system and a emerge -e --deep world.
so, will EVERYTHING on my system will be compile, ie, will it be the same thing as if I had set those flag during a stage 1 install?

I am also thinking to use the same flags as Vipenicus:

Code: Select all

CHOST="i686-pc-linux-gnu"
#
CFLAGS="-march=pentium4 -mtune=pentium4 -msse -msse2"
CFLAGS="${CFLAGS} -pipe"
CFLAGS="${CFLAGS} -Os"
CFLAGS="${CFLAGS} -fomit-frame-pointer"
CFLAGS="${CFLAGS} -fstack-protector-all"
CFLAGS="${CFLAGS} -fno-ident"
CFLAGS="${CFLAGS} -fforce-addr"
CFLAGS="${CFLAGS} -ftracer"
CFLAGS="${CFLAGS} -fweb
CFLAGS="${CFLAGS} -falign-functions=4"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
#
LDFLAGS="-Wl,-O1 -Wl,--sort-common" 
is it safe with gcc 4.1.1?

thanks
Remember that -fstack-protector-all will reduce your performance. -ftracer is also mostly pointless and usually only makes code slightly slower and larger. If I where you I'd use -march=pentium4 -O2/-Os -fomit-frame-pointer -pipe. It might save you some problems and you wouldn't notice any difference what so ever (except if you're comparing to a system compiled with -fstack-protector-all which probably would be a bit slower).
Top
Ray ishido
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 141
Joined: Tue Jan 17, 2006 12:30 pm
Location: Piracicaba (Brazil)

  • Quote

Post by Ray ishido » Sat May 27, 2006 4:01 pm

nxsty, Thank you for your answer. I will follow your advise.
Do you think it's ok for the LDFLAG?

[Edit]: sorry, I hadn't read your answer to _loki_. I will use LDFLAGS="-Wl,-O1"
Last edited by Ray ishido on Tue May 30, 2006 1:06 pm, edited 1 time in total.
Top
Marel
n00b
n00b
Posts: 17
Joined: Sat Apr 29, 2006 11:28 pm
Location: Serbia

  • Quote

Post by Marel » Sun May 28, 2006 4:00 pm

Maybe we should learn from this: :wink:

http://getswiftfox.com/rel-athlon-xp.htm

One can see all parameters used for compilation, and I can tell you that I compared its speed with Gentoo emerged version and that it was 22.5% faster 8O If you don't believe this, check it yourself.

EDIT: I measured loading time of mysql 4.0.23a manual.
EDIT2: this link is athlon-xp version if you have another CPU, there are other versions for download.
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 May 28, 2006 6:19 pm

Marel wrote:Maybe we should learn from this: :wink:

http://getswiftfox.com/rel-athlon-xp.htm

One can see all parameters used for compilation, and I can tell you that I compared its speed with Gentoo emerged version and that it was 22.5% faster 8O If you don't believe this, check it yourself.

EDIT: I measured loading time of mysql 4.0.23a manual.
EDIT2: this link is athlon-xp version if you have another CPU, there are other versions for download.
What benchmarks did you run to find out it was 22,5% faster? It's not really comparable btw if you don't use the exact same mozconfig settings. For example gentoo enables cairo support by default and that build you linked to don't it seems.
Top
Marel
n00b
n00b
Posts: 17
Joined: Sat Apr 29, 2006 11:28 pm
Location: Serbia

  • Quote

Post by Marel » Mon May 29, 2006 1:39 pm

nxsty wrote:What benchmarks did you run to find out it was 22,5% faster? It's not really comparable btw if you don't use the exact same mozconfig settings. For example gentoo enables cairo support by default and that build you linked to don't it seems.
As I sad, I measured loading time of mysql 4.0.23a manual. It was 7.1s vs 8.8s or something.
Top
Skrot
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 141
Joined: Mon Oct 06, 2003 9:48 am
Location: Adelaide, Australia

  • Quote

Post by Skrot » Sat Jun 10, 2006 12:46 am

I was looking through the GCC manual for other optimisation options which might affect 3D rendering performance, and came across the -mfpmath=sse option. From reading the manual, this option sounds purely like a good one.
The resulting code should be considerably faster in the majority of cases and
avoid the numerical instability problems of 387 code, but may break some existing
code that expects temporaries to be 80bit.
But I've only seen people saying that it nearly always makes code slower. Why such a big discrepency between the GCC manual and what people seem to be saying? The "avoid the numerical instability problems of 387 code" sounds good just on its own. Not that I know what the problem with 387 code is, however.

Edit: I should probably say that I'm using an Athlon XP 2800+.
You will release your mind.
Top
yngwin
Retired Dev
Retired Dev
User avatar
Posts: 4572
Joined: Thu Dec 19, 2002 1:22 pm
Location: Suzhou, China

  • Quote

Post by yngwin » Sat Jun 10, 2006 8:10 am

The -mfpmath options don't seem to work as they should. I've only ever seen the recommendation not to use them.
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Sat Jun 10, 2006 6:05 pm

Using both sse and 387 is broken, at least.
In theory sse fpmath is quite nice, but I think I've read somewhere that in practice it depends on your cpu. In any event one should let the compiler decide, unless you know the compiler is wrong.
Top
weaksauce
Apprentice
Apprentice
User avatar
Posts: 204
Joined: Thu Nov 17, 2005 2:31 am
Location: NYC

  • Quote

Post by weaksauce » Sat Jun 10, 2006 7:02 pm

so, nxsty, I noticed you have an amd64 system, so what LDFLAGS would you suggest for that? (running the system in 64-bits)

EDIT: I use KDE too, if that matters
Top
TheCoop
Veteran
Veteran
User avatar
Posts: 1814
Joined: Sat Jun 15, 2002 5:20 pm
Location: Where you least expect it
Contact:
Contact TheCoop
Website

  • Quote

Post by TheCoop » Tue Jun 20, 2006 6:14 pm

does anyone know the status of -fvisibility=hidden and -fvisibility-inlines-hidden?
95% of all computer errors occur between chair and keyboard (TM)

"One World, One web, One program" - Microsoft Promo ad.
"Ein Volk, Ein Reich, Ein Führer" - Adolf Hitler

Change the world - move a rock
Top
enderandrew
l33t
l33t
User avatar
Posts: 731
Joined: Tue Oct 25, 2005 8:37 am

  • Quote

Post by enderandrew » Thu Jun 22, 2006 11:15 am

Ray ishido wrote: I am also thinking to use the same flags as Vipenicus:

Code: Select all

CHOST="i686-pc-linux-gnu"
#
CFLAGS="-march=pentium4 -mtune=pentium4 -msse -msse2"
CFLAGS="${CFLAGS} -pipe"
CFLAGS="${CFLAGS} -Os"
CFLAGS="${CFLAGS} -fomit-frame-pointer"
CFLAGS="${CFLAGS} -fstack-protector-all"
CFLAGS="${CFLAGS} -fno-ident"
CFLAGS="${CFLAGS} -fforce-addr"
CFLAGS="${CFLAGS} -ftracer"
CFLAGS="${CFLAGS} -fweb
CFLAGS="${CFLAGS} -falign-functions=4"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
#
LDFLAGS="-Wl,-O1 -Wl,--sort-common" 
is it safe with gcc 4.1.1?

thanks
The GCC 4.1.1 manual doesn't even seem to list an option for -fno-ident anymore, and that flag may have been dropped.

Personally, I've experimented with various CFLAGS, and I'm dropping -ftracer. I've found that most flags increase compile time and don't really help performance. I have seem some dynamic improvements from various LDFLAGS and that is where I'm experimenting more these days.

With all that being said, a CFLAG has caught my eye. Does anyone have any experience playing with the following:
-freorder-blocks-and-partition
In addition to reordering basic blocks in the compiled function, in order to reduce number of taken branches, partitions hot and cold basic blocks into separate sections of the assembly and .o files, to improve paging and cache locality performance.

This optimization is automatically turned off in the presence of exception handling, for linkonce sections, for functions with a user-defined section attribute and on any architecture that does not support named sections.
Nihilism makes me smile.
Top
bur
Apprentice
Apprentice
Posts: 229
Joined: Fri Feb 20, 2004 10:17 pm

  • Quote

Post by bur » Thu Jun 22, 2006 11:42 am

It's been quite a while since I did a full update of my system, so I was wondering if there are any news on the cflags-front... :D

I have a Duron Morgan, which is identical to an Athlon XP when it comes to compiling.

CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -pipe"
LDFLAGS="-Wl,-O1"

Is there anything I could/should change to get better performance or stability?


Also I wonder if someone already did a run with Acovea for an Athlon XP and can say what cflags it suggests as being fastest.
Top
enderandrew
l33t
l33t
User avatar
Posts: 731
Joined: Tue Oct 25, 2005 8:37 am

  • Quote

Post by enderandrew » Thu Jun 22, 2006 12:51 pm

bur wrote:It's been quite a while since I did a full update of my system, so I was wondering if there are any news on the cflags-front... :D

I have a Duron Morgan, which is identical to an Athlon XP when it comes to compiling.

CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -pipe"
LDFLAGS="-Wl,-O1"

Is there anything I could/should change to get better performance or stability?


Also I wonder if someone already did a run with Acovea for an Athlon XP and can say what cflags it suggests as being fastest.
I'm doing a new install right now on an athlon-xp laptop and intentionally trying to break my system to see which LDFLAGS and CFLAGS break which packages. And while I normally completely trust nxsty's opinion, I think I might give profiles a try.

It does seem to be perfectly suited from Gentoo, at least from what the GCC manuals reads to me.
-fprofile-generate
Enable options usually used for instrumenting application to produce profile useful for later recompilation with profile feedback based optimization. You must use -fprofile-generate both when compiling and when linking your program.

The following options are enabled: -fprofile-arcs, -fprofile-values, -fvpt.
Obviously, we use our computers, and we recompile when new versions come out. Why not generate profiles so that the next compile will be automatically more optimized? Is there a reason not to use this that I'm not aware of?

Code: Select all

CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer -ftracer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS} -ffriend-injection"
CXXFLAGS="${CXXFLAGS} -fvisibility-inlines-hidden"
#LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-Bdirect"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-Bdirect -Wl,-hashvals -Wl,-zdynsort"
Again, as you can see, I'm purposely trying to see what LDFLAGS especially break what packages. If only a few packages break with certain flags, then I will filter then with a packages.ldflags file and a bashrc script. If tons break because of a certain flag, then I'll remove it. But individually, people seem quite happy with --sort-common, --as-needed, -Bdirect, -hashvals and -zdynsort. Why not be stupid and try them all?
Nihilism makes me smile.
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Thu Jun 22, 2006 1:37 pm

enderandrew wrote: The GCC 4.1.1 manual doesn't even seem to list an option for -fno-ident anymore, and that flag may have been dropped.]
-fno-ident is in the code generation section of the manual, as it's not exactly an optimisation, it just removes/inhibits the adding of the .ident section of the binary (if I've understood it correctly, that is)..
Top
enderandrew
l33t
l33t
User avatar
Posts: 731
Joined: Tue Oct 25, 2005 8:37 am

  • Quote

Post by enderandrew » Thu Jun 22, 2006 1:46 pm

So, is that practical for everyday use? Is there good reason to use or not use that flag in make.conf?
Nihilism makes me smile.
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Thu Jun 22, 2006 2:47 pm

AFAIK the .ident section has no practical use, thus disabling it shouldn't do any harm, neither will it alter compile times. It will, however, save you a miniscule amount of bytes.
Top
bur
Apprentice
Apprentice
Posts: 229
Joined: Fri Feb 20, 2004 10:17 pm

  • Quote

Post by bur » Thu Jun 29, 2006 3:22 am

While reading about the different features of GCC I noticed that it seems to be unclear whether -O2 implies -fomit-frame-pointer or not.

The man pages for gcc say: "-O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging." So that'd mean to be sure frame pointer get omitted you need to explicitly state it (at least if on your arch it interferes with debugging, does this apply for x86?).

But man gcc also say: "-O2 turns on all optimization flags specified by -O." Does that mean when using -O2 -fomit-frame-pointer is used no matter what or is the condition from -O still active?

Okay, it's not that important, as adding -fomit-frame-pointer to your CFLAGS isn't much work, but I'd still like to know.
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Thu Jun 29, 2006 3:29 am

I think I've read somewhere that -O2 doesn't include fomit-frame-pointer on x86.
Top
bur
Apprentice
Apprentice
Posts: 229
Joined: Fri Feb 20, 2004 10:17 pm

  • Quote

Post by bur » Thu Jun 29, 2006 4:11 am

lnxz,
maybe then x86 is one of the architectures where debugging gets impossible with -ffp and thus it isn't included in -O/2/3.
Top
yngwin
Retired Dev
Retired Dev
User avatar
Posts: 4572
Joined: Thu Dec 19, 2002 1:22 pm
Location: Suzhou, China

  • Quote

Post by yngwin » Sat Jul 01, 2006 4:10 pm

That is indeed the case.
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Top
VinzC
Watchman
Watchman
User avatar
Posts: 5100
Joined: Sat Apr 17, 2004 1:51 pm
Location: Dark side of the mood

AuthenticAMD, cpu family=15, model=47

  • Quote

Post by VinzC » Sun Jul 02, 2006 12:08 pm

Hi.

I have an AMD64 - model name AMD Athlon(tm) 64 Processor 3200+ - and I wondered what CFLAGS were best for it. I didn't find anything relevant on Safe Flags - Gentoo Wiki and /etc/make.conf currently lists

Code: Select all

CFLAGS="-march=k8 -O3 -fomit-frame-pointer -pipe"
CHOST="x86_64-pc-linux-gnu"
I think the "-march=k8" came with the LiveCD I used and I left it as is. So I wondered if K8 is for Athlon what i386 is for Intel, i.e. generic. I "feel" my machine is not as fast as it could be though. So is there a CFLAGS I can use, say -march=athlon64? Or should I stay with -march=k8?

For your info:

Code: Select all

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 47
model name      : AMD Athlon(tm) 64 Processor 3200+
stepping        : 0
cpu MHz         : 2000.143
cache size      : 512 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni lahf_lm
bogomips        : 4009.64
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
EDIT: Consider I'm about to switch to -O2. But my question still remains.
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Sun Jul 02, 2006 12:49 pm

k8 seems to be usable with any k8 core based cpu, so it might be a little generic, so perhaps athlon64 would be more appropriate in your case.
Top
VinzC
Watchman
Watchman
User avatar
Posts: 5100
Joined: Sat Apr 17, 2004 1:51 pm
Location: Dark side of the mood

  • Quote

Post by VinzC » Sun Jul 02, 2006 1:41 pm

Thanks a lot lnxz. Going for emerge -ave world ;-)...
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Top
lnxz
Guru
Guru
Posts: 472
Joined: Sun Jul 03, 2005 4:53 am
Location: Earth

  • Quote

Post by lnxz » Sun Jul 02, 2006 2:23 pm

Imho it's not really worth doing a complete rebuild.
You should at least investigate the differences between athlon64 and opteron/athlonFX (or whatever other k8 based cpus are out there) to see if the athlon64 flag really enables any cool features that k8 doesn't.
Top
Post Reply

408 posts
  • Page 10 of 17
    • Jump to page:
  • Previous
  • 1
  • …
  • 8
  • 9
  • 10
  • 11
  • 12
  • …
  • 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