You are not logged in.
Hey guys,
I checked out our wiki about makepkg and Gentoo's wiki on safe CFlags.
In both places, I noticed comments like this (paraphrased):
* Most of these flags will cause absolutely no human-perceptible differences!
* This wiki is for 100% safe, tested stuff ONLY, don't post your (awesome) untested options!
Well, I think this very unofficial thread would be a nice place to share said flags. If you do anything special that seems to work, or totally borks crap, I'd like to see it.
Oh, and can anyone confirm this;
GCC 4.2 introduces a new -march option, -march=native, which automatically detects the features your CPU supports and sets the options appropriately. If you have an Intel or AMD CPU and are using >=sys-devel/gcc-4.2.0, using -march=native is recommended. Do NOT use -march=native if you use distcc on nodes with different architectures as this may produce unusable code.
-- Gentoo Wiki
Offline
-march=generic/native do work fine, I used it until gcc 4.3 that added march=core2
Anyway:
CARCH="i686"
CHOST="i686-pc-linux-gnu"
MAKEFLAGS="-j3"
CFLAGS="-march=core2 -mfpmath=sse -O2 -pipe -fomit-frame-pointer"
#CFLAGS="-march=core2 -mfpmath=sse -O3 -pipe -fomit-frame-pointer -funroll-loops"
CXXFLAGS="$CFLAGS"
## hardware ##
E6550
2gb ddr2
The quoted line is what I use on "special" occasions, like e.g. for firefox3
Explanation:
-march=core2 : speaks for itself
-mfpmath=sse : on i686 this is set to 387 by default. sse is faster if you got it
-O2 / -O3 : optimize level. -O3 is in most cases the same or slower than -O3. aka not worth it. But it do help on some code.
-pipe : gcc uses pipes while compiling. Shorter compile time, but may cause build errors on rare ocasions
-fomit-frame-pointer : This is set in O2/3 by default on systems where it do not hamper debugging. Afaik, it's not set on x86
-funroll-loops : Tries to predict the outcome of a loop and "unroll" it. Generaly a bad idea, but works nicly for some apps like ff3
Last edited by Mr.Elendig (2008-06-03 14:25:54)
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Core Duo 1.6GHz
2GB RAM
CFLAGS="-march=native -O2 -pipe"
#LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--enable-new-dtags -Wl,--sort-common -s"
MAKEFLAGS="-j3"
I used to have a slightly-less-than-sane setup when I was doing pentium-m as the arch, but I've lost that make.conf
Doesn't core2 already provide for -mfpmath-sse? Haven't looked at the updated GCC docs yet. I would also think native does a better job at combining sane optimisations. I recommend against pipe for < 256MB RAM, < 512MB is a little strict.
I need real, proper pen and paper for this.
Offline
pfft. time spent discussing cflags and compiling >>>> time gained by using said cflags
Offline
Depends on usage. On regular desktop systems, the optimization does not compensate the time required to optimize. Your desktop application is waiting on you most of the time. On a server system where optimizing your master MySQL server can increase performance by 20% compared to what your distro ships, the optimization is worth the compile time.
Some exceptions do exist though: some multimedia applications like ffmpeg can make extensive use of features in your CPU. Recompiling these programs can increase performance a lot due to usage of SSE and friends.
Offline
-march=generic/native do work fine, I used it until gcc 4.3 that added march=core2
Anyway:
CARCH="i686" CHOST="i686-pc-linux-gnu" MAKEFLAGS="-j3" CFLAGS="-march=core2 -mfpmath=sse -O2 -pipe -fomit-frame-pointer" #CFLAGS="-march=core2 -mfpmath=sse -O3 -pipe -fomit-frame-pointer -funroll-loops" CXXFLAGS="$CFLAGS" ## hardware ## E6550 2gb ddr2
The quoted line is what I use on "special" occasions, like e.g. for firefox3
Explanation:
-march=core2 : speaks for itself
-mfpmath=sse : on i686 this is set to 387 by default. sse is faster if you got it
-O2 / -O3 : optimize level. -O3 is in most cases the same or slower than -O3. aka not worth it. But it do help on some code.
-pipe : gcc uses pipes while compiling. Shorter compile time, but may cause build errors on rare ocasions
-fomit-frame-pointer : This is set in O2/3 by default on systems where it do not hamper debugging. Afaik, it's not set on x86
-funroll-loops : Tries to predict the outcome of a loop and "unroll" it. Generaly a bad idea, but works nicly for some apps like ff3
http://gentoo-wiki.com/Safe_Cflags
The flag -mfpmath=sse however is not enabled by -march but it usually makes binaries slower due to limitations in the glibc headers. So it's better to not use this flag, even if you have an SSE capable CPU. Also -mfpmath=sse,387 is experimental and unstable.
Last edited by Cimi (2008-06-04 15:59:02)
Offline
Depends on usage. On regular desktop systems, the optimization does not compensate the time required to optimize. Your desktop application is waiting on you most of the time. On a server system where optimizing your master MySQL server can increase performance by 20% compared to what your distro ships, the optimization is worth the compile time.
It depends when you need the time. Take the threads about decreasing boot time as an example. In that instance, you're spending time when you can spare it to save time when you can't: you're in a hurry to get your machine started. Even on a desktop system, if you can make it more responsive by speeding things up it might be worth spending some spare time.
On the other hand, I agree that tweaking CFlags usually isn't worth the hassle, since it doesn't really make enough difference to be noticeable. But in theory...
0 Ok, 0:1
Offline
I got a question. Everybody's ranting about how CFLAGS do/don't make a difference. Has anybody here run (or seen) actual benchmarks that support either view?
arch(3) adj amused because you think you understand something better than other people ;P
Offline
Heh, it's sort of a peace-of-mind thing. If there were benchmarks proving these had benefits, then there'd be more Gentoo (or x source-based distro) users bragging about their systems. But the fact is, they can't
I need real, proper pen and paper for this.
Offline
Not realy a benchmark, but:
[oh@Alice][~/test/a]%g++ test.cpp -o test
[oh@Alice][~/test/a]%time ./test
Sun Jun 1 23:46:43 CEST 2008
155117520
Sun Jun 1 23:46:48 CEST 2008
./test 5.23s user 0.01s system 98% cpu 5.341 total
[oh@Alice][~/test/a]%g++ -march=core2 -mfpmath=sse -O2 -pipe -fomit-frame-pointer test.cpp -o test2
[oh@Alice][~/test/a]%time ./test2
Sun Jun 1 23:48:30 CEST 2008
155117520
Sun Jun 1 23:48:34 CEST 2008
./test2 3.75s user 0.00s system 99% cpu 3.786 total
The source:
#include <iostream>
#include <cstdlib>
using namespace std;
const unsigned char SIZE = 15;
unsigned long long result;
void count(unsigned char i, unsigned char j)
{
if(!i && !j) {
++result;
return;
}
if(i) {
count(i - 1, j);
}
if(j) {
count(i, j - 1);
}
}
int main()
{
system("date");
result = 0;
count(SIZE, SIZE);
cout << result << endl;
system("date");
return 0;
}
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
I used Gentoo for a while. What I chiefly noticed was that, once you get past -march=i686, -march stuff doesn't make a big difference; and -O3 actually slows a system down noticably. -fomit-frame-pointer was basically the only thing that reliably made stuff faster, and it breaks debugging on x86.
Offline
Related to building firefox3: Has anyone built it yet (I changed the pkgbuild from rc1 to rc2, but build failed)
My coding blog (or an attempt at it)
Archer start page (or an attempt at it)
Offline
yes, I built it this morning...
I used the PKGBUILD of spookyet with some little modifications
http://aur.archlinux.org/packages.php?ID=15184
(thanks spookyet)
everything worked well, if it still fail tell us the error..
bye
Offline
Not realy a benchmark, but:
[oh@Alice][~/test/a]%g++ test.cpp -o test [oh@Alice][~/test/a]%time ./test Sun Jun 1 23:46:43 CEST 2008 155117520 Sun Jun 1 23:46:48 CEST 2008 ./test 5.23s user 0.01s system 98% cpu 5.341 total [oh@Alice][~/test/a]%g++ -march=core2 -mfpmath=sse -O2 -pipe -fomit-frame-pointer test.cpp -o test2 [oh@Alice][~/test/a]%time ./test2 Sun Jun 1 23:48:30 CEST 2008 155117520 Sun Jun 1 23:48:34 CEST 2008 ./test2 3.75s user 0.00s system 99% cpu 3.786 total
The source:
#include <iostream> #include <cstdlib> using namespace std; const unsigned char SIZE = 15; unsigned long long result; void count(unsigned char i, unsigned char j) { if(!i && !j) { ++result; return; } if(i) { count(i - 1, j); } if(j) { count(i, j - 1); } } int main() { system("date"); result = 0; count(SIZE, SIZE); cout << result << endl; system("date"); return 0; }
I take it this code isn't reliable for testing options aside from the obvious gains ?
Using -O3 instead of -O2 for this one sped it up by over 25% (from 4.0s to 2.7s), I'm betting this isn't the case with regular applications ?
Edit: After some testing it seems the speed gain is caused by -finline-functions specifically, which seems logical.
Last edited by GGLucas (2022-06-24 08:11:45)
Offline
yes, I built it this morning...
I used the PKGBUILD of spookyet with some little modifications
http://aur.archlinux.org/packages.php?ID=15184
(thanks spookyet)
everything worked well, if it still fail tell us the error..
bye
Currently trying with those files, thanks for the post
// As for the topic: I'm currently only using march=core2
I'm not really experienced with the flags, so I try to keep things on a level I can understand, or find myself in...
My coding blog (or an attempt at it)
Archer start page (or an attempt at it)
Offline
hi, I have modified my /etc/makepkg.conf as follow:
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
(I have a Genuine Intel(R) CPU T2300 @ 1.66GHz)
are they "automatically" used when I compile a program with "configure - make"/"PKGBUILD - makepkg" or do I have to do something manually?
(I checked the arch and gentoo wiki for CFLAG but I didn't find an answer)
thanks
Offline
yes they are automatically used when you use makepkg, not if you manually ./configure && make
Offline
what should I do in that case?
Offline
As a general rule you shoudn't do ./configure && make && make install at all. You should always use makepkg, to avoid the chance of messing up your system.
If you want to do it anyway, you can export the cflags before you run make.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
if you dont use makepkg you could put in your ~/.bashrc
export CFLAGS='-march=prescott -O2 -pipe -fomit-frame-pointer'
alias gcc='gcc $CFLAGS'
but not really any need to because makepkg should be used for making packages.
Offline
I was under the impression that if you created /etc/make.conf that would handle the non-makepkg compilations. Or am I horribly wrong?
Stop looking at my signature. It betrays your nature.
Offline
I created that wiki page xD... but it's not really much the same (well completly different now xD)
Proud Ex-Arch user.
Still an ArchLinux lover though.
Currently on Kubuntu 9.10
Offline
I was under the impression that if you created /etc/make.conf that would handle the non-makepkg compilations. Or am I horribly wrong?
Hmm. The point is, instead of using make install, use ABS and makepkg. That way, pacman is aware of all installed files and can manipulate, upgrade, install, remove, etc.
Otherwise, It's up to the user to manage and track all manually installed software...which can quickly become overwhelming to a human being.
Offline
Hmm. The point is, instead of using make install, use ABS and makepkg. That way, pacman is aware of all installed files and can manipulate, upgrade, install, remove, etc.
Otherwise, It's up to the user to manage and track all manually installed software...which can quickly become overwhelming to a human being.
I agree wholeheartedly. I just seem to remember the standard file that gcc sources to is /etc/make.conf. Or at least it is on Gentoo, FreeBSD, and a couple others. I didn't want to make a definitive statement since I've never used it on Arch, I've always used makepkg.
Stop looking at my signature. It betrays your nature.
Offline
Misfit138 wrote:Hmm. The point is, instead of using make install, use ABS and makepkg. That way, pacman is aware of all installed files and can manipulate, upgrade, install, remove, etc.
Otherwise, It's up to the user to manage and track all manually installed software...which can quickly become overwhelming to a human being.I agree wholeheartedly. I just seem to remember the standard file that gcc sources to is /etc/make.conf. Or at least it is on Gentoo, FreeBSD, and a couple others. I didn't want to make a definitive statement since I've never used it on Arch, I've always used makepkg.
Ah, I see your point now, sorry. I have heard conflicting information on this. A dev once told me that makepkg.conf is for makepkg only- not make. He recommended to export the environment variables from rc.conf. Someone else said make an alias for make in .bashrc, which passes the cflags, and I think I read in the wiki that make sources makepkg.conf. I hope a dev can set us all straight on this.
Here's the wiki page which states that makepkg.conf passes variables for make, gcc and makepkg: http://wiki.archlinux.org/index.php/Makepkg.conf
I don't know if it is true.
Offline