1FROM ubuntu:17.10
2
3RUN apt-get update && apt-get install -y --no-install-recommends \
4  gcc make libc6-dev git curl ca-certificates \
5  gcc-aarch64-linux-gnu qemu-user
6RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \
7    tar xzf - && \
8    cd musl-1.1.19 && \
9    CC=aarch64-linux-gnu-gcc \
10    ./configure --prefix=/musl-aarch64 --enable-wrapper=yes && \
11    make install -j4 && \
12    cd .. && \
13    rm -rf musl-1.1.19
14# Install linux kernel headers sanitized for use with musl
15RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \
16    tar xzf - && \
17    cd kernel-headers-3.12.6-6 && \
18    make ARCH=arm64 prefix=/musl-aarch64 install -j4 && \
19    cd .. && \
20    rm -rf kernel-headers-3.12.6-6
21
22# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
23ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \
24    CC_aarch64_unknown_linux_musl=musl-gcc \
25    RUSTFLAGS='-Clink-args=-lgcc' \
26    CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \
27    CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-aarch64 -L /musl-aarch64"
28