Compiling Firefox on Ubuntu Feisty
I built Minefield (Firefox trunk) for Windows a couple of weeks before classes started. It was fairly uneventful: I already had Visual Studio 2005 installed and functioning, so it was pretty much as simple as following the Build Documentation, more specifically Windows Build Prerequisites. I remember I had a couple of simple-to-fix problems, but since it was a few weeks ago and I didn’t document them, I decided to try building again: this time for Ubuntu. After three weeks, I’d basically forgotten the steps, so it was time to consult the docs.
Step 0: Install prerequisites
I already have a lot of development libraries installed in ubuntu, and I’m not sure how vastly my setup differs from the base Feisty (Ubuntu 7.04) installation. Here’s what I did have to install based on the list of Linux build prerequisites:
sudo apt-get install cvs
All I had to install was cvs, everything else I already had. One odd thing I did notice is the Linux build prerequisites states pkgconfig 0.9.0 or higher is required. On my system I have pkg-config 0.2.2 (note the hyphen) which is apparently the “latest version” of pkg-config. Perhaps there was some history with that project I’m not aware of, but this line on the MDC wiki is misleading at best and outdated at worst. (Of course, I’d edit the wiki if I knew for sure what I was talking about!)
Step 1: Download source
$ mkdir mozilla-dev $ cd mozilla-dev/ $ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk cvs checkout: CVS password file /home/jb/.cvspass does not exist - creating a new file U mozilla/client.mk
Right, so that’s only one makefile. I remember from last time thinking it was odd that Mozilla uses a makefile to download source from CVS.
Step 1a: Download source (really)
$ cd mozilla $ time make -f client.mk checkout MOZ_CO_PROJECT=browser ... real 3m49.976s user 0m9.417s sys 0m24.974s
While this goes, I read this: “Before pulling a tree, you should always check the appropriate Tinderbox to make sure that the codebase is not broken.”. Checking Tinderbox shows all trees are green as of 19:13:39 (PST), so I’m good to go.
Step 2: Editing .mozconfig
From the information on Configuring Build Options, I made my .mozconfig file:
. $topsrcdir/browser/config/mozconfig mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@ ac_add_options --disable-optimize ac_add_options --enable-debug mk_add_options MOZ_MAKE_FLAGS=-j3
The first line just includes the default firefox mozconfig. The second line enables the objdir, which separates the compiled binaries from the source – a good thing. Third and fourth lines are there so I can debug Firefox. And the last line I added to take advantage of my dual core processor by compiling in parallel (whether 2, 3, or 4 is the best number of parallel compiles is up for argument: I’ve heard CPUs*1.5, but I don’t know whether to believe that).
Step 3: Compiling!
Following Build and Install, I turned off the CPU frequency scaling on my laptop, killed all my programs, and started compiling firefox:
$ time make -f client.mk build ..
CPU time fluctuated a little with one core doing all of the work for brief periods of time, and brief periods of flatline (presumably for the individual “install” processes – copying files and not compiling), but it stayed fairly constant throughout (screenshot).
Error 1: nsIMenuBar.h: No such file or directory
Woops! First error compiling. Note to self for next time: should have used tee to easier log errors.
... /home/jb/mozilla-dev/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp:77:24: error: nsIMenuBar.h: No such file or directory ...
No good. I asked #firefox and there was no-one around who could help me. Reaching at straws, I decided to do two things at once – a terrible practice in any scientific experiment, but I’m impatient: I rechecked out the source code, and I added ‘cairo-gtk2′ as the default windowing toolkit to .mozconfig:
ac_add_options --enable-default-toolkit=cairo-gtk2
Went to sleep and let it compile. Woke up in the morning to a successful build! I’ll never know whether rechecking out the tree did it or changing to cairo-gtk2 did it, but I’d assume it’s the latter. Here’s a screenshot:
the missing nsIMenuBar.h was a problem in the Mozilla tree. It was fixed late last night. Ifyou do a cvs update you can remove the cairo line from your mozconfig.
Andrew
September 20, 2007 at 5:59 pm