Cross Compiling Chromium on Ubuntu - the multiarch way

This document demonstrates howto cross-build chromium-browser using multiarch libraries.

Preparing the multiarch chroot

For testing, you will want a 32bit oneiric chroot. (chromium needs 32bit host to cross-compile to arm).

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

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

deb [arch=i386] 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

Import the public key of the Overlay, to avoid the GPG error while accessing the PPA:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7BE1F97B

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";

Create a /usr/sbin/policy-rc.d file to prevent daemons to start in the chroot

echo "exit 101" > /usr/sbin/policy-rc.d
chmod a+x /usr/sbin/policy-rc.d

Install toolchain and essentials

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

Drag in build-dependencies for chromium

Ideally, we would just: apt-get build-dep -aarmel chromium-browser

But this doesn't work yet. So we walk through chromium-browser 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 cdbs debhelper pkg-config lsb-release lzma quilt patchutils hardening-wrapper python bison flex gperf python-simplejson shared-mime-info

apt-get install libjpeg-dev:armel libpng12-dev:armel libbz2-dev:armel zlib1g-dev:armel libxml2-dev:armel libxslt1-dev:armel lzma-dev:armel libpulse-dev:armel libcups2-dev:armel libhunspell-dev:armel libsqlite3-dev:armel libasound2-dev:armel libnss3-dev:armel libnspr4-dev:armel libpam0g-dev:armel libgl1-mesa-dri:armel mesa-common-dev:armel libgl1-mesa-dev:armel libglu1-mesa-dev:armel libgles2-mesa-dev:armel libxt-dev:armel libxtst-dev:armel libxss-dev:armel libpango1.0-dev:armel libglib2.0-dev:armel libgtk2.0-dev:armel libdbus-glib-1-dev:armel libgnome-keyring-dev:armel libgconf2-dev:armel libvpx-dev:armel

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

Pull the patched chromium sources from linaro-maintainers overlay:

apt-get source chromium-browser=15.0.874.120~r108895-0ubuntu1linaro2
cd chromium*

And proceed to build:

unset LANG LANGUAGE
dpkg-buildpackage -b -B -aarmel 2>&1|tee ../chromium-browser.log

On my i5 M520, build time was 45min - compared to the native build on ubuntu buildd, which was 1 day 3 hours.

Work in progress

  • There is a runaway char in: /var/lib/dpkg/info/libglib2.0-0:armel.postinst - edit it to fix it for now
  • 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/ChromiumCrossCompile (last modified 2011-12-09 08:13:35)