aboutsummaryrefslogtreecommitdiff
path: root/libc/ci/docker/wasm32-wasi/Dockerfile
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-05-24 18:07:22 -0700
committerDaniel Mueller <deso@posteo.net>2019-05-24 18:07:22 -0700
commit82cf43dd887801b8b22b8aae8c02854d921915d5 (patch)
treeb1bf3710bd07fe83e396a5db8563f3e6c5e85689 /libc/ci/docker/wasm32-wasi/Dockerfile
parent06722702ea35434189d7de2b13a00209b2ebbd6d (diff)
downloadnitrocli-82cf43dd887801b8b22b8aae8c02854d921915d5.tar.gz
nitrocli-82cf43dd887801b8b22b8aae8c02854d921915d5.tar.bz2
Update libc crate to 0.2.55
This change updates the libc crate to version 0.2.55. Import subrepo libc/:libc at caf17a0641d29dc624621177f5756804dd180c13
Diffstat (limited to 'libc/ci/docker/wasm32-wasi/Dockerfile')
-rw-r--r--libc/ci/docker/wasm32-wasi/Dockerfile93
1 files changed, 93 insertions, 0 deletions
diff --git a/libc/ci/docker/wasm32-wasi/Dockerfile b/libc/ci/docker/wasm32-wasi/Dockerfile
new file mode 100644
index 0000000..d963a44
--- /dev/null
+++ b/libc/ci/docker/wasm32-wasi/Dockerfile
@@ -0,0 +1,93 @@
+# In the first container we want to assemble the `wasi-sysroot` by compiling it
+# from source. This requires a clang 8.0+ compiler with enough wasm support and
+# then we're just running a standard `make` inside of what we clone.
+FROM ubuntu:18.04 as wasi-sysroot
+
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ ca-certificates \
+ clang \
+ cmake \
+ curl \
+ g++ \
+ git \
+ libc6-dev \
+ libclang-dev \
+ make \
+ ssh \
+ xz-utils
+
+# Fetch clang 8.0+ which is used to compile the wasi target and link our
+# programs together.
+RUN curl http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | tar xJf -
+RUN mv /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 /wasmcc
+
+# Note that we're using `git reset --hard` to pin to a specific commit for
+# verification for now. The sysroot is currently in somewhat of a state of flux
+# and is expected to have breaking changes, so this is an attempt to mitigate
+# those breaking changes on `libc`'s own CI
+RUN git clone https://github.com/CraneStation/wasi-sysroot && \
+ cd wasi-sysroot && \
+ git reset --hard eee6ee7566e26f2535eb6088c8494a112ff423b9
+RUN make -C wasi-sysroot install -j $(nproc) WASM_CC=/wasmcc/bin/clang INSTALL_DIR=/wasi-sysroot
+
+# This is a small wrapper script which executes the actual clang binary in
+# `/wasmcc` and then is sure to pass the right `--sysroot` argument which we
+# just built above.
+COPY docker/wasm32-wasi/clang.sh /wasi-sysroot/bin/clang
+
+# In the second container we're going to build the `wasmtime` binary which is
+# used to execute wasi executables. This is a standard Rust project so we're
+# just checking out a known revision (which pairs with the sysroot one we
+# downlaoded above) and then we're building it with Cargo
+FROM ubuntu:18.04 as wasmtime
+
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ ca-certificates \
+ clang \
+ cmake \
+ curl \
+ g++ \
+ git \
+ libclang-dev \
+ make \
+ ssh
+
+RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
+ENV PATH=/root/.cargo/bin:$PATH
+
+RUN apt-get install -y --no-install-recommends python
+RUN git clone --recursive https://github.com/CraneStation/wasmtime wasmtime && \
+ cd wasmtime && \
+ git reset --hard 67edb00f29b62864b00179fe4bfa99bc29973285
+RUN cargo build --release --manifest-path wasmtime/Cargo.toml
+
+# And finally in the last image we're going to assemble everything together.
+# We'll install things needed at runtime for now and then copy over the
+# sysroot/wasmtime artifacts into their final location.
+FROM ubuntu:18.04
+
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ gcc \
+ libc6-dev \
+ libxml2 \
+ ca-certificates
+
+# Copy over clang we downloaded to link executables ...
+COPY --from=wasi-sysroot /wasmcc /wasmcc/
+# ... and the sysroot we built to link executables against ...
+COPY --from=wasi-sysroot /wasi-sysroot/ /wasi-sysroot/
+# ... and finally wasmtime to actually execute binaries
+COPY --from=wasmtime /wasmtime/target/release/wasmtime /usr/bin/
+
+# Of note here is our clang wrapper which just executes a normal clang
+# executable with the right sysroot, and then we're sure to turn off the
+# crt-static feature to ensure that the CRT that we're specifying with `clang`
+# is used.
+ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
+ CARGO_TARGET_WASM32_WASI_LINKER=/wasi-sysroot/bin/clang \
+ CC_wasm32_wasi=/wasi-sysroot/bin/clang \
+ PATH=$PATH:/rust/bin \
+ RUSTFLAGS=-Ctarget-feature=-crt-static