Stream: git-wasmtime

Topic: wasmtime / issue #6540 cargo wasi run doesn't work - erro...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 07 2023 at 21:15):

thinkrapido opened issue #6540:

when I execute cargo wasi run, I get following error

error: failed to run custom build command for `cranelift-codegen v0.96.3`

Caused by:
  process didn't exit successfully: `<home>/Work/rust/wasm/wasm-in-wasm/target/debug/build/cranelift-codegen-ca47549c9dd955cf/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'error when identifying target: "no supported isa found for arch `wasm32`"', <home>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-codegen-0.96.3/build.rs:43:53
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

view this post on Zulip Wasmtime GitHub notifications bot (Jun 07 2023 at 21:32):

bjorn3 commented on issue #6540:

Wasmtime itself can't be compiled for webassembly. Wasmtime uses a jit compiler, which isn't supported by webassembly.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 07 2023 at 23:18):

thinkrapido commented on issue #6540:

I think, I understood the problem space.

I tried to compile the example itself as a wasm.

This broke the compilation.

cranelift relys on platform specific libraries.

when I switched to wasmi, an pure rust implementation, the compilation went through.

Please confirm my assumption of the problem space.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 07 2023 at 23:51):

pchickey commented on issue #6540:

Wasmtime is a WebAssembly engine which internally compiles the user's WebAssembly code to fast native code using the Cranelift code generator. Wasmtime cannot be compiled to WebAssembly because WebAssembly does not have the facilities for executing code generated from inside WebAssembly.

If you're trying to compile Wasmtime for the WebAssembly target, that would be to run it inside another WebAssembly engine. This is not possible.

If you want to execute WebAssembly using Wasmtime, you just need to compile Wasmtime for your computer's native architecture (i.e. do not pass cargo a --target flag).

Wasmi is a WebAssembly engine which internally is just an interpreter, so it does not generate any native code as part of executing WebAssembly. This means it is indeed possible to compile it to WebAssembly. I don't know why you would do that, but if you really do need that, wasmi will work and wasmtime will not.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 07 2023 at 23:55):

pchickey edited a comment on issue #6540:

Wasmtime is a WebAssembly engine which internally compiles the user's WebAssembly code to fast native code using the Cranelift code generator. Wasmtime cannot be compiled to WebAssembly because WebAssembly does not have the facilities for executing code generated from inside WebAssembly.

If you're trying to compile Wasmtime for the WebAssembly target, that would be to run it inside another WebAssembly engine. This is not possible.

If you want to execute WebAssembly using Wasmtime, you just need to compile Wasmtime for your computer's native architecture (i.e. do not pass cargo a --target flag). cargo wasi already contains a Wasmtime which is compiled for your native architecture. It doesn't make sense to run cargo wasi run for the the wasmtime (or wasmtime-cli) crate. Instead, you should find or write a Rust crate which is a WebAssembly program, and then you can use cargo wasi run to compile and execute it inside wasmtime.

Wasmi is a WebAssembly engine which internally is just an interpreter, so it does not generate any native code as part of executing WebAssembly. This means it is indeed possible to compile it to WebAssembly, and run it inside Wasmtime using cargo wasi run. I don't know why you would do that, but it is possible.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2023 at 18:07):

thinkrapido commented on issue #6540:

the problem is, that I like to run webassembly within a webassembly and wasmtime setting up a runtime within a webassembly is not possible, because it depends on shared libraries defined in the host system, which are not contained with the webassembly environment itself. Therefore I need wasmi as an interpretter to run webassemblies within an webassembly. this is mentioned before by @bjorn3

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2023 at 18:09):

thinkrapido commented on issue #6540:

I'm going to close this ticket, because for my specific use case it is not working and not possible at all.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2023 at 18:09):

thinkrapido closed issue #6540:

when I execute cargo wasi run, I get following error

error: failed to run custom build command for `cranelift-codegen v0.96.3`

Caused by:
  process didn't exit successfully: `<home>/Work/rust/wasm/wasm-in-wasm/target/debug/build/cranelift-codegen-ca47549c9dd955cf/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'error when identifying target: "no supported isa found for arch `wasm32`"', <home>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-codegen-0.96.3/build.rs:43:53
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...


Last updated: Dec 23 2024 at 13:07 UTC