Skip to content

Commit

Permalink
Auto merge of #57914 - jethrogb:jb/sgx-unwind-version, r=alexcrichton
Browse files Browse the repository at this point in the history
SGX target: clean up dist builder, update libunwind

This incorporates fortanix/llvm-project#4

Fixes fortanix/rust-sgx#65

r? @alexcrichton
  • Loading branch information
bors committed Jan 31, 2019
2 parents 8a0e5fa + b025557 commit 63505b8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/ci/docker/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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 "13fad13f8ea83a8da58d04a5faa45943151b3398"
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "53b586346f2c7870e20b170decdc30729d97c42b"

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ target="x86_64-fortanix-unknown-sgx"
url="https://github.com/fortanix/llvm-project/archive/${1}.tar.gz"
repo_name="llvm-project"

install_prereq()
{
install_prereq() {
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
Expand All @@ -22,36 +21,32 @@ install_prereq()
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()
{
build_unwind() {
set -x
dir_name="${target}_temp"
rm -rf "./${dir_name}"
rm -rf ${dir_name}
mkdir -p ${dir_name}
cd ${dir_name}
pushd ${dir_name}

retry fetch_llvm_commit
# Clone Fortanix's fork of llvm-project which has a port of libunwind
fetch_github_commit_archive "$repo_name" "$url"
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/ ../
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" \
-DLLVM_ENABLE_WARNINGS=1 -DLIBUNWIND_ENABLE_WERROR=1 -DLIBUNWIND_ENABLE_PEDANTIC=0 \
-DLLVM_PATH=../../llvm/ ../
make unwind_static
install -D "lib/libunwind.a" "/${target}/lib/libunwind.a"

popd
rm -rf ${dir_name}

{ set +x; } 2>/dev/null
}

set -x
hide_output install_prereq
hide_output build_unwind
build_unwind
15 changes: 14 additions & 1 deletion src/ci/docker/dist-various-2/shared.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
hide_output() {
set +x
{ set +x; } 2>/dev/null
on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/build.log
Expand All @@ -14,6 +14,7 @@ exit 1
set -x
}

# Copied from ../../shared.sh
function retry {
echo "Attempting with retry:" "$@"
local n=1
Expand All @@ -31,3 +32,15 @@ function retry {
}
done
}

# Copied from ../../init_repo.sh
function fetch_github_commit_archive {
local module=$1
local cached="download-${module//\//-}.tar.gz"
retry sh -c "rm -f $cached && \
curl -f -sSL -o $cached $2"
mkdir $module
touch "$module/.git"
tar -C $module --strip-components=1 -xf $cached
rm $cached
}
7 changes: 4 additions & 3 deletions src/ci/init_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then
git fetch origin --unshallow beta master
fi

function fetch_submodule {
# Duplicated in docker/dist-various-2/shared.sh
function fetch_github_commit_archive {
local module=$1
local cached="download-${module//\//-}.tar.gz"
retry sh -c "rm -f $cached && \
curl -sSL -o $cached $2"
curl -f -sSL -o $cached $2"
mkdir $module
touch "$module/.git"
tar -C $module --strip-components=1 -xf $cached
Expand All @@ -58,7 +59,7 @@ for i in ${!modules[@]}; do
git rm $module
url=${urls[$i]}
url=${url/\.git/}
fetch_submodule $module "$url/archive/$commit.tar.gz" &
fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
continue
else
use_git="$use_git $module"
Expand Down
1 change: 1 addition & 0 deletions src/ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# marked as an executable file in git.

# See http://unix.stackexchange.com/questions/82598
# Duplicated in docker/dist-various-2/shared.sh
function retry {
echo "Attempting with retry:" "$@"
local n=1
Expand Down

0 comments on commit 63505b8

Please sign in to comment.