3 # Requires the CHANNEL env var to be set to `debug` or `release.`
9 source ./scripts/config.sh
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
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"
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
30 sysroot_channel='debug'
31 cargo build --target $TARGET_TRIPLE
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/