14 begingroup "Building Miri"
16 # Determine configuration for installed build
17 echo "Installing release version of Miri"
18 export RUSTFLAGS="-D warnings"
19 export CARGO_INCREMENTAL=0
20 ./miri install # implicitly locked
22 # Prepare debug build for direct `./miri` invocations
23 echo "Building debug version of Miri"
24 export CARGO_EXTRA_FLAGS="--locked"
25 ./miri check --no-default-features # make sure this can be built
26 ./miri check --all-features # and this, too
27 ./miri build --all-targets # the build that all the `./miri test` below will use
33 if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
34 begingroup "Testing foreign architecture $MIRI_TEST_TARGET"
36 begingroup "Testing host architecture"
41 if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
42 # Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
43 # optimizations up all the way).
44 # Optimizations change diagnostics (mostly backtraces), so we don't check them
45 #FIXME(#2155): we want to only run the pass and panic tests here, not the fail tests.
46 MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
50 # On Windows, there is always "python", not "python3" or "python2".
51 if command -v python3 > /dev/null; then
56 # Some environment setup that attempts to confuse the heck out of cargo-miri.
57 if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then
58 # These act up on Windows (`which miri` produces a filename that does not exist?!?),
59 # so let's do this only on Linux. Also makes sure things work without these set.
60 export RUSTC=$(which rustc)
61 export MIRI=$(which miri)
64 echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
66 ${PYTHON} test-cargo-miri/run-test.py
71 # Ensure that our benchmarks all work, but only on Linux hosts.
72 if [ -z "${MIRI_TEST_TARGET+exists}" ] && [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ] ; then
73 for BENCH in $(ls "bench-cargo-miri"); do
74 cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml
81 function run_tests_minimal {
82 if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
83 begingroup "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@"
85 begingroup "Testing MINIMAL host architecture: only testing $@"
90 # Ensure that a small smoke test of cargo-miri works.
91 cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml --target ${MIRI_TEST_TARGET-$HOST_TARGET}
100 x86_64-unknown-linux-gnu)
101 MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
102 MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
103 MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
104 MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var
105 MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
106 MIRI_TEST_TARGET=wasm32-wasi MIRI_NO_STD=1 run_tests_minimal no_std # supports std but miri doesn't support it
107 MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
110 MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
111 MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
113 i686-pc-windows-msvc)
114 MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
115 MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
118 echo "FATAL: unknown OS"