diff options
| author | bors <bors@rust-lang.org> | 2019-01-15 04:06:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-15 04:06:25 +0000 |
| commit | 33e6df4b62237af312bf6e3f40a97f5bdc94949a (patch) | |
| tree | a8cd44217ba1afaaa007bbc38b9e77e9632202b5 /src/ci | |
| parent | aea9f0aa976db2f5de28be3b6b287c6889cd926b (diff) | |
| parent | 99fbd1bf110c1e62c0c22a0e2232bec4bf9fdd89 (diff) | |
| download | rust-33e6df4b62237af312bf6e3f40a97f5bdc94949a.tar.gz rust-33e6df4b62237af312bf6e3f40a97f5bdc94949a.zip | |
Auto merge of #57130 - VardhanThigle:Vardhan/x86_64-fortanix-unknown-sgx-tier2_support, r=alexcrichton
Upgrade x86_64-fortanix-unknown-sgx platform support to tier 2 ## Overview 1. This PR upgrades x86_64-fortanix-unknown-sgx platform support to tier 2 (std only) by setting up build automation for this target. 1. For supporting unwinding, this target needs to link to a port of LLVM's libunwind (more details could be found in #56979), which will be distributed along with the Rust binaries (similar to the extra musl objects) ### Building and copying libunwind: We have added a new build script (`build-x86_64-fortanix-unknown-sgx-toolchain.sh`) that will run while the container is built. This will build `libunwind.a` from git source. While the container is built, the persistent volumes where obj/ gets created aren't yet mapped. As a workaround, we copy the built `libunwind.a` to `obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/` after x.py runs. If any reviewer knows of a better solution, please do tell. r? @Mark-Simulacrum
Diffstat (limited to 'src/ci')
| -rw-r--r-- | src/ci/docker/dist-various-2/Dockerfile | 7 | ||||
| -rwxr-xr-x | src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh | 57 | ||||
| -rw-r--r-- | src/ci/docker/dist-various-2/shared.sh | 18 |
3 files changed, 82 insertions, 0 deletions
diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index 944c2a51b8d..906255533ad 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -29,6 +29,10 @@ RUN /tmp/build-fuchsia-toolchain.sh COPY dist-various-2/build-solaris-toolchain.sh /tmp/ RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc +COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/ +# We pass the commit id of the port of LLVM's libunwind to the build script. +# Any update to the commit id here, should cause the container image to be re-built from this point on. +RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "bbe23902411be88d7388f381becefadd6e3ef819" COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -65,6 +69,9 @@ ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi +ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx + +ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/" ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh b/src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh new file mode 100755 index 00000000000..76921316df2 --- /dev/null +++ b/src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -eu +source shared.sh + +if [ -z "$1" ]; then + echo "Usage: ${0} <commit_id>" + exit -1 +fi + +target="x86_64-fortanix-unknown-sgx" +url="https://github.com/fortanix/llvm-project/archive/${1}.tar.gz" +repo_name="llvm-project" + +install_prereq() +{ + apt-get update + apt-get install -y --no-install-recommends \ + build-essential \ + ca-certificates \ + cmake \ + git +} + +# Clone Fortanix's port of llvm-project to build libunwind that would link with this target. +# The below method to download a single commit from llvm-project is based on fetch_submodule +# from init_repo.sh +fetch_llvm_commit() +{ + cached="download-${repo_name}.tar.gz" + curl -f -sSL -o ${cached} ${url} + tar -xvzf ${cached} + mkdir "./${repo_name}" && tar -xf ${cached} -C ${repo_name} --strip-components 1 +} + +build_unwind() +{ + dir_name="${target}_temp" + rm -rf "./${dir_name}" + mkdir -p ${dir_name} + cd ${dir_name} + + retry fetch_llvm_commit + cd "${repo_name}/libunwind" + + # Build libunwind + mkdir -p build + cd build + cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" -DLLVM_PATH=../../llvm/ ../ + make unwind_static + install -D "lib/libunwind.a" "/${target}/lib/libunwind.a" + rm -rf ${dir_name} +} + +set -x +hide_output install_prereq +hide_output build_unwind diff --git a/src/ci/docker/dist-various-2/shared.sh b/src/ci/docker/dist-various-2/shared.sh index 2b5eccb3189..fb917b0510e 100644 --- a/src/ci/docker/dist-various-2/shared.sh +++ b/src/ci/docker/dist-various-2/shared.sh @@ -13,3 +13,21 @@ exit 1 kill $PING_LOOP_PID set -x } + +function retry { + echo "Attempting with retry:" "$@" + local n=1 + local max=5 + while true; do + "$@" && break || { + if [[ $n -lt $max ]]; then + sleep $n # don't retry immediately + ((n++)) + echo "Command failed. Attempt $n/$max:" + else + echo "The command has failed after $n attempts." + return 1 + fi + } + done +} |
