rust/compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2020-05-10 09:54:30 -05:00
# Requires the CHANNEL env var to be set to `debug` or `release.`
set -e
cd $(dirname "$0")
2023-09-26 09:09:51 -05:00
pushd ../
2020-05-10 09:54:30 -05:00
source ./config.sh
2023-09-26 09:09:51 -05:00
popd
2020-05-10 09:54:30 -05:00
# Cleanup for previous run
# v Clean target dir except for build scripts and incremental cache
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
rm -r sysroot/ 2>/dev/null || true
# Build libs
2022-10-19 08:23:23 -05:00
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
2020-05-10 09:54:30 -05:00
if [[ "$1" == "--release" ]]; then
sysroot_channel='release'
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
else
sysroot_channel='debug'
2023-09-06 18:01:04 -05:00
cargo build --target $TARGET_TRIPLE
2020-05-10 09:54:30 -05:00
fi
# Copy files to sysroot
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
# Copy the source files to the sysroot (Rust for Linux needs this).
source_dir=sysroot/lib/rustlib/src/rust
mkdir -p $source_dir
cp -r sysroot_src/library/ $source_dir