3 # Requires the CHANNEL env var to be set to `debug` or `release.`
11 # Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
12 # build scripts are still compiled using cg_llvm.
13 export RUSTC=$dir"/cg_clif_build_sysroot"
14 export RUSTFLAGS=$RUSTFLAGS" --clif"
18 # Cleanup for previous run
19 # v Clean target dir except for build scripts and incremental cache
20 rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
22 # We expect the target dir in the default location. Guard against the user changing it.
23 export CARGO_TARGET_DIR=target
26 export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort"
27 if [[ "$1" != "--debug" ]]; then
28 sysroot_channel='release'
29 # FIXME Enable incremental again once rust-lang/rust#74946 is fixed
30 # FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
31 CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release
33 sysroot_channel='debug'
34 cargo build --target $TARGET_TRIPLE
37 # Copy files to sysroot
38 mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
39 cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/