My previous difficulties with compiling Firefox 3 were because of the -ffast-math CFLAG, which was causing xulrunner to go nutty. Strange add-on messages, faulty form boxes and corrupted images, if you want to know how the patient presented himself.
I rebuilt firefox and xulrunner separately several times, with and without -ffast-math, with and without -O3, and with and without -Os, just for experimentation purposes. -ffast-math caused xulrunner to misbehave every time, regardless of the optimization level.
firefox itself was fine no matter what flags I used. And other ancillary packages seem to behave normally too. As far as -Os making programs load faster or run quicker, I don’t notice anything substantially different over -O2. Since it’s slightly more convenient not to have to switch flags for one package, I might stick with -Os -pipe -fomit-frame-pointer, and call it as good as it gets.
I find, in general, compiling Firefox with one set of flags ends up performing worse than the binary they release.
That’s because they compile it twice. First they make a profiling build, run that for a while (click some buttons, browse a bit, run benchmarks, etc.) and then use the collected data to optimize the second build.
It’s called Profile Guided Optimization (PGO).
http://developer.mozilla.org/en/docs/Building_with_Profile-Guided_Optimization