]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh
Auto merge of #73007 - yoshuawuyts:socketaddr-from-string-u16, r=sfackler
[rust.git] / src / ci / docker / dist-various-2 / build-x86_64-fortanix-unknown-sgx-toolchain.sh
1 #!/bin/bash
2
3 set -eu
4 source shared.sh
5
6 if [ -z "$1" ]; then
7     echo "Usage: ${0} <commit_id>"
8     exit -1
9 fi
10
11 target="x86_64-fortanix-unknown-sgx"
12 url="https://github.com/fortanix/llvm-project/archive/${1}.tar.gz"
13 repo_name="llvm-project"
14
15 install_prereq() {
16     curl https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -
17     add-apt-repository -y 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main'
18     apt-get update
19     apt-get install -y --no-install-recommends \
20             build-essential \
21             ca-certificates \
22             cmake \
23             git \
24             clang-11
25 }
26
27 build_unwind() {
28     set -x
29     dir_name="${target}_temp"
30     rm -rf ${dir_name}
31     mkdir -p ${dir_name}
32     pushd ${dir_name}
33
34     # Clone Fortanix's fork of llvm-project which has a port of libunwind
35     fetch_github_commit_archive "$repo_name" "$url"
36     cd "${repo_name}/libunwind"
37
38     # Build libunwind
39     mkdir -p build
40     cd build
41     target_CC="CC_${target//-/_}"
42     target_CXX="CXX_${target//-/_}"
43     target_CFLAGS="CFLAGS_${target//-/_}"
44     target_CXXFLAGS="CXXFLAGS_${target//-/_}"
45     cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" \
46         -DCMAKE_C_COMPILER="${!target_CC}" -DCMAKE_CXX_COMPILER="${!target_CXX}" \
47         -DCMAKE_C_FLAGS="${!target_CFLAGS}" -DCMAKE_CXX_FLAGS="${!target_CXXFLAGS}" \
48         -DCMAKE_C_COMPILER_TARGET=$target -DCMAKE_CXX_COMPILER_TARGET=$target \
49         -DLLVM_ENABLE_WARNINGS=1 -DLIBUNWIND_ENABLE_WERROR=1 -DLIBUNWIND_ENABLE_PEDANTIC=0 \
50         -DLLVM_PATH=../../llvm/ ../
51     make unwind_static
52     install -D "lib/libunwind.a" "/${target}/lib/libunwind.a"
53
54     popd
55     rm -rf ${dir_name}
56
57     { set +x; } 2>/dev/null
58 }
59
60 set -x
61 hide_output install_prereq
62 build_unwind