rust/miri
2019-05-27 13:04:18 +02:00

39 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -e
TARGET=$(rustc --print target-spec-json -Z unstable-options | jq '.["llvm-target"]' -r)
SYSROOT=$(rustc --print sysroot)
# We set the rpath so that Miri finds the private rustc libraries it needs.
# We enable debug-assertions to get tracing.
export RUSTFLAGS="-C link-args=-Wl,-rpath,$SYSROOT/lib/rustlib/$TARGET/lib -C debug-assertions"
COMMAND="$1"
shift
case "$COMMAND" in
install)
exec cargo install --path "$(dirname "$0")" --force --locked --offline
;;
build|test|run)
# Basic build
cargo build --release
# We we want to just build, we are done.
if [ "$COMMAND" = "build" ]; then exit 0; fi
# Get ourselves a sysroot
if [ -n "$MIRI_SYSROOT" ]; then
# sysroot already set
true
elif echo "$SYSROOT" | egrep -q 'build/[^/]+/stage'; then
# a local rustc build, assume we have a proper libstd in $SYSROOT
true
else
# we have to build a sysroot
cargo run --release --bin cargo-miri -- miri setup
export MIRI_SYSROOT=$HOME/.cache/miri/HOST
fi
exec cargo "$COMMAND" --release "$@"
;;
esac