]> git.lizzy.rs Git - rust.git/blob - build_sysroot/build_sysroot.sh
Merge commit '39683d8eb7a32a74bea96ecbf1e87675d3338506' into sync_cg_gcc-2022-03-26
[rust.git] / build_sysroot / build_sysroot.sh
1 #!/bin/bash
2
3 # Requires the CHANNEL env var to be set to `debug` or `release.`
4
5 set -e
6 cd $(dirname "$0")
7
8 pushd ../ >/dev/null
9 source ./config.sh
10 popd >/dev/null
11
12 # Cleanup for previous run
13 #     v Clean target dir except for build scripts and incremental cache
14 rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
15 rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
16 rm -r sysroot/ 2>/dev/null || true
17
18 # Build libs
19 export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked -Cpanic=abort"
20 if [[ "$1" == "--release" ]]; then
21     sysroot_channel='release'
22     RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
23 else
24     sysroot_channel='debug'
25     cargo build --target $TARGET_TRIPLE --features compiler_builtins/c
26 fi
27
28 # Copy files to sysroot
29 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
30 cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/