Closed sunfishcode closed 3 years ago
I think this should be technically feasible at the witx layer and others, but I'd be worried about language support for this and compatibility with future interface types. AFAIK C/C++/Rust (aka LLVM) has no way of specifying an import of a custom global? Additionally I'm not sure if globals are expected to be supported with the interface types specification or if interface modules will only have adapter functions and core wasm imports/exports. (cc @lukewagner on the globals-in-interface-types question)
In the absence of globals or exported values, we can use constructor functions with no arguments, which should work fine for now.
I'm investingating what we'll need to convert wasi-clocks to use handles: https://github.com/WebAssembly/wasi-clocks/issues/4
I think the most straightforward way to do this is to make the clock constants available as exported globals that a program can import, something like this:
...
The witx tooling currently only supports exported functions, so this would require implementing support for exported globals.
@alexcrichton Does this sound like it would fit in the current ABI work? To keep it simple I think we could limit it to only supporting non-mutable handles.