2018-12-14 13:58:33 +01:00
|
|
|
#!/bin/bash
|
2019-07-30 13:37:47 +02:00
|
|
|
|
|
|
|
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
|
|
|
|
2018-12-14 13:58:33 +01:00
|
|
|
set -e
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
2019-07-30 13:37:47 +02:00
|
|
|
pushd ../ >/dev/null
|
2020-09-16 16:46:02 +02:00
|
|
|
source ./scripts/config.sh
|
2019-07-30 13:37:47 +02:00
|
|
|
popd >/dev/null
|
|
|
|
|
2018-12-14 13:58:33 +01:00
|
|
|
# Cleanup for previous run
|
2019-04-24 16:35:58 +02:00
|
|
|
# v Clean target dir except for build scripts and incremental cache
|
2020-09-29 13:26:32 +02:00
|
|
|
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
|
2019-08-18 14:57:46 +02:00
|
|
|
rm -r sysroot/ 2>/dev/null || true
|
2018-12-14 13:58:33 +01:00
|
|
|
|
2020-09-29 17:51:52 +02: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-10-10 16:41:31 +02:00
|
|
|
export RUSTC=$(pwd)/../"target/"$CHANNEL"/cg_clif_build_sysroot"
|
|
|
|
export RUSTFLAGS=$RUSTFLAGS" --clif"
|
2020-09-29 17:51:52 +02:00
|
|
|
|
2018-12-14 13:58:33 +01:00
|
|
|
# Build libs
|
2020-09-29 17:51:52 +02:00
|
|
|
export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort"
|
2018-12-14 13:58:33 +01:00
|
|
|
if [[ "$1" == "--release" ]]; then
|
2019-07-30 13:37:47 +02:00
|
|
|
sysroot_channel='release'
|
2020-08-19 13:51:49 +02:00
|
|
|
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
|
2020-10-05 11:12:41 +02: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 13:58:33 +01:00
|
|
|
else
|
2019-07-30 13:37:47 +02:00
|
|
|
sysroot_channel='debug'
|
2018-12-14 13:58:33 +01:00
|
|
|
cargo build --target $TARGET_TRIPLE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to sysroot
|
2019-07-30 13:37:47 +02:00
|
|
|
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
2019-08-18 11:30:13 +02:00
|
|
|
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|