zerocopy
zerocopy copied to clipboard
Run `cargo miri test` on a wasm target once one is supported
Currently, Miri doesn't support any wasm target (see https://github.com/google/zerocopy/issues/22#issuecomment-1281481417). Once one is supported, we should run cargo miri test on a wasm target in CI.
Old issue text
This job failed for reasons that seem specific to running cargo miri test with the target set to wasm32-wasi. I'm going to disable the test for the time being.
Thanks to @frazar for discovering https://github.com/rust-lang/miri/issues/1916, which suggests that Miri lacks support for some wasm32 targets. The task for this issue now is to a) determine whether any wasm32 targets are supported, b) switch to using a supported one if so or, c) skip running Miri when targetting wasm32 if none are supported.
Reading the comments to a relevant issue in the miri repo (rust-lang/miri#1916), it seems like miri does not support wasm32-unknown-unknown.
Maybe I misuderstood something?
Oh good find! Updated the issue description based on that.
I can take a look!
Thanks! Assigned to you.
My investigation suggests that miri doesn't support any of the wasm32 targets as they all give the same error.
> rustup +nightly-2022-09-26 target list | rg wasm32
wasm32-unknown-emscripten
wasm32-unknown-unknown
wasm32-wasi
wasm32-unknown-emscripten
> cargo +nightly-2022-09-26 miri test --target wasm32-unknown-emscripten --features "" -- --skip ui
Preparing a sysroot for Miri (target: wasm32-unknown-emscripten)... done
Compiling zerocopy v0.7.0-alpha (/Users/memark/Src/zerocopy)
Finished test [unoptimized + debuginfo] target(s) in 0.04s
Running unittests src/lib.rs (target/miri/wasm32-unknown-emscripten/debug/deps/zerocopy-cad9098b3780266a.js)
fatal error: file "/Users/memark/Src/zerocopy/target/miri/wasm32-unknown-emscripten/debug/deps/zerocopy-cad9098b3780266a.js" not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/Users/memark/.rustup/toolchains/nightly-2022-09-26-aarch64-apple-darwin/bin/cargo-miri runner /Users/memark/Src/zerocopy/target/miri/wasm32-unknown-emscripten/debug/deps/zerocopy-cad9098b3780266a.js --skip ui` (exit status: 1)
wasm32-unknown-unknown
> cargo +nightly-2022-09-26 miri test --target wasm32-unknown-unknown -- --skip ui
Preparing a sysroot for Miri (target: wasm32-unknown-unknown)... done
Compiling zerocopy v0.7.0-alpha (/Users/memark/Src/zerocopy)
Finished test [unoptimized + debuginfo] target(s) in 0.04s
Running unittests src/lib.rs (target/miri/wasm32-unknown-unknown/debug/deps/zerocopy-f4099b17079841af.wasm)
fatal error: file "/Users/memark/Src/zerocopy/target/miri/wasm32-unknown-unknown/debug/deps/zerocopy-f4099b17079841af.wasm" not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/Users/memark/.rustup/toolchains/nightly-2022-09-26-aarch64-apple-darwin/bin/cargo-miri runner /Users/memark/Src/zerocopy/target/miri/wasm32-unknown-unknown/debug/deps/zerocopy-f4099b17079841af.wasm --skip ui` (exit status: 1)
wasm32-wasi
> cargo +nightly-2022-09-26 miri test --target wasm32-wasi -- --skip ui
Preparing a sysroot for Miri (target: wasm32-wasi)... done
Compiling zerocopy v0.7.0-alpha (/Users/memark/Src/zerocopy)
Finished test [unoptimized + debuginfo] target(s) in 0.04s
Running unittests src/lib.rs (target/miri/wasm32-wasi/debug/deps/zerocopy-f11f6b13dd8fddc2.wasm)
fatal error: file "/Users/memark/Src/zerocopy/target/miri/wasm32-wasi/debug/deps/zerocopy-f11f6b13dd8fddc2.wasm" not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/Users/memark/.rustup/toolchains/nightly-2022-09-26-aarch64-apple-darwin/bin/cargo-miri runner /Users/memark/Src/zerocopy/target/miri/wasm32-wasi/debug/deps/zerocopy-f11f6b13dd8fddc2.wasm --skip ui` (exit status: 1)
OK great, thanks @memark! Updated the issue description based on your findings.
My investigation suggests that miri doesn't support any of the wasm32 targets as they all give the same error.
Indeed, https://github.com/rust-lang/miri/issues/1916 affects all wasm targets. I have hardly any wasm knowledge so I am not sure how to even test potential fixes. The first step would be to add .wasm around here, but then I don't know how to tell if the result makes any sense.
FWIW https://github.com/rust-lang/miri/pull/2685 should help here. Miri still barely supports any FFI shims on wasm targets, but at least cargo miri run on an empty crate works now.