While Servo supports Android for a while now, it turned out cross compiling to ARM devices requires some additional work. Now that most of these patches have landed, it is possible to build for ARM with just some minor tweaks.
UPDATE: This tutorial has also been posted here: http://browser.sed.hu/blog/20150717/cross-compiling-servo-arm. Please visit that site if you wish to leave comments.
UPDATE 2: Most of the patches have landed, post updated.
UPDATE 3: The linker issue is now fixed (but, unfortunately there is an issue with the latest Skia).
UPDATE 4: Looks like the Skia issue was fixed, but another appeared in
libexpat. Fortunately, there is a clean workaround for that.
Last update: 2015, Nov 2
For reference, in this post I’m going to use Servo at commit 73b52c0, which requires Rust version
2d0cbf3e3e25e092bd9e4c94d08e446b680869f0. You will need the Rust standart library of this particular version, compiled to ARM. The required version is stored in the file
Unfortunately, you will probably have to build that yourself too, as ARM libs are not distributed with Rust yet. The first part of the on-board building guide describes how to do it. UPDATE: Now you should also be able to compile it by simply setting the appropriate
You will also need the ARM system libraries, but you can copy them either from the system running on your board or from a downloaded distribution installer, eg. a Raspbian image.
Setting up a rootfs
First, I’m going to set up an Ubuntu 14.04 rootfs to build in a clean environment. You can safely skip this step (just don’t forget to change the paths later).
Then, add a new user inside the roots (again, you can skip this):
All right, let’s install the ARM compiler. There are many kinds of toolchains (eg. optimized for a certain board, like the Raspberry Pi), but the default one is fine for me:
Install the Servo dependencies (copied from the README):
python-virtualenv is not found, install it like this:
Oh, and we will also need git:
Finally, download Servo, but leave it alone for now:
UPDATE: Most dependencies work correctly now
What you still have to do, is setting up the build system:
We will need to install the Rust standart libraries for ARM if we want to cross compile programs written in Rust. Let’s exit from the rootfs for a minute:
and copy your ARM Rust libraries to the correct location:
Note: Your target directory might have a different Rust hash/version.
Note: In case you’ve skipped the preface, you have to build the Rust standard libraries of the version used by Servo for ARM
If you skip this step, you will get
std-related errors when compiling Rust code
We will also need to install the ARM system libraries if we don’t want to get linker errors later:
If you are not working in a rootfs, just remove the
rootfs-trusty part of the commands.
We’re done with the libraries, let’s go back into the rootfs:
There are two ‘missing header’ errors, for OpenSSL and Zlib. Apparently this is a packaging issue on certain distros. Anyway, you can fix it like this:
Finally! If you’ve followed the previous steps correctly, running
should build servo correctly, and you can find it at
Servo still has some visual (X11 and OpenGL) problems on embedded Linux, whether you build on board or cross compile.