]> git.lizzy.rs Git - rust.git/blob - build_sysroot/build_sysroot.sh
Merge pull request #1089 from bjorn3/custom_driver
[rust.git] / build_sysroot / build_sysroot.sh
1 #!/bin/bash
2
3 # Requires the CHANNEL env var to be set to `debug` or `release.`
4
5 set -e
6 cd $(dirname "$0")
7
8 pushd ../ >/dev/null
9 source ./scripts/config.sh
10 popd >/dev/null
11
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
16
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=rustc
20 export RUSTFLAGS=$RUSTFLAGS" -Ztrim-diagnostic-paths=no -Zcodegen-backend=$(pwd)/../target/"$CHANNEL"/librustc_codegen_cranelift."$dylib_ext" --sysroot $(pwd)/sysroot"
21
22 # Build libs
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     CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=2" cargo build --target $TARGET_TRIPLE --release
28 else
29     sysroot_channel='debug'
30     cargo build --target $TARGET_TRIPLE
31 fi
32
33 # Copy files to sysroot
34 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
35 cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/