Stream: wasi

Topic: wasmtime threads


view this post on Zulip Scott Waye (May 04 2023 at 00:54):

Is there an option for wasmtime to enable threads? I tried --enable-threads but that is not recognized. I've built everything with -pthread and -target wasm32-wasi-threads

view this post on Zulip Scott Waye (May 04 2023 at 00:55):

E:\tmp\consolelocal>wasmtime run --allow-precompiled obj\Debug\net8.0\wasi-wasm\native\console.wasm
Error: failed to parse WebAssembly module

Caused by:
    Invalid input WebAssembly code at offset 23077: threads must be enabled for shared memories

This is my error

view this post on Zulip Alex Crichton (May 04 2023 at 01:11):

I believe the flag you're looking for is --wasm-features=threads

view this post on Zulip Scott Waye (May 04 2023 at 12:36):

Thanks yes, that looks like it but

Error: failed to run main module `obj\Debug\net8.0\wasi-wasm\native\console.wasm`

Caused by:
    0: failed to instantiate "obj\\Debug\\net8.0\\wasi-wasm\\native\\console.wasm"
    1: unknown import: `wasi::thread-spawn` has not been defined

Maybe that is not implemented yet in wasmtime

view this post on Zulip Alex Crichton (May 04 2023 at 14:25):

@Scott Waye you might be interested in this blog post which describes the wasi-threads support in Wasmtime a bit more. Namely the --wasi-modules=experimental-wasi-threads argument needs to be passed

Until now, one piece missing from WebAssembly standalone engines was the ability to spawn threads.Browsers have had this ability for some time via Web Workers, but standalone engines had no standardway to do this. This post describes the...

view this post on Zulip Scott Waye (May 04 2023 at 14:29):

Thanks, that's great. I see I'm missing some linker flags also to import and export the memory. Will do some more playing. I realize it is all pretty new.

view this post on Zulip Andrew Brown (May 04 2023 at 15:53):

@Scott Waye, the Rust support for wasi-threads is still being worked on but C/C++ should be currently possible. Coincidentally, others have been asking similar questions so I opened up this public thread over in the wasi-threads channel to coordinate progress. Feel free to join in there if you want to contribute.

view this post on Zulip Afshan Ahmed Khan (May 23 2024 at 11:16):

  1. Hi everyone ! I want to wait / sleep or run a function after timeout of some seconds in wasm32-wasi component ? But I want that to be cancellable .
    I tried doing this - https://stackoverflow.com/a/70121550 But I get attached error on spawning thread , I have tried compiling my rust to wasm32-wasip1-threads and on host I have make sure to enable wasm_threads support by config.wasm_threads(true)

image.png

I am writing a Rust program that does an action every 2 seconds. The program also uses the ctrlc crate to handle interrupts. However, in some cases, I have to wait up to 2 secs when killing the pro...

view this post on Zulip Alex Crichton (May 23 2024 at 14:54):

I responded on the issue you opened, happy to either continue there or here too

I want to wait / sleep or run a function after timeout of some seconds in wasm32-wasi component ? But I want that to be cancellable . I tried doing this - https://stackoverflow.com/a/70121550 But I...

view this post on Zulip Afshan Ahmed Khan (May 23 2024 at 15:14):

Thanks for responding , let's continue on the issue .


Last updated: Dec 23 2024 at 12:05 UTC