Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

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:

  • Compiled executable code for two architectures, such as:
    • the main executable (for example, firefox-bin)
    • shared libraries and binary plugins (for example, libxpcom.dylib)
  • A single copy of all other non-executable files, including:
    • application resources (for example, browser.jar)
    • localization packages (for example, en-US.jar)

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 Mac OS X 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

Document Tags and Contributors

 Last updated by: Dglazman,