Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo-miri failed to build with Rust WASM tool chain #2416

Closed
yanliu18 opened this issue Jul 22, 2022 · 4 comments
Closed

Cargo-miri failed to build with Rust WASM tool chain #2416

yanliu18 opened this issue Jul 22, 2022 · 4 comments
Labels
A-target Area: concerns targets outside of what we currently support C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@yanliu18
Copy link

Problem Description

I've encountered an error as follow when trying to run cargo miri test on a rust project.

error: failed to run custom build command for `node-template-runtime v4.0.0-dev (.../substrate-node-template/runtime)`

Caused by:
  process didn't exit successfully: `.../substrate-node-template/target/miri/debug/build/node-template-runtime-c93ff80443873606/build-script-build` (exit status: 1)
  --- stderr
  Rust WASM toolchain not installed, please install it!
Further error information:
  ------------------------------------------------------------
     Compiling wasm-test v1.0.0 (/tmp/.tmpZgt5DN)
  error[E0463]: can't find crate for `std`
    |
    = note: the `wasm32-unknown-unknown` target may not be installed
    = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`
    = help: consider building the standard library from source with `cargo build -Zbuild-std`

  error: requires `sized` lang_item

  For more information about this error, try `rustc --explain E0463`.
  error: could not compile `wasm-test` due to 2 previous errors

However, the wasm tool chain is installed, following instructions from The Rust Toolchain, and the normal cargo build or cargo run/test can be finished successfully.

Steps to reproduce

git clone https://github.com/substrate-developer-hub/substrate-node-template.git
cargo clean
cargo miri test

Tool versions:
cargo 1.64.0-nightly (8827baaa7 2022-07-14)
rustc 1.64.0-nightly (f8588549c 2022-07-18)
miri 0.1.0 (416cddb 2022-07-17)
rustup 1.25.1 (bb60b1e89 2022-07-12)

@RalfJung
Copy link
Member

Yeah, wasm targets are not currently supported. See our README for a list of supported targets.

Also see #1916 (which has a different error, but is conceptually still the same issue).

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-target Area: concerns targets outside of what we currently support labels Jul 23, 2022
@yanliu18
Copy link
Author

Yeah, wasm targets are not currently supported. See our README for a list of supported targets.

Also see #1916 (which has a different error, but is conceptually still the same issue).

@RalfJung thanks for the instant reply. Is there any plan of supporting WASM? There are a few projects I am interested compiles to WASM.
Though, I was wandering why the wasm tool chain is needed? Since miri works at MIR level, it would have nothing to do with the compilation target? (This might be a wrong impression, feel free to correct me.)

@RalfJung
Copy link
Member

I don't have plans for working on wasm support, so this is down to other people wanting to contribute support.

Indeed Miri works at the MIR level, so then I wonder why it's not possible to use another target instead?

Miri is mostly independent of compilation targets, that's why you can run Windows targets on a Linux host without having any kind of special toolchain installed. But Miri does have to know about some basic idiosyncrasies of the target (such as wasm targets using the ".wasm" file extension), and to be able to interact with the environment, it needs to be able to emulate the key extern functions that a target requires (like write on Linux to print to stdout) -- I have no idea what the latter would even look like on wasm.

@RalfJung
Copy link
Member

I'll close this as a duplicate of #1916; no need to have two issues tracking our lack of wasm support.

@RalfJung RalfJung closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target Area: concerns targets outside of what we currently support C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

2 participants