I would like to share the success we have had making the fastest Firefox for Linux with the Mac community - this how to, although written for Linux, will easily translate to anyone who knows how to compile on OS X since Linux and OS X are very similar. The first thing to do is to go get a free download of the Intel C++ compiler for Linux or OS X which is available free for non-commercial use. Make sure to install the free license first or the compiler will not work. This 2 stage technique for compiling Firefox uses a compiler optimization called PGO or Profile Guided Optimization that first complies a complete Firefox that you use and as you use it FF learns your unique browsing habits and then uses the data it has collected to build a second firefox that is completely optimized uniquely for you and how you surf. Interesting right? Here is the how to:
First we need to download the Firefox 3.5 source - if you are doing this for Linux you can use our source that has a .mozconfig file:
http://www.linuxdna.com/ff35.tar.lzma
Make a test directory in /root and then extract the ff35.tar.lzma to that /root/test directory.
Now we want to take a look at the .mozconfig file - our file is made for the P4 cpu which is designated by the -xSSE2 in the line:
ac_add_options --enable-optimize="-O3 -xSSE2 -prof-gen=globdata -prof-dir=/root/test/mozilla-build -w"
You can change that to your cpu or leave it for SSE2 optimization as long as your cpu has SSE2 extensions. (If you are using the OS X compiler version the flag might be slightly different.)
Here is the entire .mozconfig file:
ac_add_options --enable-application=browser
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../mozilla-build
ac_add_options --prefix=/opt/firefox-3.5
ac_add_options --enable-optimize="-O3 -xSSE2 -prof-gen=globdata -prof-dir=/root/test/mozilla-build -w"
ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --disable-tests
ac_add_options --disable-javaxpcom
ac_add_options --enable-system-lcms
# ac_add_options --enable-system-sqlite
ac_add_options --with-system-jpeg
# ac_add_options --with-system-png
ac_add_options --with-system-zlib
ac_add_options --with-system-bz2
ac_add_options --disable-debug
ac_add_options --enable-cpp-exceptions
ac_add_options --enable-cpp-rtti
ac_add_options --disable-accessibility
ac_add_options --disable-crashreporter
ac_add_options --disable-installer
ac_add_options --disable-mochitest
ac_add_options --disable-official-branding
ac_add_options --enable-safe-browsing
ac_add_options --enable-xinerama
ac_add_options --enable-canvas
ac_add_options --enable-svg
ac_add_options --enable-pango
ac_add_options --disable-strip
Notice that sqlite and png support has been commented out. You may change that if you are using the latest sqlite and libpng packages on your system.. otherwise your compile will fail.
One final thing about .mozconfig it has a period in front of it so it will not be visible in the directory w/o using the ls -la command.
Now that we have configured the .mozconfig file to our liking we can excute the build once we have sourced our Intel compiler - here is how - you will have a directory with the compiler installed in it... on Linux it will be /opt/intel/ you will need to source the entire directory - if you are using ICC version 11.1.038 and a 32 bit cpu it will look like this:
source /opt/intel/Compiler/11.1/038/bin/iccvars.sh ia32
Note the ia32 at the end with a space before it. That denoted a 32bit system... if you are using a 64bit system it will look like this:
source /opt/intel/Compiler/11.1/038/bin/iccvars.sh intel64
Once we have sourced the compiler we can run this command from the /root/test/mozilla-1.9.1 directory:
make CC=icc CXX=icpc -f client.mk build
The build process will start and after a few min it will halt and complain about pixman-mmx.c not being able to compile. To correct this we must now go to the following directory and modifiy the Makefile:
vi /root/test/mozilla-build/gfx/cairo/libpixman/src/Makefile
Find the second USE_MMX=1 comment and delete it along with these comments also:
MMX_CFLAGS=mmmx -Winline
MMX_CFLAGS+=--param inline-unit-growth=10000 --param large-function-growth=10000
ifdef USE_MMX
CSRCS+= pixman_mmx.c
DEFINES += -DUSE_MMX
There will also be a loose endif above that section... delete it also.
Now we restart the compile back at /root/test/mozill-1.9.1:
make CC=icc CXX=icpc -f client.mk build
There will be two more trouble files that will stop the build - here is how to deal with them:
Once the build stops and complains about nsNavHistory.cpp download the following text file:
http://www.linuxdna.com/ffpgo.txt
if you use cat to display the file you will see two parts copy the first part like so:
g++ -o nsNavHistory.o -c -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1 -DMOZILLA_INTERNAL_API -D_IMPL_NS_COM -DEXPORT_XPT_API -DEXPORT_XPTC_API -D_IMPL_NS_COM_OBSOLETE -D_IMPL_NS_GFX -D_IMPL_NS_WIDGET -DIMPL_XREAPI -DIMPL_NS_NET -DIMPL_THEBES -DOSTYPE=\"Linux2.6\" -DOSARCH=Linux -I/root/test/mozilla-1.9.1/toolkit/components/places/src/../../build -I/root/test/mozilla-1.9.1/toolkit/components/places/src -I. -I../../../../dist/include/xpcom -I../../../../dist/include/string -I../../../../dist/include/docshell -I../../../../dist/include/dom -I../../../../dist/include/morkreader -I../../../../dist/include/pref -I../../../../dist/include/necko -I../../../../dist/include/imglib2 -I../../../../dist/include/gfx -I../../../../dist/include/intl -I../../../../dist/include/layout -I../../../../dist/include/locale -I../../../../dist/include/uconv -I../../../../dist/include/unicharutil -I../../../../dist/include/autocomplete -I../../../../dist/include/storage -I../../../../dist/include/txmgr -I../../../../dist/include/nkcache -I../../../../dist/include/widget -I../../../../dist/include/chardet -I../../../../dist/include -I/root/test/mozilla-build/dist/include/nss -I/root/test/mozilla-build/dist/include/nspr -I../../../../dist/include/places -I/root/test/mozilla-build/dist/include/nspr -I/root/test/mozilla-build/dist/sdk/include -fPIC -frtti -fhandle-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-long-long -pedantic -fno-strict-aliasing -fshort-wchar -pthread -pipe -DNDEBUG -DTRIMMED -O3 -DMOZILLA_CLIENT -include ../../../../mozilla-config.h -Wp,-MD,.deps/nsNavHistory.pp /root/test/mozilla-1.9.1/toolkit/components/places/src/nsNavHistory.cpp
Once you have copied that first long sting go to the following directory:
cd /root/test/mozilla-build/toolkit/components/places/src/
Now paste the entire string to the command line and hit enter. After that cd back to the /root/test/mozilla-1.9.1 directory and start the build over again:
make CC=icc CXX=icpc -f client.mk build
The build will stop one last time - do the exact same thing for the first one but use the second command string in ffpgo.txt
Issue the make command one last time:
make CC=icc CXX=icpc -f client.mk build
Now your system will complete the make and all you have to do is issue the install command:
make CC=icc CXX=icpc -f client.mk install
This will install the Firefox 3.5 stage one to the /opt directory - issue this to start Firefox:
/opt/firefox-3.5/bin/firefox
Now your firefox will be up and running! This is the fun part... use firefox as you normally would for a few days to a week's time... while you are using it Firefox will be generating files called "dyn files. You can see them if you go to the following directory:
/root/test/mozilla-build
The dyn files are "evolutionary data" that firefox will create about your surfing habits. Once you finish your surfing over the next few days we will use these dyn files to generate a screaming fast firefox that is optimized for your particular use!
To recompile the final firefox go to the /root/test/mozilla-build directory and delete everything *but* keep all the .dyn files and the pgopti.sp* files. Now we need to edit the mozconfig file to use the dyn file data and rerun the build again - change the following line in .mozconfig:
ac_add_options --enable-optimize="-O3 -xSSE2 -prof-gen=globdata -prof-dir=/root/test/mozilla-build -w"
to this:
ac_add_options --enable-optimize="-O3 -xSSE2 -prof-use -prof-dir=/root/test/mozilla-build -w"
Now build and install firefox the same way we originally did and stand back! You know have the fastest Firefox available!