mozilla

Revision 94602 of Mac OS X Universal Binaries

  • Revision slug: Mac_OS_X_Universal_Binaries
  • Revision title: Mac OS X Universal Binaries
  • Revision id: 94602
  • Created:
  • Creator: Josh
  • Is current revision? No
  • Comment 9 words added, 440 words removed

Revision Content

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.

{{ :en/Build_Documentation/TOC() }}

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@/../build
ac_add_options --disable-tests

In this example, the objdir is placed adjacent to the mozilla directory, in a directory called build.

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:

make -C ../build/i386/ package

The disk image will be produced in ../build/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 ../build/i386/ package

{{ languages( { "ja": "ja/Mac_OS_X_Universal_Binaries" } ) }}

Revision Source

<p><span class="comment">NOTE: substantive changes to this page (non-editorial) should be reviewed by one of the build-config peers</span></p>
<p>It is possible to build Mozilla applications as a <a class="external" href="http://developer.apple.com/transition/">universal binary</a> that runs natively on multiple architectures. Universal binaries contain:</p>
<ul> <li>Compiled executable code for two architectures, such as: <ul> <li>the main executable (for example, <code>firefox-bin</code>)</li> <li>shared libraries and binary plugins (for example, <code>libxpcom.dylib</code>)</li> </ul> </li> <li>A single copy of all other non-executable files, including: <ul> <li>application resources (for example, <code>browser.jar</code>)</li> <li>localization packages (for example, <code>en-US.jar</code>)</li> </ul> </li>
</ul>
<p>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.</p>
<p>{{ :en/Build_Documentation/TOC() }}</p>
<h3 name="Prerequisites">Prerequisites</h3>
<p>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 <a href="/En/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites" title="En/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites">Mac OS X build prerequisites</a> 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.</p>
<h3 name="Configuration">Configuration</h3>
<p>This section describes how to check out the necessary files and configure Mozilla to build as a universal binary.</p>
<h4 name="Your_.mozconfig_File">Your .mozconfig File</h4>
<p>When preparing your own <code><a href="/en/Configuring_Build_Options" title="en/Configuring_Build_Options">.mozconfig</a></code> file, you must source the <code>$topsrcdir/build/macosx/universal/mozconfig</code> config fragment . It should be sourced after any product-specific <code>mozconfig</code>, in case it needs to override any options.</p>
<p>Universal binaries must be built as <a href="/en/Configuring_Build_Options#Building_with_an_Objdir" title="en/Configuring_Build_Options#Building_with_an_Objdir">objdir builds</a>, so <code>MOZ_OBJDIR</code> must be set. The location of your objdir is unimportant, so long as you provide one.</p>
<p>Here is a sample <code>.mozconfig</code> suitable for building a universal binary of Firefox in a release configuration:</p>
<pre class="eval">. $topsrcdir/browser/config/mozconfig
. $topsrcdir/build/macosx/universal/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../build
ac_add_options --disable-tests
</pre>
<p>In this example, the objdir is placed adjacent to the <code>mozilla</code> directory, in a directory called <code>build</code>.</p>
<h4>Building</h4>
<p>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.</p>
<h4 name="Results_of_a_Build">Results of a Build</h4>
<p>Two subdirectories are created in your objdir, one for each architecture (<code>ppc</code>, <code>i386</code>, or <code>x86_64</code>). Each of these directories contains a complete processor-specific build. The merged universal binary is placed in both build directories, one via symlink, at <code>dist/universal</code>.</p>
<h4 name="Packaging">Packaging</h4>
<p>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 <a href="#Your_.mozconfig_File">sample <code>.mozconfig</code></a> above, you would build a universal disk image of Firefox by typing:</p>
<pre class="eval">make -C ../build/i386/ package
</pre>
<p>The disk image will be produced in <code>../build/i386/dist</code>. You could just as easily substitute another architecture for <code>i386</code>, this only affects the location that the disk image is produced in.</p>
<p>To bypass universal packaging, and create a disk image containing the application for a single processor only, you can override the <code>UNIVERSAL_BINARY</code> variable, setting it to empty:</p>
<pre class="eval">UNIVERSAL_BINARY= make -C ../build/i386/ package
</pre>
<p>{{ languages( { "ja": "ja/Mac_OS_X_Universal_Binaries" } ) }}</p>
Revert to this revision