Skip to content

Commit c2791fc

Browse files
committed
add 'miri' script to help build, test and run miri
1 parent aa868a8 commit c2791fc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

miri

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
set -e
3+
TARGET=$(rustc --print target-spec-json -Z unstable-options | jq '.["llvm-target"]' -r)
4+
SYSROOT=$(rustc --print sysroot)
5+
export RUSTFLAGS="-C link-args=-Wl,-rpath,$SYSROOT/lib/rustlib/$TARGET/lib -C debug-assertions"
6+
7+
COMMAND="$1"
8+
shift
9+
10+
case "$COMMAND" in
11+
install)
12+
exec cargo install --path "$(dirname "$0")" --force --locked --offline
13+
;;
14+
build|test|run)
15+
# Basic build
16+
cargo build --release
17+
18+
# We we want to just build, we are done.
19+
if [ "$COMMAND" = "build" ]; then exit 0; fi
20+
21+
# Get ourselves a sysroot
22+
if [ -n "$MIRI_SYSROOT" ]; then
23+
# sysroot already set
24+
true
25+
elif rustc --print sysroot | egrep -q 'build/[^/]+/stage'; then
26+
# a local build, we have a proper libstd in $SYSROOT
27+
true
28+
else
29+
# we have to build a sysroot
30+
cargo run --release --bin cargo-miri -- miri setup
31+
export MIRI_SYSROOT=$HOME/.cache/miri/HOST
32+
fi
33+
34+
exec cargo "$COMMAND" --release "$@"
35+
;;
36+
esac

0 commit comments

Comments
 (0)