Building Mozilla’s Firefox from source was definitely an experience on its own. This was my first time attempting to build a large open source project on my local machine. At first glance of the build instructions the process seemed to be simple and straightforward. You download Mozilla’s build tool, run a few commands, download the dependencies and before you know it you have a compiled build of Firefox.

Spoiler alert… I was wrong.

Firefox has been in development for 13 years with over 17 million lines of code and thousands of dependencies. You’re almost guaranteed to experience some issues.

Code, Comments and Blank Lines
Let The Build Begin
Day 1

After downloading and installing the mozilla-build tool,  you’re presented with TortoiseHg Windows shell. Hg contains a series of applications for Mercurial distributed revision control system. It also includes a Gnome/Nautilus extension and a CLI wrapper.
The next step was to start downloading the source files at over 5GB and an estimated 3 hours remaining. It was time to get some rest.

hg is the chemical symbol for mercury


Day 2

Luckily there were not network interruptions and the download completed successfully.

The next step was to run the “mach bootstrap” command. This  is a catch-all for any dependencies not covered in the documentation.

You’re taken through a series up setup questions to optimize the build to your environment. It then begins to download all the packages required for the build.

So far so good.

The final step was to run begin compiling the source files with the ‘mach build’ command.
Almost instantly after starting the build process I encountered my first error.
The setup wasn’t able to find the  system variable, llvm-config. A collection of modular toolchain compilers.

After scrolling through the error log it seemed to be a simple PATH error.

The solution was to create a new system variable pointed to: C:/Users/USERNAME/.mozbuild/clang/bin

llvm-config variable

I fixed the llvm PATH issue and I tried to build again. It passed the llvm-config check and continued to run a bit longer. Until the next error.

command line error MIDL1004 : cannot execute C preprocessor cl.exe
mozmake.EXE[3]: * [c:/mozilla-source/mozilla-central/config/ export] Error 2 0:58.03
mozmake.EXE[2]: * [c:/mozilla-source/mozilla-central/config/ default] Error 2 0:58.03
mozmake.EXE[1]: * [c:/mozilla-source/mozilla-central/ realbuild] Error 2

I began to search through Bugzilla, Mozilla’s issue tracking platform. I searched for hours looking for similar issue’s and solutions other users have suggested.

Down the rabbit hole I went…

I tried re-downloading dependencies, re-configuring Visual Studio build tools, dug through directories and the .mk files listed in the error, trying to find a solution. But no Luck.

After 4 hours of troubleshooting and 3 cups of coffee I called it a day.


Day 3

After talking with a few classmates about their progress, I found out there were a handful of students in the same situation with no solution. Students that experienced other errors were able to successfully run an ‘Artifacts build’ of Firefox.

At this point my patience were running low and last resort was to delete everything and start over with an Artifacts build.

Instead of building the project locally, Artifact mode would download pre-built C++ components. Essentially trading bandwidth for time.

I figured it was worth a shot and began the artifacts build on a fresh install of mozilla-build and source files.  After 20 minutes of downloading and compiling, it successfully built. I couldn’t believe it. There was a working environment of Firefox’s new browser, Nightly.

I was excited to dive to finally have a working build of Firefox and but decided it was best to start hacking at it the next day.

Day 4

I was happy to finally get started on a working build but at the same time part of me needed to fix the MIDL1004 error. Again, I started searching through Google and Bugzzilla, hoping to make some sense of this issue.

Before I knew it I was on the right track

Bug 1397263 – midl : command line error MIDL1004 : cannot execute C preprocessor cl.exe

led me to

Bug 1329587 – Move AS and MIDL checks to moz.configure

There’s a bug in the mozilla-build to that throws an MIDL error with file that contain spaces in the PATH name.

After getting a better understanding of the issue I put together a temporary solution:

Workaround: MIDL1004-C Preprocessor Error

It finally compiled locally and error free!

nightly build capture


Hacking Nightly

//Modified OpenBrowserWindow function in browser/base/content/browser.js to open cat GIFs when opening a new window.
function OpenBrowserWindow(options) { return“”); }


//Modified #TabsToolbar in browser/themes/windows/browser.css by adding a custom background.
<p style="text-align: center;">background: url(;

nightly build with custom menubar


//Modified the &#8220;Duplicate Tab&#8221; option in browser/locales/en-US/chrome/browser/browser.dtd
<p style="text-align: center;"><!--ENTITY duplicateTab.label "This Tab * 2"-->

Nightly custom duplicate tab option


Related Posts