mozilla

Revision 345049 of Compiling 32-bit Firefox on a Linux 64-bit OS

  • Revision slug: Compiling_32-bit_Firefox_on_a_Linux_64-bit_OS
  • Revision title: Compiling 32-bit Firefox on a Linux 64-bit OS
  • Revision id: 345049
  • Created:
  • Creator: Roc
  • Is current revision? No
  • Comment

Revision Content

Instructions for Fedora

The following commands are a recipe to compile 32-bit Firefox on an x86-64 Fedora system. This is not technically cross-compiling, because the "target" binaries being produced will run on the native system; this means that a lot of the complexities of cross-compiling can be avoided.

Packages

The following extra packages must be installed (using sudo yum install packagename):

Package list for Fedora 17:

  • glibc-devel.i686
  • cairo-devel.i686
  • fontconfig-devel.i686
  • gtk2-devel.i686
  • dbus-glib-devel.i686
  • glib2-devel.i686
  • gdk-pixbuf2-devel.i686
  • pango-devel.i686
  • pixman-devel.i686
  • freetype-devel.i686
  • libpng-devel.i686
  • libXrender-devel.i686
  • libX11-devel.i686
  • libxcb-devel.i686
  • libXau-devel.i686
  • atk-devel.i686
  • libnotify-devel.i686
  • dbus-devel.i686
  • alsa-lib-devel.i686
  • libcurl-devel.i686
  • libIDL-devel.i686
  • libXt-devel.i686
  • libXext-devel.i686
  • glibc-static.i686
  • libstdc++-devel.i686
  • zlib-devel.i686

On Fedora 17, glib2-devel.i686 can't be installed cleanly alongside glib2-devel --- see Fedora bug. Downloading glib2-devel.i686 and installing it with "rpm -ivh --force glib2-devel.i686" seems to work, at least for building Firefox.

Configuration

To configure by hand in a bash-like shell, use the following command:

PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig CC="gcc -m32" CXX="g++ -m32" AR=ar ../mozilla/configure --x-libraries=/usr/lib --target=i686-pc-linux --other-options-here

To do the same thing with a mozconfig file:

export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
CC="gcc -m32"
CXX="g++ -m32"
AR=ar
ac_add_options --x-libraries=/usr/lib
ac_add_options --target=i686-pc-linux

For ubuntu 9, there is more work:

  1. export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
  2. export CROSS_COMPILE=1
  3. 32bit DEV package is name like lib32XXXX.dev, like lib32asound2-dev
  4. need to change 'ac_add_options --x-libraries=/usr/lib' to 'ac_add_options --x-libraries=/usr/lib32'.
  5. need to install  ia32-libs , gcc-multilib and g++-multilib package.

Instructions for Ubuntu

Method 1: True Cross-Compiling

This method is actually cross-compiling: you take a 64-bit toolchain and produce 32-bit binaries. This is ideally how you cross-compile.

  1. sudo apt-get install ia32-libs gcc-multilib g++-multilib lib32*
  2. (I had to open Synaptic afterwards, search for package names beginning with lib32, and install the ones that apt-get missed)
  3. Use a .mozconfig like below.
  4. make -f client.mk build
export CROSS_COMPILE=1
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-dbg32
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
ac_add_options --enable-application=browser

CC="gcc -m32"
CXX="g++ -m32"
AR=ar
ac_add_options --x-libraries=/usr/lib32
ac_add_options --target=i686-pc-linux

ac_add_options --disable-crashreporter # needed because I couldn't find a 32-bit curl-dev lib
ac_add_options --disable-libnotify     # needed because I couldn't find a 32-bit libinotify-dev
ac_add_options --disable-gnomevfs      # needed because I couldn't find a 32-bit libgnomevfs-dev

If you are getting an error as follows:

error: Can't find header fontconfig/fcfreetype.h

Add these configuration options to your .mozconfig:

ac_add_options --disable-freetypetest
ac_add_options --disable-pango

Method 2: Create a 32-bit chroot Environment

In this method, we effectively create a wholly-contained 32-bit operating system within a 64-bit operating system using schroot. This isn't technically cross-compiling, but it yields the same result: 32-bit binaries.

This method is arguably more reliable than true cross-compiling because the newly-created environment is completely isolated from the 64-bit operating system and it won't be susceptible to common issues with cross-compiling, such as unavailability of 32-bit libraries/packages when running in 64-bit mode. Additionally, since your 32-bit environment is completely isolated, to clean up from it, you just rm -rf the chroot directory. Contrast this with removing dozens of 32-bit packages from your primary operating system.

The downside to this method is size and complexity. Since you will be effectively creating a whole operating system within your primary operating system, there will be lots of redundant files. You'll probably need at least 1GB for all the new files. Additionally, the steps for initially creating the 32-bit environment are more involved.

To create a 32-bit chroot Ubuntu environment, follow the DebootstrapChroot instructions. Here is an example config file which works in Ubuntu 12.04:

# /etc/schroot/chroot.d/precise_i386

[precise_i386]
description=Ubuntu 12.04 for i386
directory=/srv/chroot/precise_i386
root-users=gps
type=directory
users=gps

Once you have changed the root-users and users entries to include your username and verified that $ schroot -c precise_i386 works, $ exit back to your regular operating system and copy your APT's sources list to the new environment:

$ sudo cp /etc/apt/sources.list /srv/chroot/precise_i386/etc/apt/sources.list

Note: this assumes a generic sources list. If you have modified this file yourself, you may wish to ensure the contents are accurate when you perform the copy.

The reason we copy the APT sources is because debootstrap does not appear to configure all the sources by default (it doesn't define the "sources" sources, for example).

Once your sources list is copied over, enter your new environment and configure things:

# Update the APT sources and install sudo into the new environment and exit back out
$ schroot -c precise_i386 -u root
(precise_i386) # apt-get update
(precise_i386) # apt-get install sudo
(precise_i386) # exit

# re-enter the environment as a regular user
$ schroot -c precise_i386

# Install Firefox build dependencies
$ sudo apt-get build-dep firefox

Now, your new 32-bit operating system should be ready for building Firefox!

One last step is ensuring that configure detects the proper system type. Since you are technically running on a 64-bit kernel, things could still be fooled.
 Run the following program from your mozilla source tree:

$ ./build/autoconf/config.guess

If this prints anything with x86_64, the system type is being incorrectly detected and you must override it. You can fix things by adding the following to your .mozconfig:

ac_add_options --host=i686-pc-linux-gnu
ac_add_options --target=i686-pc-linux-gnu

When you run configure ($ make -f client.mk configure), verify that the host, target, and build system types are what you just defined in your .mozconfig:

checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu

Now, follow the build instructions like normal and you should have 32-bit builds!

See Also

Revision Source

<h3 id="Instructions_for_Fedora">Instructions for Fedora</h3>
<p>The following commands are a recipe to compile 32-bit Firefox on an x86-64 Fedora system. This is not technically cross-compiling, because the "target" binaries being produced will run on the native system; this means that a lot of the complexities of cross-compiling can be avoided.</p>
<h4 id="Packages" name="Packages">Packages</h4>
<p>The following extra packages must be installed (using <code>sudo yum install <var>packagename</var></code>):</p>
<p>Package list for Fedora 17:</p>
<ul>
  <li>glibc-devel.i686</li>
  <li>cairo-devel.i686</li>
  <li>fontconfig-devel.i686</li>
  <li>gtk2-devel.i686</li>
  <li>dbus-glib-devel.i686</li>
  <li>glib2-devel.i686</li>
  <li>gdk-pixbuf2-devel.i686</li>
  <li>pango-devel.i686</li>
  <li>pixman-devel.i686</li>
  <li>freetype-devel.i686</li>
  <li>libpng-devel.i686</li>
  <li>libXrender-devel.i686</li>
  <li>libX11-devel.i686</li>
  <li>libxcb-devel.i686</li>
  <li>libXau-devel.i686</li>
  <li>atk-devel.i686</li>
  <li>libnotify-devel.i686</li>
  <li>dbus-devel.i686</li>
  <li>alsa-lib-devel.i686</li>
  <li>libcurl-devel.i686</li>
  <li>libIDL-devel.i686</li>
  <li>libXt-devel.i686</li>
  <li>libXext-devel.i686</li>
  <li>glibc-static.i686</li>
  <li>libstdc++-devel.i686</li>
  <li>zlib-devel.i686</li>
</ul>
<p>On Fedora 17, glib2-devel.i686 can't be installed cleanly alongside glib2-devel --- see <a href="https://bugzilla.redhat.com/show_bug.cgi?id=718404" title="https://bugzilla.redhat.com/show_bug.cgi?id=718404">Fedora bug</a>. Downloading glib2-devel.i686 and installing it with "rpm -ivh --force glib2-devel.i686" seems to work, at least for building Firefox.</p>
<h4 id="Configuration" name="Configuration">Configuration</h4>
<p>To configure by hand in a bash-like shell, use the following command:</p>
<p>PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig CC="gcc -m32" CXX="g++ -m32" AR=ar ../mozilla/configure --x-libraries=/usr/lib --target=i686-pc-linux <var>--other-options-here</var></p>
<p>To do the same thing with a mozconfig file:</p>
<pre>
export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
CC="gcc -m32"
CXX="g++ -m32"
AR=ar
ac_add_options --x-libraries=/usr/lib
ac_add_options --target=i686-pc-linux</pre>
<p>For ubuntu 9, there is more work:</p>
<ol>
  <li>export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig</li>
  <li>export CROSS_COMPILE=1</li>
  <li>32bit DEV package is name like lib32XXXX.dev, like lib32asound2-dev</li>
  <li>need to change 'ac_add_options --x-libraries=/usr/lib' to 'ac_add_options --x-libraries=/usr/lib32'.</li>
  <li>need to install&nbsp; ia32-libs , gcc-multilib and g++-multilib package.</li>
</ol>
<h3 id="Instructions_for_Ubuntu">Instructions for Ubuntu</h3>
<h4 id="Method_1.3A_True_Cross-Compiling">Method 1: True Cross-Compiling</h4>
<p>This method is actually cross-compiling: you take a 64-bit toolchain and produce 32-bit binaries. This is ideally how you cross-compile.</p>
<ol>
  <li><code>sudo apt-get install ia32-libs gcc-multilib g++-multilib lib32*</code></li>
  <li>(I&nbsp;had to open Synaptic afterwards, search for package names beginning with lib32, and install the ones that apt-get missed)</li>
  <li>Use a <code>.mozconfig</code> like below.</li>
  <li><code>make -f client.mk build</code></li>
</ol>
<pre>
export CROSS_COMPILE=1
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-dbg32
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
ac_add_options --enable-application=browser

CC="gcc -m32"
CXX="g++ -m32"
AR=ar
ac_add_options --x-libraries=/usr/lib32
ac_add_options --target=i686-pc-linux

ac_add_options --disable-crashreporter # needed because I&nbsp;couldn't find a 32-bit curl-dev lib
ac_add_options --disable-libnotify     # needed because I&nbsp;couldn't find a 32-bit libinotify-dev
ac_add_options --disable-gnomevfs      # needed because I&nbsp;couldn't find a 32-bit libgnomevfs-dev
</pre>
<p>If you are getting an error as follows:</p>
<pre>
error: Can't find header fontconfig/fcfreetype.h</pre>
<p>Add these configuration options to your <code>.mozconfig</code>:</p>
<pre>
ac_add_options --disable-freetypetest
ac_add_options --disable-pango</pre>
<h4 id="Method_2.3A_Create_a_32-bit_chroot_Environment">Method 2: Create a 32-bit chroot Environment</h4>
<p>In this method, we effectively create a wholly-contained 32-bit operating system within a 64-bit operating system using <code>schroot</code>. This isn't technically cross-compiling, but it yields the same result: 32-bit binaries.</p>
<p>This method is arguably more reliable than true cross-compiling because the newly-created environment is completely isolated from the 64-bit operating system and it won't be susceptible to common issues with cross-compiling, such as unavailability of 32-bit libraries/packages when running in 64-bit mode. Additionally, since your 32-bit environment is completely isolated, to clean up from it, you just <code>rm -rf</code> the chroot directory. Contrast this with removing dozens of 32-bit packages from your primary operating system.</p>
<p>The downside to this method is size and complexity. Since you will be effectively creating a whole operating system within your primary operating system, there will be lots of redundant files. You'll probably need at least 1GB for all the new files. Additionally, the steps for initially creating the 32-bit environment are more involved.</p>
<p>To create a 32-bit chroot Ubuntu environment, follow the <a class="link-https" href="https://help.ubuntu.com/community/DebootstrapChroot" title="https://help.ubuntu.com/community/DebootstrapChroot">DebootstrapChroot</a> instructions. Here is an example config file which works in Ubuntu 12.04:</p>
<pre>
# /etc/schroot/chroot.d/precise_i386

[precise_i386]
description=Ubuntu 12.04 for i386
directory=/srv/chroot/precise_i386
root-users=gps
type=directory
users=gps
</pre>
<p>Once you have changed the <code>root-users</code> and <code>users</code> entries to include your username and verified that <code>$ schroot -c precise_i386</code> works, <code>$ exit</code> back to your regular operating system and copy your APT's sources list to the new environment:</p>
<pre>
$ sudo cp /etc/apt/sources.list /srv/chroot/precise_i386/etc/apt/sources.list
</pre>
<p><strong>Note: this assumes a generic sources list. If you have modified this file yourself, you may wish to ensure the contents are accurate when you perform the copy.</strong></p>
<p>The reason we copy the APT sources is because <code>debootstrap </code>does not appear to configure all the sources by default (it doesn't define the "sources" sources, for example).</p>
<p>Once your sources list is copied over, enter your new environment and configure things:</p>
<pre>
# Update the APT sources and install sudo into the new environment and exit back out
$ schroot -c precise_i386 -u root
(precise_i386) # apt-get update
(precise_i386) # apt-get install sudo
(precise_i386) # exit

# re-enter the environment as a regular user
$ schroot -c precise_i386

# Install Firefox build dependencies
$ sudo apt-get build-dep firefox
</pre>
<p>Now, your new 32-bit operating system should be ready for building Firefox!</p>
<p>One last step is ensuring that <code>configure </code>detects the proper system type. Since you are technically running on a 64-bit kernel, things could still be fooled.<br />
  &nbsp;Run the following program from your mozilla source tree:</p>
<pre>
$ ./build/autoconf/config.guess
</pre>
<p><strong>If this prints anything with <code>x86_64</code>, the system type is being incorrectly detected and you must override it.</strong> You can fix things by adding the following to your <code>.mozconfig</code>:</p>
<pre>
ac_add_options --host=i686-pc-linux-gnu
ac_add_options --target=i686-pc-linux-gnu
</pre>
<p>When you run configure (<code>$ make -f client.mk configure</code>), verify that the host, target, and build system types are what you just defined in your <code>.mozconfig</code>:</p>
<pre>
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
</pre>
<p>Now, follow the <a href="/En/Developer_Guide/Build_Instructions" title="Build Instructions">build instructions</a> like normal and you should have 32-bit builds!</p>
<h3 id="See_Also" name="See_Also">See Also</h3>
<ul>
  <li><a href="/en/Cross-Compiling_Mozilla" title="en/Cross-Compiling_Mozilla">Cross-Compiling Mozilla</a></li>
</ul>
Revert to this revision