dart-archive / wasm

Utilities for loading and running WASM modules from Dart code
https://pub.dev/packages/wasm
BSD 3-Clause "New" or "Revised" License
312 stars 24 forks source link

[ux] WASI #117

Open modulovalue opened 1 year ago

modulovalue commented 1 year ago

I'm trying to bind some WASM modules, and here is one error that is extremely confusing from the perspective of a user:

https://github.com/dart-lang/wasm/blob/ddb2d46ac000827f44a3d18c6564b13b8b3876ef/wasm/lib/src/runtime.dart#L355-L365

WasmRuntimeError: Failed to fill WASI imports.
Failed to resolve import "env" "exit"
#0      WasmRuntime._checkNotEqual (package:wasm/src/runtime.dart:384:7)
#1      WasmRuntime.getWasiImports (package:wasm/src/runtime.dart:360:5)
#2      _WasmInstanceBuilder.enableWasi (package:wasm/src/module.dart:210:13)

To be honest, I'm not entirely sure how WASI is supposed to work. As far as I understood it, it's a known set of imports that WASM modules can choose to depend on? So if a module expects a particular set of imports, can we then derive that it depends on WASI? We should perhaps provide some help here or at least a little more information about what actually went wrong.