Questions tagged [wasmtime]
30 questions
5
votes
1 answer
Why is WebAssembly safe and what is linear memory model
(1) I heard WebAssembly's safety by providing a linear memory. I wonder what does this linear memory contain? does wasm stack and heap locate in this memory space? If yes, I think the stack of wasm and stack of glue code (e.g., js python etc) are…

yeehaw
- 159
- 2
- 11
4
votes
1 answer
How to link a C library in Rust WASI
I want to use a C library in my rust-wasi program. but I am having trouble linking external libraries. My Current setup is this.
main.rs
#[link(name = "mylib")]
extern "C" {
pub fn add_one(i: i32) -> i32;
}
pub fn main() {
let res = unsafe…

Kival M
- 182
- 1
- 10
3
votes
1 answer
Golang to wasm compilation using tinygo. Execution using wasmtime
I have the following test code
func main() {
path, err := os.Getwd()
log.Println(path, err)
files, err := ioutil.ReadDir("/etc/dse")
log.Println(files, err)
}
I compile it to wasm using
tinygo build -target wasi -o list.wasm…

0x11111
- 55
- 3
3
votes
0 answers
Return mutliple values from a wasm function
I have a Golang TCP server running locally and connected to a wasm module. Currently, I can return one value from a wasm function. Through this blog, I noticed that there should be possible to return multiple values rather than one. However, in my…

Hanif Tadjik
- 73
- 1
- 7
3
votes
1 answer
How do I call a Rust function from Go with a string as a parameter?
I have been trying to pass a string to a Rust function (compiled to Wasm), however for what I understood, right now there is no way to pass strings directy, because the "str" is not a type in the "FFI world" (at least that's what the rust compiler…

JioFrost
- 33
- 7
2
votes
2 answers
Is it possible to add a new function to an instantiated Webassembly module?
I'm writing a wasm program that will dynamically generate wasm functions as bytecode (including the type signature, locals vector, and body instruction sequence; everything that defines a function according to the spec). I want an efficient way to…

handle
- 51
- 4
2
votes
1 answer
Failed to invoke functions when running wasm file with wasmtime
Mozilla shared WASI and how to use Wasmtime to run .wasm file in their blog post. The programming language they demonstrated is Rust:
#[wasm_bindgen]
pub fn render(input: &str) -> String {
let parser = Parser::new(input);
let mut html_output…

yushulx
- 11,695
- 8
- 37
- 64
1
vote
1 answer
Calling a WASM function that returns a string from Wasmtime
At a high level I am trying to create a Rust host program that loads a WASM module at runtime using Wasmtime and calls a WASM function that returns a string. I can get this working with numeric types such as usize, but can't work out how to handle…

Keith Sharp
- 21
- 4
1
vote
0 answers
How to pass a function to WebAssembly?
I have a simple function compiled using the WASI SDK, intended to receive a function pointer to pass to another C library that is supposed to call it at a later time (and with an arbitrary signature):
__attribute__((export_name("add_func")))
void…

IS4
- 11,945
- 2
- 47
- 86
1
vote
0 answers
Segfault when calling malloc or puts from Cranelift-generated code
I'm working on a small programming language compiled using cranelift. Now, my generated code segfaults whenever I call malloc or even puts. I'll focus on a small example with malloc:
The code I'm trying to compile is roughly equivalent to the…

nickkoro
- 374
- 3
- 15
1
vote
0 answers
What is the equivalent working Rust code example for this WAT (WebAssembly Text) example?
The below WAT, adapted from a couple of Wasmtime examples, runs absolutely fine embedded in my application but what I thought was the equivalent Rust code fails with:
Running `target\debug\hello_world.exe`
Error: expected 5 imports, found 1
error:…

junglie85
- 1,243
- 10
- 30
1
vote
1 answer
Compile a protobuf c++ program to wasm(Webassembly)
I want to compile a c++ program to wasm(webassembly) and run it by wasmtime which is a wasm runtime but failed.
The c++ program utilize protobuf which is already compiled from src code using Emscripten. The program is build using Emscripten…

Han
- 21
- 6
1
vote
1 answer
How does the element section of wasm module in binary format looks?
I am reading this docs to study wasm binary format. I am finding it very tough to understand the composition of element section. Can someone please give me an example / explanation about it ? Maybe similar to one given here

Sebastian Orteho
- 55
- 5
1
vote
1 answer
What is the size of the Section vector of certain data type in wasm binary?
I am reading this docs. I have doubt about the content of the vector of the sections in binary. For eg Table Section here. How many items of type tabletype can be present in that vector. Is it 0,1 and more or 0(not present) and 1 (only…

Sebastian Orteho
- 55
- 5
1
vote
1 answer
Wasmtime WASI communication via HTTP/sockets
There is awesome webassembly compiler&vm named Wasmtime, which provide support for execution without any kind of embedding, which allows run WASM applications direcly from command line https://docs.wasmtime.dev/lang-bash.html
Unfortunately there is…

Vladislav Ihost
- 2,127
- 11
- 26