Instructions for Fedora 19
First ensure that your compiler toolchain is installed.
sudo yum install \ ccache cmake gcc gcc-c++ \ glibc-devel glibc-devel.i686 \ libstdc++-devel libstdc++-devel.i686
Next, install the Gecko build depedencies.
sudo yum install \ autoconf213 \ gtk2-devel.i686 gtk+-devel.i686 gtk+extra-devel.i686 \ glib-devel.i686 glib2-devel.i686 \ dbus-devel.i686 dbus-glib-devel.i686 \ alsa-lib-devel.i686 yasm-devel.i686 \ gstreamer-devel.i686 gstreamer-plugins-devel.i686 \ gstreamer-plugins-base-devel.i686 \ libxml2-devel.i686 zlib-devel.i686 \ freetype-devel.i686 \ atk-devel.i686 pango-devel.i686 fontconfig-devel.i686 \ cairo-devel.i686 gdk-pixbuf2-devel.i686 \ libX11-devel.i686 libXt-devel.i686 libXext-devel.i686 \ libXrender-devel.i686 libXau-devel.i686 libxcb-devel.i686
Finally, you need to use a .mozconfig that looks like the following example.
# Flags set for targeting x86. export CROSS_COMPILE=1 export PKG_CONFIG_PATH=/usr/lib/pkgconfig CC="ccache gcc -m32" CXX="ccache g++ -m32" AR=ar ac_add_options --target=i686-pc-linux # Normal build flags. These make a debug browser build. ac_add_options --enable-application=browser mk_add_options MOZ_MAKE_FLAGS="-s -j6" mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../ff-dbg ac_add_options --enable-debug ac_add_options --disable-optimize
Instructions for Fedora 17
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.
The following extra packages must be installed (using
sudo yum install packagename):
Package list for Fedora 17:
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.
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:
- export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
- export CROSS_COMPILE=1
- 32bit DEV package is name like lib32XXXX.dev, like lib32asound2-dev
- need to change 'ac_add_options --x-libraries=/usr/lib' to 'ac_add_options --x-libraries=/usr/lib32'.
- 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.
sudo apt-get install ia32-libs gcc-multilib g++-multilib lib32*
- (I had to open Synaptic afterwards, search for package names beginning with lib32, and install the ones that apt-get missed)
- Use a
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
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
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:
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
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
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!