Cross Compiling Firefox on ubuntu the multiarch way

Preparing multiarch chroot

For testing, you will want a oneiric chroot.

sudo debootstrap --variant=buildd oneiric /srv/oneiric
sudo chroot /srv/oneiric/
mount -t proc proc /proc

Set up the /etc/apt/sources.list inside the chroot :

# use arch=i386 if you have 32bit Linux install
deb [arch=amd64] http://archive.ubuntu.com/ubuntu oneiric main universe
deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports oneiric main universe
deb-src http://archive.ubuntu.com/ubuntu oneiric main universe

We need some packages not yet in oneiric, so we create /etc/apt/sources.list.d/linaro-maintainers.list

deb http://ppa.launchpad.net/linaro-maintainers/overlay/ubuntu oneiric main
deb-src http://ppa.launchpad.net/linaro-maintainers/overlay/ubuntu oneiric main
deb http://ppa.launchpad.net/linaro-maintainers/staging-overlay/ubuntu oneiric main
deb-src http://ppa.launchpad.net/linaro-maintainers/staging-overlay/ubuntu oneiric main

Enable multiarch for dpkg in in /etc/dpkg/dpkg.cfg.d/multiarch

foreign-architecture armel

In /etc/apt/apt.conf.d/10local disable installing recommends:

APT::Install-Recommends "0";
APT::Install-Suggests "0";

Install toolchain and essentials

apt-get update
apt-get install g++-arm-linux-gnueabi build-essential

Drag in build-dependencies for firefox

Ideally, we would just:

apt-get build-dep -aarmel firefox

But this doesn't work yet. So we walk through firefox build dependencies by hand, and split them to ones we want for armel (DEB_HOST_ARCHITECTURE) and ones we want for x86/amd64 (DEB_BUILD_ARCHITECTURE). Thumb of rule is that anything with -dev and/or multi-arch: same goes for armel and ones with multi-arch: foreign go with build machine architecture.

apt-get install libx11-dev:armel libxt-dev:armel libgtk2.0-dev:armel liborbit2-dev:armel libidl-dev:armel libxft-dev:armel libfreetype6-dev:armel libxrender-dev:armel libxinerama-dev:armel libgnome2-dev:armel libgconf2-dev:armel libgnomeui-dev:armel libstartup-notification0-dev:armel libasound2-dev:armel libcurl4-openssl-dev:armel libdbus-glib-1-dev:armel libiw-dev:armel mesa-common-dev:armel libnotify-dev:armel libgnomevfs2-dev:armel libdbusmenu-gtk-dev:armel

apt-get install cdbs debhelper m4 autotools-dev autoconf2.13 quilt patchutils bzip2 zip mozilla-devscripts hardening-wrapper lsb-release yasm xvfb imagemagick libidl-dev libglib2.0-dev

As you notice, some packages (libidl-dev libglib2.0-dev) are needed for both host and build environment. This is because firefox builds some tools it uses during build time.

Finally, we need to create a symlink for pkg-config:

cd /usr/bin
ln -s /usr/share/pkg-config-crosswrapper arm-linux-gnueabi-pkg-config

Proceeding to build

Finally something simple:

apt-get source firefox=8.0+build1-0ubuntu0.11.10.3linaro1
cd firefox*
dpkg-buildpackage -aarmel 2>&1|tee ../firefox.log

Work in progress

  • Cross-toolchain still doesn't search multiarch paths. These were hacked in for this demo into debian/rules
  • pkg-config wrapper symlink should come with cross-toolchain
  • apt-get build-dep should work for cross-arch


CategoryCrossCompile

Platform/DevPlatform/CrossCompile/FirefoxCrossCompile (last modified 2012-02-09 19:53:02)