NOTE: substantive changes to this page (non-editorial) should be reviewed by one of the build-config peers

It is possible to build Mozilla applications as a universal binary that runs natively on multiple architectures. Universal binaries contain:

On the Gecko 1.9.2 and lower branches, universal binaries are PPC/i386 binaries. On Gecko 2.0 and higher branches, universal binaries are i386/x86_64.

Prerequisites

The universal build system is supported on the trunk, Mozilla 1.9.1 and Mozilla 1.9.2 branches. You should be familiar with the macOS build prerequisites before attempting to build a universal binary of a Mozilla product. The prerequisites for universal binaries are the same. "libIDL" and "GLib" need only be installed in the host architecture.

Configuration

This section describes how to check out the necessary files and configure Mozilla to build as a universal binary.

Your .mozconfig file

When preparing your own .mozconfig file, you must source the $topsrcdir/build/macosx/universal/mozconfig config fragment . It should be sourced after any product-specific mozconfig, in case it needs to override any options.

Universal binaries must be built as objdir builds, so MOZ_OBJDIR must be set. The location of your objdir is unimportant, so long as you provide one.

Here is a sample .mozconfig suitable for building a universal binary of Firefox in a release configuration:

. $topsrcdir/browser/config/mozconfig
. $topsrcdir/build/macosx/universal/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/myobjdir
ac_add_options --disable-tests

In this example, the objdir is placed inside the top source directory, in a directory called myobjdir.

Building

Once the configuration is in place, use the normal steps to build. Two build passes will be made, one for each architecture. As one might expect, this process takes approximately twice as long as compiling for a single architecture. After both passes are complete, the results are automatically merged into a single universal binary.

Results of a build

Two subdirectories are created in your objdir, one for each architecture (ppc, i386, or x86_64). Each of these directories contains a complete processor-specific build. The merged universal binary is placed in both build directories, one via symlink, at dist/universal.

Packaging

For most products, when configured as a universal binary, the packaging phase will produce a disk image containing the merged universal binary. In order to perform the packaging phase, you must keep the new objdir structure in mind. If you had used the sample .mozconfig above, you would build a universal disk image of Firefox by typing:

cd myobjdir/x86_64
MOZ_CURRENT_PROJECT=i386 make -C ../i386/ package

The disk image will be produced in ../myobjdir/i386/dist. You could just as easily substitute another architecture for i386, this only affects the location that the disk image is produced in.

To bypass universal packaging, and create a disk image containing the application for a single processor only, you can override the UNIVERSAL_BINARY variable, setting it to empty:

UNIVERSAL_BINARY= make -C ../i386/ package