This is a really short tutorial for cross compiling Servo to ARM and AArch64. For a more detailed guide, see my previous post.

Changelog:

  • 2016 Aug 2: added libavformat-dev to the dependecies
  • 2016 May 2: small updates
  • 2016 Feb 2: original version

ARM

Preparations

Get the compiler:

sudo apt-get install g++-arm-linux-gnueabihf

You will need the ARM system libs, either copy it from real hardware, or:

sudo qemu-debootstrap --arch=armhf --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg --verbose wily rootfs-wily-armhf

sudo chroot rootfs-wily-armhf \
    sudo apt-get install curl freeglut3-dev autoconf \
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \
    gperf g++ build-essential cmake python \
    libssl-dev libbz2-dev libosmesa6-dev libxmu6 libxmu-dev \
    libglu1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev \
    libavformat-dev

# Take a coffee

# In case you want to save your libs:
# tar czfv armhf-wily-libs.tgz -C rootfs-wily-armhf usr/include/arm-linux-gnueabihf lib/arm-linux-gnueabihf usr/lib/arm-linux-gnueabihf

sudo ln -s $(pwd)/rootfs-wily-armhf/usr/include/arm-linux-gnueabihf /usr/include/arm-linux-gnueabihf
sudo ln -s $(pwd)/rootfs-wily-armhf/usr/lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf
sudo ln -s $(pwd)/rootfs-wily-armhf/lib/arm-linux-gnueabihf /lib/arm-linux-gnueabihf

I’m on Ubuntu 15.10 (Wily), so I’m using wily for debootstrap too. I guess you might have more luck if they match. You can find qemu-debootstrap in qemu-user-static.

Some dependencies search for the compiler with the -unknown- vendor tag (eg. arm-unknown-linux-gnueabihf instead of arm-linux-gnueabihf), here is a quick fix for that:

mkdir -p $HOME/bin
for f in /usr/bin/arm-linux-*; do f2=$(basename $f); ln -s $f $HOME/bin/${f2/-linux/-unknown-linux}; done
PATH="$PATH:$HOME/bin"

Building Servo

git clone https://github.com/servo/servo.git
cd servo

UPDATE: This step is no longer needed. The Rust stdlibs for ARM and AArch64 aren’t downloaded automatically, here’s fix for that:

sed -i "s/stdlibs = \[host_triple(), \"arm-linux-androideabi\"\]/stdlibs = set(\[host_triple(), \"arm-linux-androideabi\", \"arm-unknown-linux-gnueabihf\", \"aarch64-unknown-linux-gnu\"\])/" python/servo/bootstrap_commands.py

Now you can build:

CC=arm-linux-gnueabihf-gcc \
CXX=arm-linux-gnueabihf-g++ \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig \
./mach build -r --target=arm-unknown-linux-gnueabihf

In case you get errors, delete your build (./mach clean), and add the following environment variables to the build command: EXPAT_NO_PKG_CONFIG=1 FREETYPE2_NO_PKG_CONFIG=1 FONTCONFIG_NO_PKG_CONFIG=1

AArch64

Yes, this will be mostly the same.

Preparations

Get the compiler:

sudo apt-get install g++-aarch64-linux-gnu

You will need the ARM64 system libs, either copy it from real hardware, or:

sudo qemu-debootstrap --arch=arm64 --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg --verbose wily rootfs-wily-arm64

sudo chroot rootfs-wily-arm64 \
    sudo apt-get install curl freeglut3-dev autoconf \
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \
    gperf g++ build-essential cmake python \
    libssl-dev libbz2-dev libosmesa6-dev libxmu6 libxmu-dev \
    libglu1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev \
    libavformat-dev

# Coffee break!

# In case you want to save your libs:
# tar czfv arm64-wily-libs.tgz -C rootfs-wily-arm64 usr/include/aarch64-linux-gnu lib/aarch64-linux-gnu usr/lib/aarch64-linux-gnu

sudo ln -s $(pwd)/rootfs-wily-arm64/usr/include/aarch64-linux-gnu /usr/include/aarch64-linux-gnu
sudo ln -s $(pwd)/rootfs-wily-arm64/usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu
sudo ln -s $(pwd)/rootfs-wily-arm64/lib/aarch64-linux-gnu /lib/aarch64-linux-gnu

I’m on Ubuntu 15.10 (Wily), so I’m using wily for debootstrap too. I guess you might have more luck if they match. You can find qemu-debootstrap in qemu-user-static.

Some dependencies search for the compiler with the -unknown- vendor tag (eg. arm-unknown-linux-gnueabihf instead of arm-linux-gnueabihf), here is a quick fix for that:

mkdir -p $HOME/bin
for f in /usr/bin/aarch64-linux-*; do f2=$(basename $f); ln -s $f $HOME/bin/${f2/-linux/-unknown-linux}; done
PATH="$PATH:$HOME/bin"

Building Servo

git clone https://github.com/servo/servo.git
cd servo

UPDATE: This step is no longer needed. The Rust stdlibs for ARM and AArch64 aren’t downloaded automatically, here’s fix for that:

sed -i "s/stdlibs = \[host_triple(), \"arm-linux-androideabi\"\]/stdlibs = set(\[host_triple(), \"arm-linux-androideabi\", \"arm-unknown-linux-gnueabihf\", \"aarch64-unknown-linux-gnu\"\])/" python/servo/bootstrap_commands.py

Now you can build:

CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig \
./mach build -r --target=aarch64-unknown-linux-gnu

In case you get errors, delete your build (./mach clean), and add the following environment variables to the build command: EXPAT_NO_PKG_CONFIG=1 FREETYPE2_NO_PKG_CONFIG=1 FONTCONFIG_NO_PKG_CONFIG=1