I'm trying to use the WASI interface. I have started trying to print to stdout, but without luck. - I also want to read input and so on. Here's the WebAssembly Text (wat) code that I'm using for testing:
(module
(type $write_type (func (param i32 i32 i32 i32) (result i32)))
(import "wasi_snapshot_preview1" "fd_write" (func $fd_write (type $write_type)))
(memory (export "memory") 1)
(data (i32.const 8) "Hello, WASI!\n")
(func $main (result i32)
;; Prepare parameters for fd_write
i32.const 1 ;; File descriptor (1 represents stdout)
i32.const 8 ;; Pointer to the data to be written
i32.const 13 ;; Length of the data
i32.const 0 ;; Pointer to store the number of bytes written (not used in this example)
;; Call fd_write
call $fd_write
)
(export "main" (func $main))
)
Wasmtime Version=9.0.2
I have set up wasmtime-dotnet like so:
var config = new Config()
.WithDebugInfo(true)
.WithCraneliftDebugVerifier(true)
.WithOptimizationLevel(0);
_engine = new Engine(config);
_linker = new Linker(_engine);
_store = new Store(_engine);
var config = new WasiConfiguration().WithInheritedStandardOutput()
.WithInheritedStandardInput()
.WithInheritedArgs()
.WithInheritedStandardError()
.WithInheritedEnvironment();
_store.SetWasiConfiguration(config);
_linker.DefineWasi();
The code is running without any errors, and the main function returns 21.
Hello!
I'm trying to use the WASI interface. I have started trying to print to stdout, but without luck. - I also want to read input and so on. Here's the WebAssembly Text (wat) code that I'm using for testing:
Wasmtime Version=9.0.2
I have set up wasmtime-dotnet like so:
The code is running without any errors, and the main function returns 21.