Note: Substantive changes to this page (non-editorial) should be reviewed by Mark Mentovai ([email protected]), or one of the build-config peers.
Mozilla builds for OS X are Mach-O builds, built from Makefiles. Doing builds on OS X is therefore very similar to doing Unix/Linux builds. You should be comfortable using the Terminal app (in /Applications/Utilities
). Additional instructions are available for building Mozilla as a universal binary.
If you run into problems, see the Mozilla Build Frequently Asked Questions or the rest of the Mozilla build documentation.
{{ BuildDocsTOC() }}
One-Line Setup (Try This First!)
Run the following in a terminal:
curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py > bootstrap.py && python bootstrap.py
This will help you install all the build prerequisites for OS X. Your account will need permission to administer this computer to succeed; you can verify that you have this permission in System Preferences -> Users & Groups.
In some circumstances - particularly if you've got a MacPorts or Homebrew development environment already set up - this script can error out. Most of those errors can be resolved by bringing your MacPorts or Homebrew installations up to date.
You can do this with:
port selfupdate && port upgrade outdated
for MacPorts and
brew update && brew upgrade
for Homebrew. If that doesn't work, or you need more details, please contact Mike Hoye. The documentation below may also be of assistance.
You will need:
- Apple ID (to install
Xcode
) - 1 hour (to download and install
Xcode
, which is slow) Homebrew
orMacports
(bootstrap.py
will install these if necessary)
Once your build environment is complete, proceed to Step 3 below.
Build Steps (Details)
Building on OS X is divided into the following steps:
- Install Apple-distributed developer tools
- Install supplementary build tools
- Obtain a copy of the Mozilla source code
- Configure the Mozilla source tree to suit your needs
- Build Firefox
1. Install Apple-distributed developer tools
For all versions of OS X, you will need to install Xcode to build any Mozilla application.
Note that for Xcode 4.5 and later the expected install location is /Applications (not /Developer/Applications). When you run a 4.5+ .dmg it will simply show you an Xcode.app file. Take care NOT to run this .app from there. Drag it to /Applications and run it from there instead. If you run Xcode.app from the .dmg folder directly it will screw up various paths associated with your Xcode install by making them point into /Volumes/Xcode/Xcode.app. That in turn will break building of Mozilla (probably with build errors making WebRTC makefiles), updating of MacPorts, etc. once the .dmg is unmounted! If you do find yourself in this position, try running
sudo xcode-select -switch /Applications/Xcode.app
Note that if you get a build failure where it can't find "find_sdk.py" when generating webrtc makefiles from .gyp files, this is likely your problem.
You can download and install Xcode from:
- https://developer.apple.com/downloads/index.action (Apple ID required, but subscription and credit card info not required.)
- The Apple App Store (in newer versions of OS X)
- Note that you need to run /Applications/Install Xcode.app after installing Xcode via the App Store. This, however, may fail due to "untrusted package" error. One known workaround to this is to set the computer's clock back temporarily to 1/1/2010 and trying the installation again.
- The Mac OS X Install DVD that came with your computer. The Xcode or XcodeTools installer should be located in the "Optional Installs" folder. If possible, you should obtain Xcode from the Internet to ensure you have an up-to-date version.
Generally, any released version of Xcode should build the latest version of a Mozilla source tree. However, early adopters of new and beta Xcode releases may see incompatibilities. Therefore, heed caution when upgrading OS X and Xcode.
The compatibility of various OS X and Xcode versions is listed in the Software Requirements section below.
For Xcode 4.5 and up you will also need to manually install the Command Line Tools: Xcode > Preferences > Downloads > Command line tools > Components > Install. (Failing to do this when upgrading from an older version of Xcode will simply leave you with the old /usr/bin/clang etc.)
Note: the Apple version of clang 4.2 is now required. If you see the error message below you are likely using an older clang version:
In file included from .../js/src/vm/PropertyKey.cpp:9: ./../../dist/include/js/PropertyKey.h:35:7: error: no member named 'operator=' in 'JS::Value' class PropertyKey ^~~~~~~~~~~ ./../../dist/include/js/PropertyKey.h:87:14: note: implicit default move assignment operator for 'JS::PropertyKey' first required here *key = PropertyKey(uint32_t(v.toInt32())); ^ 1 error generated.
2. Install supplementary build tools
Mozilla's source tree requires a number of third party tools and applications to build it. You will need to install these before you can build anything.
You have the choice over how to install all these components. You can use a package manager like Homebrew or Ports. Or, you can obtain, compile, and install them individually. For simplicity and to save your time, using a package manager is recommended. The following sections describe how to install the packages using existing package managers. Choose whatever package manager you prefer.
You can also use these package managers to install Clang if your version of Xcode doesn't have it already.
2.1a Install Dependencies via Homebrew
Homebrew is "the missing package manager for OS X." It provides a simple command-line interface to install packages, typically by compiling them from source.
The first step is to install Homebrew. See https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md#installation
Once you have Homebrew installed, you'll need to run the following:
$ brew install yasm mercurial gawk ccache python
Depending on the version of Xcode you are using, "brew install mercurial" may fail due to a missing Mac OS 4 universal SDK. You may work around this issue by directly installing mercurial binary from this site, and installing yasm only using brew.
You will also need autoconf213, but the primary Homebrew repository does not retain formulas for older versions of software. Fortunately, a repository of older versions exists. To install autoconf 2.13, install the homebrew/versions tap and then install the autoconf213
formula:
$ brew tap homebrew/versions $ brew install autoconf213
Alternatively, you can just point to that formula directly (no need to download it first):
$ brew install https://raw.github.com/Homebrew/homebrew-versions/master/autoconf213.rb
2.1b Install Dependencies via MacPorts
MacPorts is a package manager for OS X. If you are running Homebrew, you can ignore this section.
To install MacPorts, go to their install page, download the .dmg for your platform, and install it. If you already have MacPorts installed, ensure it is up to date by running:
$ sudo port selfupdate $ sudo port sync
The first of these commands will ask for your root password.
Common errors include:
sudo
doesn't accept a blank password: create a password for your account in System Preferences.port
command not found: add it to your path (see troubleshooting section below).
Use MacPorts to install the packages needed for building Firefox:
$ sudo port install libidl autoconf213 yasm
You'll then see lots of output as MacPorts builds and installs these packages and their dependencies -- it takes a while, so go grab a cup of coffee.
2.2 Install Mercurial
Mozilla's source code is hosted in Mercurial repositories. You use Mercurial to interact with these repositories. There are many ways to install Mercurial on OS X:
- Install official builds from Selenic
- Install via MacPorts:
- $ sudo port install mercurial
- Install via Homebrew:
- $ brew install mercurial
- Install via Pip
- $ easy_install pip && pip install mercurial
Once you have installed Mercurial, test it by running:
$ hg version
If this works, congratulations! You'll want to configure your Mercurial settings to match other developers. See Getting Mozilla Source Code Using Mercurial.
If this fails with the error "ValueError: unknown locale: UTF-8", then see the workarounds on the Mercurial wiki's Unix Install page.
When trying to clone a repository you may get an HTTP 500 error (internal server error). This seems to be due to something that Mac Mercurial sends to the server (it's been observed both with MacPort and selenic.com Mercurial binaries). Try restarting your shell, your computer, or reinstall Mercurial (in that order), then report back here what worked, please.
3. Obtain a copy of the Mozilla source code
You may want to read Getting Mozilla Source Code Using Mercurial for the complete instructions. If you are interested in Firefox development:
# The following will create a new directory, mozilla-central, in the # current one with the contents of the remote repository. This command # will take many minutes to run, as it will be copying a couple hundred # megabytes of data over the internet. $ hg clone https://hg.mozilla.org/mozilla-central/ mozilla-central $ cd mozilla-central(If you are building Firefox for Android, you should now return to the
4. Configure the Mozilla source tree for build options
In your checked out source tree, you'll create a new file, .mozconfig
, which contains your build options. For more on this file, see Configuring Build Options.
To quickly get started, create the file .mozconfig
file in your source tree clone with the following contents:
# Define where build files should go. This places them in the directory # "obj-ff-dbg" under the current source directory mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff-dbg # -s makes builds quieter by default # -j4 allows 4 tasks to run in parallel. Set the number to be the amount of # cores in your machine. 4 is a good number. mk_add_options MOZ_MAKE_FLAGS="-s -j4" # Enable debug builds ac_add_options --enable-debug
Builds require the 10.7 SDK or higher. If you'd like to ensure compatibility with an operating system version previous to the one you are building on, you can explicitly specify an SDK by adding a line like this:
ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.8.sdk
For MacOSX10.10, or maybe for versions of Xcode after version 6, this may need to be a different path, for example:
ac_add_options --with-macos-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
Or, check the /Applications/Xcode.app/Contents/Developer/Platforms directory to see which SDKs are installed, and pick one to add into your .mozconfig.
Firefox no longer builds with gcc 4.2, but the build system should automatically select clang if it is available in the PATH. If that is not the case, you need to set CC and CXX. For instance, if you installed Clang 3.1 via Homebrew, then you need to have
CC=clang-mp-3.1 CXX=clang++-mp-3.1
If you installed autoconf 2.13 with the Homebrew recipe linked above, you'll need to add the following to your .mozconfig
:
mk_add_options AUTOCONF=/usr/local/Cellar/autoconf213/2.13/bin/autoconf213
5. Build
Once you have your .mozconfig
file in place, you should be able to build!
$ ./mach build
If the build step works, you should be able to find the built application inside obj-ff-dbg/dist/
. If building the browser with --enable-debug
, the name of the application is NightlyDebug.app
. Try running the following:
$ ./mach run
mozilla-1.9.2
branch, the application will be named Namoroka.app
or NamorokaDebug.app
.Hardware requirements
There are no specific hardware requirements, provided that the hardware accommodates all of the software required to build Mozilla. Mozilla can take a very long time to build, so recommended development systems are listed alongside the minimum requirements.
- Processor: PowerPC G4 or later, PowerPC G5 or Intel CPUs recommended. Mozilla can now be built for either type of processor, or as a universal binary for both types (see Mac OS X Universal Binaries).
- Memory: 256MB RAM minimum, 1GB recommended.
- Disk Space: At least 1GB of free disk space for non-debug builds; development/debug builds require at least 2.5GB of free disk space.
Software requirements
- Operating System: Mac OS X 10.5.8 or later. It is advisable to upgrade to the latest “point” release (currently 10.5.8 and 10.6.6) by running Software Update, found in the Apple menu.
- Beginning with Mozilla 1.9.3 (mozilla-central), Mac OS X 10.5 is both a build- and run-time requirement; for 64-bit builds, Mac OS X 10.6 is both a build- and run-time requirement.
- Beginning with Mozilla 1.9 (cvs trunk), Mac OS X 10.4 is both a build- and run-time requirement.
- Mozilla’s 1.8.0 and 1.8.1 branches will run on Mac OS X 10.2 (“Jaguar”), but the build requires a minimum of 10.3 (“Panther”).
- No recent version of Mozilla will build or run on 10.1 (“Puma”).
To install the following software requirements, you may need administrative privileges on the system.
- Development Environment: Xcode 4.1 or later. Tested Xcode configurations are listed in the Mac compatibility matrix. There are three ways to obtain or upgrade Xcode:
- Download: Download Xcode from Apple. This ensures that you’ll install the latest version of the tools available for your computer. You’ll need a (free) Apple Developer Connection membership. Note that Xcode updates are not installed by Software Update at this time.
- The OS X App Store.
- DVD or CD: Most Macs and retail versions of Mac OS X include an Xcode installer on the installation discs. Check your discs for Xcode or Developer Tools.
- Package Management: A package management system is not strictly required, but simplifies the installation of additional build dependencies. There are two package management systems that are compatible with the Mozilla build system, Fink and MacPorts. Note that package installation may be a time-consuming but automated process using either tool.
- MacPorts, formerly DarwinPorts. You may download the MacPorts installer corresponding to your operating system release. MacPorts installs in
/opt/local
by default. After running the MacPorts installer, the changes that it makes to the shell environment will be available in any new Terminal window. - fink (not recommended).
- MacPorts, formerly DarwinPorts. You may download the MacPorts installer corresponding to your operating system release. MacPorts installs in
- To build the old branch such as Mozilla 1.9, libIDL and GLib, libraries used by Mozilla’s IDL (interface definition language) file parser. These may be installed using MacPorts using the commands listed below. Glib is installed automatically as part of the libidl install. Administrative privileges are required, so provide your password to the
sudo
command if requested:$ sudo port sync $ sudo port install libidl +universal
The above command buildslibidl
as a universal binary, making it possible to link Mozilla under any OS X architecture.
- autoconf version 2.13 is needed if you plan on making changes to the Mozilla configure.in files on versions up to 1.9 and when building from mozilla-central. Newer versions of autoconf, including those that come with Xcode and installed in
/usr/bin
, are incompatible with Mozilla ({{ Bug(104642) }}).$ sudo port install autoconf213
The above commands install autoconf-2.13 to
/opt/local/bin/autoconf213
using MacPorts. You will need to typeautoconf213
to run it when other documentation might instruct you to runautoconf
. Do not install theautoconf
package without the213
suffix.When building from mozilla-central, use
mk_add_options AUTOCONF=autoconf213
in your .mozconfig. - Mercurial source control system (if you're planning to work on post-1.9.0 code). See Mercurial#Installing.
- To build the Mozilla 1.9.0, 1.9.1, or 1.9.2 branches on a Mac OS X 10.4 build host, additional packages are required, so run the following command to obtain them:
$ sudo port install python py25-zlib py25-hashlib
.mozconfig options and other tunables
These options are specific to Mozilla builds for OS X. For a more general overview of build options and the .mozconfig
file, see Configuring Build Options. For specific information on configuring to build a universal binary, see Mac OS X Universal Binaries.
- Compiler: Firefox releases are no longer built with gcc-4.2. A recent copy of clang is needed.
- See the discussion here: gcc 4.2 - Clang Switch Discussion
- There are some options on where to get clang:
- Newer versions of xcode. The one in xcode 4.1 or newer and the open source 3.1 release should work.
- Following the instructions in the clang web site for information on how to get it.
- Using some of the package managers (see above).
- Once bug 768879 is fixed, you should be able to download the same packages used by the bots.
The following options, specified with ac_add_options
, are lines that are intended to be added to your .mozconfig
file.
- Mac OS X SDK: This selects the version of the system headers and libraries to build against, ensuring that the product you build will be able to run on older systems with less complete APIs available. Selecting an SDK with this option overrides the default headers and libraries in
/usr/include
,/usr/lib
, and/System/Library
. Mac OS X SDKs are installed in/Developer/SDKs
during the Xcode installation by selecting the Cross Development category in the installer’s Customize screen.ac_add_options --with-macos-sdk=/path/to/SDK
Official trunk builds use
/Developer/SDKs/MacOSX10.7.sdk
. Checkbuild/macosx/universal/mozconfig.common
for the SDK version used for official builds of any particular source release.Applications built against a particular SDK will usually run on earlier versions of Mac OS X as long as they are careful not to use features or frameworks only available on later versions.Note that some frameworks (notably AppKit) behave differently at runtime depending on which SDK was used at build time. This may be the source of bugs that only appear on certain platforms or in certain builds.
-
You will not be able to build Mozilla using the 10.2.8 SDK included in the Xcode 2.4 installer. If you install Xcode 2.4, please see the Mac OS X Prerequisites#Troubleshooting section for a workaround. Upgrade to Xcode 2.4.1 or newer.
Use of an SDK is highly recommended, especially when building on OS X 10.3 with Xcode 1.5. - Deployment Target: This option selects the minimum OS version that the resulting application will run on. Proper use of this option requires additional support in the code.
ac_add_options --enable-macos-target=version
This option is not recommended. The default for the trunk on all platforms is10.5
, while on the 1.9.0-1.9.2 branches it is10.4
. The default for PowerPC builds on the 1.8.0 and 1.8.1 branches is10.3
, while the default for Intel builds on those branches is10.4
. Official builds use these defaults. - Prebinding: The Mozilla build system allows you to build an application and libraries that are prebound. This improves application launch time on OS X 10.3.3 and earlier.
ac_add_options --enable-prebinding
The default is to not prebind. Official PowerPC builds are prebound. Official Intel builds are not prebound, as no Intel build will run on any release earlier than 10.4. - Sample
.mozconfig
: This.mozconfig
file is suitable to build an Intel version of Minefield (equivalent to Firefox), which will only run on Intel-based Macs running OS X 10.5 or newer:. $topsrcdir/browser/config/mozconfig ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk ac_add_options --disable-tests
Build defines
For OS X builds, defines are set up as follows:
XP_MACOSX
is definedXP_UNIX
is definedXP_MAC
is not defined.XP_MAC
is obsolete and has been removed from the source tree (see {{ Bug(281889) }}). It was used for CFM (non-Mach-O) builds for the classic (pre-X) Mac OS.
This requires care when writing code for Unix platforms that exclude Mac:
#if defined(XP_UNIX) && !defined(XP_MACOSX)
Troubleshooting
- Unable to build with GCC. Apple used to ship a GCC based on vanilla GCC 4.2. They still ship LLVM-GCC (which is also base on GCC 4.2). Mozilla does not support building with any GCC 4.2 variant anymore. On OS X, non-Apple (i.e. stock) GCCs are also not supported (they don't support blocks), so you must use clang on OS X.
- After installing Xcode 2.4, the build fails in
nsLookAndFeel.cpp
with:
error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function)
.The 10.2.8 SDK included in Xcode 2.4 (build 8K1079) contains a bug that prevents Mozilla from building with that SDK. Apple has been notified of this bug, which is being tracked as Radar 4671592. This bug has been fixed as of Xcode 2.4.1.
- QuickTime SDK Update: If you install or update QuickTime 7, you may also need to install an updated QuickTime SDK, available from “Software Update” in the Apple menu. This update is only needed if Software Update indicates that it is available to you. You will need this update if your build fails because it is unable to find
Sound.
- Using Fink, you get
apt-get: command not found
.apt-get
is not in your$PATH
. Close and reopen Terminal and try again. If the error persists, Fink was unable to fully configure itself in your environment. Take these steps:- If you use the
bash
shell, the default since OS X 10.3, edit your~/.bashrc
file, adding the following line. Don’t neglect the leading period and space.. /sw/bin/init.sh
- If you use the
tcsh
shell, edit your~/.tcshrc
file, adding the following line:source /sw/bin/init.csh
- If you use the
- Using MacPorts (DarwinPorts), you get
port: command not found
.port
is not in your$PATH
. Close and reopen Terminal and try again. If the error persists, DarwinPorts was unable to fully configure itself in your environment. Take these steps:- If you use the
bash
shell, the default since OS X 10.3, edit your~/.profile
(or~/.bash_profile
or~/.bash_login
, if either exists) file, and adding the following line:export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
- If you use the
tcsh
shell, edit your~/.tcshrc
file, adding the following line:setenv PATH "/opt/local/bin:/opt/local/sbin:$PATH"
- After modifying the appropriate file, close and reopen Terminal and try again.
- If you use the
- Using Fink with Virex 7.2: There is a conflict between Fink and Virex 7.2. Both place files within
/sw
. If you have Virex installed, you will need to upgrade to at least version 7.2.1, as described in the Fink News (2003-04-16). - The build stops while building
libwidget.rsrc
inwidget/src/mac
Delete, or rename
~/Library/Preferences/.GlobalPreferences.plist
. We're not quite sure what setting in that file is causing this problem. Note that if you remove this file, system preferences such as preferred locales and recent programs will also disappear. - The build complains about missing IDL headers: Make sure you installed the orbit distribution via Fink's
apt-get
, and that you edited your.bashrc
to source the/sw/bin/init.sh
file or your.tcshrc
file to source the/sw/bin/init.csh
file. - Can't find
dlfcn.h
with errornsTraceRefcnt.cpp:68: dlfcn.h: No such file or directory
Make sure you have the libdl.dylib from Fink. If you install bash from Apple, it will provide a copy of libdl.dylib which will not come with the headers (e.g., dlfcn.h) needed to compile new programs that use the library, such as Mozilla. The solution is to remove the bash from Apple and install the bash from Fink. (Thanks to Alex Stewart for helping us track this down.)
-
Error: Failed to install db46
-
Error: Target org.macports.build returned: shell command failed (see log for details) Error: Failed to install db46 Log for db46 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_db46/main.log Error: The following dependencies were not installed: python26 db46 gdbm gettext expat libiconv gperf ncurses ncursesw openssl zlib readline sqlite3 Error: Status 1 encountered during processing. To report a bug, see <https://guide.macports.org/#project.tickets>
-
OS X 10.6.5 and newer have removed a file necessary to build db46, which is a prerequisite for some of the MacPorts packages we require. You can get this file by installing the Java Developer Package for Mac.
-
If configure (or generally building with clang) generates this error:
fatal error: 'stdio.h' file not found
Try making sure xcode command line tools are installed by running:xcode-select --install
[jgilbert] found this necessary during an install for 10.9.
Building with --enable-dtrace fails with configure: error: dtrace enabled but sys/sdt.h not found
Make sure you use the 10.5 SDK, not 10.4 as in the default configuration.
Forcing 32-bit builds
Currently, 64-bit compilation is the default. If you want to build a 32-bit version of Firefox on OS X, you can append the following lines to your .mozconfig in order to force the build process to produce a 32-bit version of Firefox.
CC="clang -arch i386" CXX="clang++ -arch i386" ac_add_options --target=i386-apple-darwin9.2.0 ac_add_options --enable-macos-target=10.6 HOST_CC=clang HOST_CXX="clang++" RANLIB=ranlib AR=ar AS=$CC LD=ld STRIP="strip -x -S" OTOOL=otool CROSS_COMPILE=1