How to Build Firefox
Open source is a dream and a gateway to an amazing career -- I'm a testament to that. One of the most amazing open source projects to ever exist, Mozilla Firefox, is a project I'm proud to work on as an employee of Mozilla. It's rewarding, challenging, and a unique experience...and I want you to join me!
Take a few moments with me to learn how to build the amazing Firefox!
Step 1: Clone Mozilla Central
Mozilla Central is the name of the mercurial repository that contains the source code of Firefox. Start by installing mercurial and cloning "MC":
hg clone https://hg.mozilla.org/mozilla-central/
hg clone {repo_url}
is the first and most basic mercurial command, but check out my Mercurial Productivity Tips post to learn more hg
commands! "MC" will be installed in a mozilla-central
directory.
Step 2: Install Dependencies
From C++ to Rust, Firefox has a fair bit of requirements you'll need to install. From within the mozilla-central
directory, run the following:
./mach bootstrap
The bootstrap
command will install dependencies as well as configure mercurial extensions as required. Congratulations -- you're now ready to build!
Step 3: Create a mozconfig
You'll thank me for this one! Create a mozconfig
file to use artifact builds, which will save loads of time during the build process by downloading pre-built binaries for Firefox's internals.
# Automatically download and use compiled C++ components: ac_add_options --enable-artifact-builds # Write build artifacts to: mk_add_options MOZ_OBJDIR=./objdir-frontend
Place the code above in your mozconfig
file and you're builds will be super fast!
Step 4: Build!
Once you have the code and the dependencies, it's time to build the amazing Firefox! You can build Firefox with the following command:
./mach build
Hello Firefox!
Step 5: Run Firefox
Once you've built the amazing Firefox, you can run Firefox with the following mach
command:
./mach run --jsdebugger
Congratulations! You've taken the Firefox source code and turned it into an application that you can run! The --jsdebugger
option opens the "browser toolbox" which allows you to debug the Firefox you've just built.
Updating Mozilla Central Code
The Mozilla Central repository is updated several times a day as Mozilla employees and contributors like you submit patches. You can update your local checkout with the following:
hg pull && hg update --clean
You local commits will always be draft
status while patches which have been merged into MC will be public
status.
Configuring Options
Whenever Firefox developer and the community develop new features, they're hidden behind a preference until the feature reaches maturity. To toggle feature flags, you can visit about:config
in your local Firefox or any Firefox release.
The config page allows you to toggle and set a number of options. Many "edge" features debut behind feature flags in Firefox Nightly.
Congratulations! You've turned a massive repository of code into a living, breathing Firefox web browser! In the next post in the Firefox series, we'll explore contribution and testing!
Could you say something how to build support for gpsd? I have application that are made with javascript dependent on GPS for use in a sail boat. I need to compile Firefox with support for gpsd. I plan to use the browser with raspberry pi and Linux.
Hi, While trying to build. I am getting this error. I am new to building from source code.
I have following error:
To save the next person downloading 7+GB and more than 800k files: the build does not work on Raspbian/Raspberry Pi OS. It fails at the OS check, and if you bypass that by editing the bootstrap script to make it see the system as Debian (which it is) then it later fails in the Rust initialization, where it seems to think the system is an x86/64 (it’s an ARM).