facebookexperimental / MIRAI

Rust mid-level IR Abstract Interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust WASM toolchain not installed, please install it!

rlaferla opened this issue · comments

After running cargo mirai against a Rust/Substrate blockchain project, I get this error. The project has multiple custom pallets. I also tried running it in each pallet directory (not sure if that is the correct approach) and it ran but produced no results. I then tried it with --diag=verify and also --diag=paranoid. It displayed issues but they were in crate dependencies and not in the project codebase. While I would like to believe that project has no issues, I am skeptical and it's more likely I am not running MIRAI properly. I did build the project with RUSTFLAGS="-Zalways_encode_mir" cargo build

error: failed to run custom build command for `polkadot-runtime v0.9.36 (https://github.com/paritytech/polkadot?branch=release-v0.9.36#dc25abc7)`

Caused by:
  process didn't exit successfully: `/mysrc/target/debug/build/polkadot-runtime-8113c0c85a8c22e4/build-script-build` (exit status: 1)
  --- stderr
  Rust WASM toolchain not installed, please install it!

  Further error information:
  ------------------------------------------------------------
     Compiling wasm-test v1.0.0 (/var/folders/tx/4pzs9v1d4dqd5vm7mtr5vc8h0000gp/T/.tmpONi597)
  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: cannot find macro `println` in this scope
   --> src/main.rs:3:5
    |
  3 |                 println!("{}", env!("RUSTC_VERSION"));
    |                 ^^^^^^^

  error: requires `sized` lang_item

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

% rustup show
Default host: aarch64-apple-darwin
rustup home:  /mysrc/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-2022-08-18-aarch64-apple-darwin
nightly-2022-09-22-aarch64-apple-darwin
nightly-2022-10-09-aarch64-apple-darwin
nightly-2023-02-18-aarch64-apple-darwin
nightly-2023-03-22-aarch64-apple-darwin
nightly-aarch64-apple-darwin (default)

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
wasm32-unknown-unknown

active toolchain
----------------

nightly-2022-10-09-aarch64-apple-darwin (overridden by ‘/mysrc/rust-toolchain.toml')
rustc 1.66.0-nightly (8796e7a9c 2022-10-08)

Running cargo mirai is the preferred way. Since you seem to be concerned with verification rather than just bug finding, so probably want to run MIRAI_FLAGS=--diag=verify cargo mirai. Note that this assumes that you are willing and able to add explicit annotations to the source code being analyzed.

MIRAI runs as an add-on to the rust compiler and it depends on the toolchain for the particular version of rustc against which it was built (see rust-toolchain.toml). Normally you don't have to worry about this because you'll have rustup installed and cargo will use rustup to get hold of this toolchain when it runs the MIRAI binary.

Unfortunately, cross compilation complicates matters quite a bit and MIRAI is not configured and not tested for cross compilation scenarios. It is conceivable that if you run rustup +nightly-2023-03-22 target add wasm32-unknown-unknown before running cargo mirai, things will just work. (I tend never to be quite so lucky whenever I try to cross compile anything, but you never know.)

It seemed promising but in the end it errored out with "could not compile"

I'm afraid that you are in a world of complexity where things just won't work out of the box. It might be more productive to concentrate on a small core library and see if you can verify that with --diag=library.

No updates.