This article is in need of a technical review.
This page covers the steps needed to prepare your machine to build a bleeding-edge, development version of Firefox on Windows.
Mozilla takes time to build. You need a development-class system:
- A fast processor, ideally with several cores.
- At least 2 GB of RAM, 4 GB or higher recommended.
- 1.5 GB NTFS or 3 GB FAT disk space, or more
- Windows Vista or later recommended (the build should work on Windows XP though).
The Mozilla build process requires many tools that are not installed on most Windows systems. In addition to Visual Studio, you must install MozillaBuild, which is a bundle of software including just the right versions of bash, GNU make, autoconf, Mercurial, and much more.
This document is a guide to the MozillaBuild environment, which works with the following versions of the Mozilla codebase available as Mercurial code repositories:
- mozilla-central/mozilla-aurora/mozilla-beta/mozilla-release (Firefox)
- comm-central/comm-aurora/comm-beta/comm-release (Thunderbird)
It works with the following compilers ("Official" means this is what we use for the builds we release as the Firefox product):
|VC8 (Visual Studio 2005)||VC9 (Visual Studio 2008)||VC10 (Visual Studio 2010)||VC11 (Visual Studio 2012)|
Note that installing both Visual Studio 2010 and Visual Studio 2012 on Windows 64-bit currently seems to break the build. See Bug 772989 Comments 15 and 17 for a possible workaround.
Install build prerequisites
Complete each of these steps otherwise you may not be able to build successfully, there are notes on these software requirements below.
- Make sure your system is up-to-date through Windows Update. (Windows XP needs at least Service Pack 2 and .NET Framework 2.0.)
- Install a version of Visual Studio that supports C++ development: VS 2012 for Windows Desktop Pro or Express (free), or VC++ 2010 Pro or Express (free).
- You may need to install one or more Windows SDKs. See Windows SDK versions for a quick guide.
- Install the June 2010 DirectX SDK (even VS 2012 requires this).
- Install MozillaBuild, a package of additional build tools. (If you see a Windows error dialog giving you the option to re-install with the 'correct settings', choose that option and after that all should be well.)
The rest of the build steps are done from the MSYS shell installed with MozillaBuild (the MINGW32 shell). NOTE that this is not the same as an MS-DOS CMD.EXE Shell.
Mozilla will not build if some tools are installed at a path that contains spaces or other breaking characters such as pluses, quotation marks, or meta characters. The Visual C++ tools may be installed in a directory which contains spaces (the default install location is preferred).
Opening a Build Command Prompt
After the prerequisites are installed, launch one of the following batch files from the
start-shell-msvc2010.bat (for Visual Studio 2010)
forVisual Studio 2012)
forVisual Studio 2013)
start-shell-msvcNNNN-x64.batfiles (unless you know what you're doing). Those files are experimental and unsupported. See the Build:MozillaBuild For x64 wiki page.
This will launch a MSYS command prompt properly configured to build one of the aforementioned code bases.
All further commands should be executed in this command prompt window.
Create directory for the source
It's a sensible idea to create a new directory dedicated solely to the code.
cd /c; mkdir mozilla-source; cd mozilla-source
Now you are ready to get the Firefox source and build, continue on from Simple Firefox build (Get_the_source).
Notes on some of the required software
Microsoft DirectX SDK
The June 2010 DirectX SDK (specifically) is required for building the ANGLE GLES-on-D3D9 renderer, which is required on Windows for WebGL rendering. (If you don't care about compatibility with official Firefox builds and want to avoid installing this large SDK, you can disable WebGL by building Mozilla with the --disable-webgl option.) As part of the DirectX SDK install, you must install the End-User Redistributable Packages; don't uncheck it in the installer. (At least prior to Win7+VS2012?)
(Note that other versions of the DirectX SDK on Microsoft's Developer Center that claim to have been released after June 2010 are actually older versions that are misdated, some of which will result in an error if you try and download them due to the installer files themselves having been removed from the MS servers. There will not be any further standalone DirectX SDKs released by MS, since DirectX has been transitioned from an independent distribution model to an integrated (into Windows and Visual Studio) model, and the DirectX SDK is now integrated into the Windows 8 SDK (which is bundled with Visual Studio as of VS2012) [ref]. The reason that we require the June SDK even on newer Win7+VS2012 systems is because ANGLE depends on D3DX9, but MS considers D3DX to have been obsoleted by newer technologies and therefore VS2012 don't include the d3dx9.h and d3dx9tex.h headers that are required to compile ANGLE. Any queries about this paragraph, talk to Jonathan Watt.)
MSDN claims that MSVC 2005 is not compatible with the June 2010 SDK, but as far as we're concerned it works for release builds. However you cannot use the compiler provided with the Vista SDK to compile debug builds at all, and you need a hotfix to be able to compile debug builds with the full MSVC 2005.
The MozillaBuild package contains the other software prerequisites necessary for building Mozilla. This includes the MSYS build environment, Mercurial, autoconf-2.13, CVS, Python, YASM, NSIS, and UPX, as well as optional but useful tools such as wget and emacs.
By default, the package installs to
c:\mozilla-build. It is recommended to use the default path. Don't use a path that contains spaces. The installer does not modify the Windows registry. Note that some binaries may require Visual C++ Redistributable package to run.
Expectation setting: Note that the "UNIX-like" environment provided by MozillaBuild is only really useful for building and committing to the Mozilla source. Most command line tools you would expect in a modern Linux distribution are not present, and those tools that are provided can be as much as a decade or so old (especially those provided by MSYS). It's the old tools in particular that can cause problems, since they often don't behave as expected, are buggy, or don't support command line arguments that have been taken for granted for years. For example, copying a source tree using
cp -rf src1 src2 does not work correctly because of an old version of cp (it gives "cp: will not create hard link" errors for some files). In short, MozillaBuild supports essential developer interactions with the Mozilla code, but beyond that don't be surprised if it trips you up in all sorts of exciting and unexpected ways.
The MozillaBuild package includes the "make" program that originated on the UNIX and Linux platforms. This version of make does not make use of Windows' multi-core architecture. pymake is a Python implementation of Make that uses Window's multi-core architecture and thus significantly speeds up build time.