Questions tagged [wasi]

45 questions
7
votes
1 answer

Why are there "wasi_snapshot_preview_1" imports in this wasm module?

Recently I tried to experiment with webassembly with as few helpers as possible. So I created a c project, included some libraries (stb_image.h) and tried to compile it. Here is a short reproducible example: #include #define…
rambi
  • 1,013
  • 1
  • 7
  • 25
5
votes
2 answers

How to reduce size of WASM binary?

I have a project written in C++, and the platform to be deployed in has a limitation of 256KB of binary size. The toolchain is wasi-sdk-16.0 clang++, we use this compiler to compile the source code into binary in WASM format. In this step we compile…
Acane
  • 167
  • 1
  • 9
5
votes
2 answers

How to use Rust's async/await syntax in WASI

I would like to compile the following code with cargo-wasi. // reqwest = { version = "0.11", features = ["json"] } // tokio = { version = "1", features = ["full"] } use std::collections::HashMap; #[tokio::main] async fn main() -> Result<(),…
ducaale
  • 637
  • 6
  • 17
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
5
votes
1 answer

What is the difference between Emscripten and Clang in terms of WebAssembly compilation

I know both clang (by use target=wasm32) and emscripten can compile C code into webassembly, but how are they different? It looks like they both use LLVM as backend. Actually, I do not even quite understand the relation between llvm and clang... I…
yeehaw
  • 159
  • 2
  • 11
4
votes
1 answer

How to import WASI and write a simple console log function in WASM WAT

I want to understand the WebAssembly text format for educational purposes and for writing a POC compiler that compiles straight to WASM. I want to understand how to properly import the necessary WASI functions to create a console log function. I'd…
José Mancharo
  • 175
  • 1
  • 14
3
votes
0 answers

How to import wasi in C (wasm2c)?

I transfer a wasi-wasm to C file via wasm2c. wasm2c test.wasm -o test.c And I got a header file and a source C file. Part of the header file shows here. /* import: 'wasi_snapshot_preview1' 'args_get' */ u32…
Dbettkk
  • 51
  • 2
3
votes
0 answers

How to use .witx definitions for Go code generation to use with TinyGo WebAssembly targeting WASI?

Is it possible to use .witx definition files for Go code generation to use with TinyGo's WebAssembly WASI (WebAssembly System Interface) support? Specifically, I want to create a Fastly Compute@Edge SDK for Go. These SDKs exist for JavaScript,…
Grokify
  • 15,092
  • 6
  • 60
  • 81
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
0 answers

WASI and JVM - OS Abstraction

My question is if the JVM actually provides a virtual operating system too, similar to how WASI does. As for my understand WASM and JVM are both virtual machines, providing an environment to execute some bytecode. Their aim is to abstract the…
prohit
  • 609
  • 1
  • 6
  • 18
2
votes
1 answer

How implement websockets using Boost library in WebAssembly?

I am trying to pass a program that uses websockets in C++ using the Boost library, to WebAssembly for its later use in a web application, or in its defect in a runtime like Wasmtime. On the one hand I have used Emscripten to compile my C++…
amelian
  • 21
  • 1
2
votes
1 answer

Importing the correct Wasi module in node.js

I've been stuck on something for some time now. I'm trying to use WebAssembly from Node.js, but in order to do that, I need NodeJs to instantiate a Wasi object. This is implemented here: https://github.com/nodejs/node/blob/master/lib/wasi.js and the…
JonasAnon
  • 195
  • 1
  • 14
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
0 answers

Should i use wasi-libc to access standard library functions from browser WebAssembly code?

I'm trying to use WebAssembly and libc++ for browser app. I've successfully added libc++ headers to my C++ code and compiled it. Without linking libc++ there is a need to import some functions to wasm from JS (memcpy, operator new...). But if i link…
Denis Belov
  • 113
  • 8
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
2 3