The following commands are a recipe bsmedberg uses to compile 32-bit Firefox on an x86-64 Fedora Core 7 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):
- fontconfig-devel.i386 - Unfortunately,
yumrefuses to install this package at the same time as fontconfig-devel.x86_64 - I had to download the RPM and install it manually using
rpm -i --replacefiles fontconfig-devel-2.4.2-3.fc7.i386.rpm
The list of additional packages given above requires modifications for Fedora 8:
- xorg-x11-proto-devel.i386 is no longer present in Fedora 8. The .noarch RPM package is used instead, and it should have been automatically installed. This RPM package (xorg-x11-proto-devel.noarch) has pkg-config files in a different location (/usr/share/pkgconfig).
- popt-devel.386 - Unfortunately,
yumrefuses to install this package at the same time as popt-devel.x86_64 - I had to download the RPM and install it manually using
rpm -i --replacefiles popt-devel-1.12-3.fc8.i386.rpm
- dbus-glib-devel.i386 may also need to be installed
Package list for Fedora 12:
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 CC="gcc -m32" CXX="g++ -m32" AR=ar ac_add_options --x-libraries=/usr/lib ac_add_options --target=i686-pc-linux
For Fedora 8 it is necessary to add /usr/share/pkgconfig to PKG_CONFIG_LIBDIR:
For ubuntu 9, it is also necessary to add /usr/share/pkgconfig to PKG_CONFIG_LIBDIR, and few 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 section is maintained for historical reference; it might not work for more recent versions of Ubuntu. It was last tested in Ubuntu 10.10") }}
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 mozconfig like below.
- make -f client.mk build
export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig 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
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 chroot. 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 tree. 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 1 or 2 GB for all the 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. When you have entered your newly-created environment with
schroot, follow the regular build instructions to set up your build environment.