1FROM ubuntu:16.10
2
3RUN dpkg --add-architecture i386
4RUN apt-get update
5RUN apt-get install -y --no-install-recommends \
6  gcc-multilib make libc6-dev git curl ca-certificates libc6:i386
7# Below we're cross-compiling musl for i686 using the system compiler on an
8# x86_64 system. This is an awkward thing to be doing and so we have to jump
9# through a couple hoops to get musl to be happy. In particular:
10#
11# * We specifically pass -m32 in CFLAGS and override CC when running ./configure,
12#   since otherwise the script will fail to find a compiler.
13# * We manually unset CROSS_COMPILE when running make; otherwise the makefile
14#   will call the non-existent binary 'i686-ar'.
15RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \
16    tar xzf - && \
17    cd musl-1.1.15 && \
18    CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \
19    make CROSS_COMPILE= install -j4 && \
20    cd .. && \
21    rm -rf musl-1.1.15
22ENV PATH=$PATH:/musl-i686/bin:/rust/bin \
23    CC_i686_unknown_linux_musl=musl-gcc
24