proxy-wasm/proxy-wasm-cpp-host

Add file system WASI call stubs to support wider Wasm binaries

mathetake opened this issue · 3 comments

Some of TinyGo app have started emitting binaries with file system related WASI system calls:

envoy_1  | [2021-11-15 08:13:45.970][1][error][wasm] [source/extensions/common/wasm/wasm_vm.cc:38] Failed to load Wasm module due to a missing import: wasi_snapshot_preview1.path_open
envoy_1  | [2021-11-15 08:13:45.970][1][error][wasm] [source/extensions/common/wasm/wasm_vm.cc:38] Failed to load Wasm module due to a missing import: wasi_snapshot_preview1.fd_prestat_get
envoy_1  | [2021-11-15 08:13:45.970][1][error][wasm] [source/extensions/common/wasm/wasm_vm.cc:38] Failed to load Wasm module due to a missing import: wasi_snapshot_preview1.fd_prestat_dir_name

So it would be helpful if we could add stubs for it even though we cannot actually support them. Relevant to #127

Do you have an example for when those imports are generated? I've built all examples from Proxy-Wasm Go SDK using TinyGo v0.20.0 and the development version, but none of them try to list preopened files.

We need to add those functions for #127, so stubs are fine in the meantime, but I'm wondering if there is a bug in TinyGo that results in unnecessary imports.

@PiotrSikora yeah here's the example:

package main

import "time"

func main() {
	println(time.Now().Second())
}

This would expects these exports in the hosts. I think this stems from the usage of local time zone info (which in tern uses sync package) on time.Time type in the time package. I verified #201 allows apps to use time.Now().Second() or similar in extensions (with UTC timezone).

sorry so maybe the description was wrong -- this issue has existed in the first place and users haven't been able to (heavily used) time.Time struct.