2018-12-14 06:58:33 -06:00
|
|
|
#!/bin/bash
|
2019-07-30 06:37:47 -05:00
|
|
|
|
|
|
|
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
|
|
|
|
2018-12-14 06:58:33 -06:00
|
|
|
set -e
|
|
|
|
|
2020-11-02 11:16:57 -06:00
|
|
|
source ./config.sh
|
2020-11-01 12:47:14 -06:00
|
|
|
|
2020-11-02 11:16:57 -06:00
|
|
|
dir=$(pwd)
|
2019-07-30 06:37:47 -05:00
|
|
|
|
2020-11-02 11:16:57 -06:00
|
|
|
# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
|
|
|
|
# build scripts are still compiled using cg_llvm.
|
|
|
|
export RUSTC=$dir"/cg_clif_build_sysroot"
|
|
|
|
export RUSTFLAGS=$RUSTFLAGS" --clif"
|
|
|
|
|
|
|
|
cd $(dirname "$0")
|
2020-11-01 12:38:21 -06:00
|
|
|
|
2018-12-14 06:58:33 -06:00
|
|
|
# Cleanup for previous run
|
2019-04-24 09:35:58 -05:00
|
|
|
# v Clean target dir except for build scripts and incremental cache
|
2020-11-02 11:54:10 -06:00
|
|
|
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
|
2018-12-14 06:58:33 -06:00
|
|
|
|
2020-11-02 11:16:57 -06:00
|
|
|
# We expect the target dir in the default location. Guard against the user changing it.
|
|
|
|
export CARGO_TARGET_DIR=target
|
2020-09-29 10:51:52 -05:00
|
|
|
|
2018-12-14 06:58:33 -06:00
|
|
|
# Build libs
|
2020-09-29 10:51:52 -05:00
|
|
|
export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort"
|
2020-11-01 12:47:14 -06:00
|
|
|
if [[ "$1" != "--debug" ]]; then
|
2019-07-30 06:37:47 -05:00
|
|
|
sysroot_channel='release'
|
2020-08-19 06:51:49 -05:00
|
|
|
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
|
2020-10-05 04:12:41 -05:00
|
|
|
# FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
|
|
|
|
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release
|
2018-12-14 06:58:33 -06:00
|
|
|
else
|
2019-07-30 06:37:47 -05:00
|
|
|
sysroot_channel='debug'
|
2018-12-14 06:58:33 -06:00
|
|
|
cargo build --target $TARGET_TRIPLE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to sysroot
|
2020-11-02 11:16:57 -06:00
|
|
|
mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
|
|
|
cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|