The Mozilla build system contains support for building with Profile-Guided Optimization (PGO) with GCC 4 or newer and Microsoft Visual C++ 2005 (Professional Edition) or newer. A PGO build consists of two passes: a first pass to build instrumented binaries, then a second pass to re-build optimized binaries using profile information gleaned from running the instrumented binaries. The Mozilla build system will run both passes for you, as well as a profile generation script in between.
In order to build Firefox with Profile Guided Optimizations, you should first make sure that you can do a simple build of Firefox. You need to set up the build prerequisites and environment. You must have tests enabled (do not include
--disable-tests in your build configuration). Then run
make -f client.mk profiledbuild (see the Building section below.)
The Mozilla build system will run the
pgo-profile-run make rule from
testing/testsuite-targets.mk, which in turn runs the
build/pgo/profileserver.py script. You can customize any of these two if you need the profile generation to happen differently from the default.
PGO builds require you to start your build from a different target in client.mk. Instead of the usual
make -f client.mk build, you do
make -f client.mk profiledbuild.
PGO builds will take much longer than normal builds! With GCC, you will wind up doing two complete clobber builds. With MSVC, you will only do one full build, and then another pass of re-linking, but re-linking libxul can take over a half hour on a fast machine, and use over one gigabyte of RAM.
Linking a PGO build is known to exhaust the 32 bit address space on Win32. To work around this either use a 64 bit compiler or use the /3GB boottime switch to give the linker more address space. See Bug 543034 for details.