2021-02-14 21:43:23 +08:00
|
|
|
#!/usr/bin/env bash
|
2019-07-30 19:37:47 +08:00
|
|
|
|
|
|
|
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
|
|
|
|
2018-12-14 20:58:33 +08:00
|
|
|
set -e
|
|
|
|
|
2020-11-03 01:16:57 +08:00
|
|
|
source ./config.sh
|
2020-11-02 02:47:14 +08:00
|
|
|
|
2020-11-03 01:16:57 +08:00
|
|
|
dir=$(pwd)
|
2019-07-30 19:37:47 +08:00
|
|
|
|
2020-11-03 01:16:57 +08: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.
|
2020-11-09 00:35:59 +08:00
|
|
|
export RUSTC=$dir"/bin/cg_clif_build_sysroot"
|
2020-11-03 01:16:57 +08:00
|
|
|
export RUSTFLAGS=$RUSTFLAGS" --clif"
|
|
|
|
|
2020-11-04 22:35:42 +08:00
|
|
|
cd "$(dirname "$0")"
|
2020-11-02 02:38:21 +08:00
|
|
|
|
2018-12-14 20:58:33 +08:00
|
|
|
# Cleanup for previous run
|
2019-04-24 22:35:58 +08:00
|
|
|
# v Clean target dir except for build scripts and incremental cache
|
2020-11-03 01:54:10 +08:00
|
|
|
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
|
2018-12-14 20:58:33 +08:00
|
|
|
|
2020-11-03 01:16:57 +08:00
|
|
|
# We expect the target dir in the default location. Guard against the user changing it.
|
|
|
|
export CARGO_TARGET_DIR=target
|
2020-09-29 23:51:52 +08:00
|
|
|
|
2018-12-14 20:58:33 +08:00
|
|
|
# Build libs
|
2021-03-31 19:47:10 +08:00
|
|
|
export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort"
|
2021-01-21 22:20:48 +08:00
|
|
|
export __CARGO_DEFAULT_LIB_METADATA="cg_clif"
|
2020-11-02 02:47:14 +08:00
|
|
|
if [[ "$1" != "--debug" ]]; then
|
2019-07-30 19:37:47 +08:00
|
|
|
sysroot_channel='release'
|
2020-08-19 19:51:49 +08:00
|
|
|
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
|
2021-03-09 23:45:55 +08:00
|
|
|
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target "$TARGET_TRIPLE" --release
|
2018-12-14 20:58:33 +08:00
|
|
|
else
|
2019-07-30 19:37:47 +08:00
|
|
|
sysroot_channel='debug'
|
2020-11-04 22:35:42 +08:00
|
|
|
cargo build --target "$TARGET_TRIPLE"
|
2018-12-14 20:58:33 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to sysroot
|
2020-11-12 23:18:03 +08:00
|
|
|
ln "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
|
2020-11-09 00:35:59 +08:00
|
|
|
rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}
|