Sunday, March 26, 2006

Firefox and gcc Optimization Flag

As you might already know, to optimize Gentoo we have to set a couple of variables which impact Portage behaviour. Those variables are stored in /etc/make.conf. Some of the important variables are CFLAGS and CXXFLAGS, which define the optimization flags for the gcc and C++ compiler respectively. My CFLAGS and CXXFLAGS are defined as follow:
CFLAGS="-march=athlon-xp -pipe -O3"
CXXFLAGS="${CFLAGS}"

(quoted from Gentoo Linux x86 Handbook)
One of the options in CFLAGS is the -O flag (that is capital O, not zero), which specifies the gcc optimization class flag. Possible classes are s (for size-optimized), 0 (zero - for no optimizations), 1, 2 or 3 for more speed-optimization flags.

As you see, I use -O3 for more speed optimization and that works well with most applications on my Gentoo box.

However, when I use Firefox on this machine I noticed some strange behaviour such as the font size is not the same as what I configured in Preferences. No matter what size I specified in the "Minimum font size" setting, it always show as small font as possible. So I have to hit Ctrl + "+" several times in order to be able to read the content of the web.

Moreover, sometimes when I move back/forward between each page, the font size just randomly got decreased automatically, which is quite annoying.

I saw some people discuss about this problem in Gentoo Forums and they said it's Firefox 1.5.0 's bug. Some even suggest to downgrade to Firefox 1.0.7 but I don't think that's a good idea.

So I have been living with the font problem like for a month, then I got a new problem . My Firefox just doesn't like some web site, sometimes when I click on a link from Google, or try to read an email in my Gmail account, Firefox crashes! Fortunately I have installed Tab Mix Plus extension, which can restore the last session I was surfing before Firefox crashed -- but that's not the right solution for sure.

This time I'm pretty certain that the problem is related to the optimization flag because I have read it somewhere and it said more speed optimization = less stable software. So I edited the /etc/make.conf and put -O2 instead of -O3 and executed emerge -av mozilla-firefox before I went to bed last night...

This morning I came to check the results, emerge went fine and Firefox seems to be happy with my emails and other web sites. More than that, I noticed that the fonts displayed on the web are bigger, like it should be according to my settings in Preferences. Surprisingly, I have fixed both of my problems at the same time. Yeah! :D

Now I changed my CFLAGS option back to -O3 and have to remind myself to change it to -O2 before emerging Firefox. That's all :)

---------------------
edited: 17 Apr 2006

Here's some useful information about Mozilla DPI-related Font Size Issues on Unix

1 Comments:

At 12:03 PM, Anonymous Anonymous said...

i personally used -O2.
The available flags can be found in optimization options of `man gcc`

 

Post a Comment

<< Home