]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh
Rollup merge of #93443 - spastorino:add-stable-hash-impl-doc, r=cjgillot
[rust.git] / src / ci / docker / host-x86_64 / dist-various-2 / build-fuchsia-toolchain.sh
1 #!/usr/bin/env bash
2
3 set -ex
4 source shared.sh
5
6 ZIRCON=e9a26dbc70d631029f8ee9763103910b7e3a2fe1
7
8 mkdir -p zircon
9 pushd zircon > /dev/null
10
11 # Download sources
12 git init
13 git remote add origin https://github.com/rust-lang-nursery/mirror-google-fuchsia-zircon
14 git fetch --depth=1 origin $ZIRCON
15 git reset --hard FETCH_HEAD
16
17 # Download toolchain
18 ./scripts/download-toolchain
19 chmod -R a+rx prebuilt/downloads/clang+llvm-x86_64-linux
20 cp -a prebuilt/downloads/clang+llvm-x86_64-linux/. /usr/local
21
22 build() {
23   local arch="$1"
24
25   case "${arch}" in
26     x86_64) tgt="zircon-pc-x86-64" ;;
27     aarch64) tgt="zircon-qemu-arm64" ;;
28   esac
29
30   hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
31   dst=/usr/local/${arch}-fuchsia
32   mkdir -p $dst
33   cp -a build-${tgt}/sysroot/include $dst/
34   cp -a build-${tgt}/sysroot/lib $dst/
35 }
36
37 # Build sysroot
38 for arch in x86_64 aarch64; do
39   build ${arch}
40 done
41
42 popd > /dev/null
43 rm -rf zircon
44
45 for arch in x86_64 aarch64; do
46   for tool in clang clang++; do
47     cat >/usr/local/bin/${arch}-fuchsia-${tool} <<EOF
48 #!/bin/sh
49 ${tool} --target=${arch}-fuchsia --sysroot=/usr/local/${arch}-fuchsia "\$@"
50 EOF
51     chmod +x /usr/local/bin/${arch}-fuchsia-${tool}
52   done
53   ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-fuchsia-ar
54 done