]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh
Auto merge of #57416 - alexcrichton:remove-platform-intrinsics, r=nagisa
[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 {
17     apt-get update
18     apt-get install -y --no-install-recommends \
19             build-essential \
20             ca-certificates \
21             cmake \
22             git
23 }
24
25 # Clone Fortanix's port of llvm-project to build libunwind that would link with this target.
26 # The below method to download a single commit from llvm-project is based on fetch_submodule
27 # from init_repo.sh
28 fetch_llvm_commit()
29 {
30     cached="download-${repo_name}.tar.gz"
31     curl -f -sSL -o ${cached} ${url}
32     tar -xvzf ${cached}
33     mkdir "./${repo_name}" && tar -xf ${cached} -C ${repo_name} --strip-components 1
34 }
35
36 build_unwind()
37 {
38     dir_name="${target}_temp"
39     rm -rf "./${dir_name}"
40     mkdir -p ${dir_name}
41     cd ${dir_name}
42
43     retry fetch_llvm_commit
44     cd "${repo_name}/libunwind"
45
46     # Build libunwind
47     mkdir -p build
48     cd build
49     cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" -DLLVM_PATH=../../llvm/ ../
50     make unwind_static
51     install -D "lib/libunwind.a" "/${target}/lib/libunwind.a"
52     rm -rf ${dir_name}
53 }
54
55 set -x
56 hide_output install_prereq
57 hide_output build_unwind