]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/build_sysroot/build_sysroot.sh
Auto merge of #78147 - tmiasko:validate-storage, r=jonas-schievink
[rust.git] / compiler / rustc_codegen_cranelift / 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 ./scripts/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 -r sysroot/ 2>/dev/null || true
16
17 # Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
18 # build scripts are still compiled using cg_llvm.
19 export RUSTC=$(pwd)/../"target/"$CHANNEL"/cg_clif_build_sysroot"
20 export RUSTFLAGS=$RUSTFLAGS" --clif"
21
22 # Build libs
23 export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort"
24 if [[ "$1" == "--release" ]]; then
25     sysroot_channel='release'
26     # FIXME Enable incremental again once rust-lang/rust#74946 is fixed
27     # FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
28     CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release
29 else
30     sysroot_channel='debug'
31     cargo build --target $TARGET_TRIPLE
32 fi
33
34 # Copy files to sysroot
35 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
36 cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/