]> git.lizzy.rs Git - rust.git/commitdiff
Add a Docker container for doing automated builds for CloudABI.
authorEd Schouten <ed@nuxi.nl>
Sun, 14 Jan 2018 17:37:52 +0000 (18:37 +0100)
committerEd Schouten <ed@nuxi.nl>
Tue, 16 Jan 2018 19:31:09 +0000 (20:31 +0100)
Setting up a cross compilation toolchain for CloudABI is relatively
easy. It's just a matter of installing a somewhat recent version of
Clang (5.0 preferred) and installing the corresponding
${target}-cxx-runtime package, containing a set of core C/C++ libraries
(libc, libc++, libunwind, etc).

Eventually it would be nice if we could also run 'x.py test'. That,
however still requires some more work. Both libtest and compiletest
would need to be adjusted to deal with CloudABI's requirement of having
all of an application's dependencies injected. Let's settle for just
doing 'x.py dist' for now.

.travis.yml
src/ci/docker/dist-cloudabi/Dockerfile [new file with mode: 0644]
src/ci/docker/scripts/cloudabi-toolchain.sh [new file with mode: 0755]

index 6e242b74894c5dd66715f904683287ba94338b69..1642a39955293a57f6f26abbbb2bef2e531f3fb6 100644 (file)
@@ -126,6 +126,8 @@ matrix:
       if: branch = auto
     - env: IMAGE=dist-armv7-linux DEPLOY=1
       if: branch = auto
+    - env: IMAGE=dist-cloudabi DEPLOY=1
+      if: branch = auto
     - env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1
       if: branch = auto
     - env: IMAGE=dist-i686-freebsd DEPLOY=1
diff --git a/src/ci/docker/dist-cloudabi/Dockerfile b/src/ci/docker/dist-cloudabi/Dockerfile
new file mode 100644 (file)
index 0000000..f1f6f0f
--- /dev/null
@@ -0,0 +1,30 @@
+FROM ubuntu:17.10
+
+ENV TARGETS=aarch64-unknown-cloudabi
+# FIXME(EdSchouten): Enable ARMv7 support once libc ≥0.2.37 has been merged.
+# ENV TARGETS=armv7-unknown-cloudabi-eabihf
+ENV TARGETS=$TARGETS,i686-unknown-cloudabi
+ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi
+
+COPY scripts/cloudabi-toolchain.sh /tmp/
+RUN /tmp/cloudabi-toolchain.sh
+
+COPY scripts/sccache.sh /scripts/
+RUN sh /scripts/sccache.sh
+
+# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can
+# automatically pick the right compiler path.
+ENV \
+    AR_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-ar \
+    CC_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang \
+    CXX_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang++ \
+    AR_i686_unknown_cloudabi=i686-unknown-cloudabi-ar \
+    CC_i686_unknown_cloudabi=i686-unknown-cloudabi-clang \
+    CXX_i686_unknown_cloudabi=i686-unknown-cloudabi-clang++ \
+    AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \
+    CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \
+    CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++
+
+# FIXME(EdSchouten): Work towards being able to run 'x.py test'.
+ENV RUST_CONFIGURE_ARGS --target=${TARGETS} --disable-jemalloc
+ENV SCRIPT python2.7 /checkout/x.py dist --target ${TARGETS}
diff --git a/src/ci/docker/scripts/cloudabi-toolchain.sh b/src/ci/docker/scripts/cloudabi-toolchain.sh
new file mode 100755 (executable)
index 0000000..5d6ecb4
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+set -eux
+
+# Install prerequisites.
+apt-get update
+apt-get install -y --no-install-recommends \
+  apt-transport-https \
+  ca-certificates \
+  clang-5.0 \
+  cmake \
+  curl \
+  file \
+  g++ \
+  gdb \
+  git \
+  lld-5.0 \
+  make \
+  python \
+  sudo \
+  xz-utils
+
+# Set up a Clang-based cross compiler toolchain.
+# Based on the steps described at https://nuxi.nl/cloudabi/debian/
+IFS=,
+for target in ${TARGETS}; do
+  for tool in ar nm objdump ranlib size; do
+    ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool}
+  done
+  ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc
+  ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++
+  ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld
+  ln -s ../../${target} /usr/lib/llvm-5.0/${target}
+
+  # FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It
+  # can make use of ${target}-cc and ${target}-c++, without incorrectly
+  # assuming it's MSVC.
+  ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang
+  ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang++
+done
+
+# Install the C++ runtime libraries from CloudABI Ports.
+echo deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi > \
+    /etc/apt/sources.list.d/cloudabi.list
+curl 'https://pgp.mit.edu/pks/lookup?op=get&search=0x0DA51B8531344B15' | \
+    apt-key add -
+apt-get update
+for target in ${TARGETS}; do
+  apt-get install -y $(echo ${target} | sed -e s/_/-/g)-cxx-runtime
+done