Skip to content

I’d really like to opt-in to Wasm features #3364

@swankjesse

Description

@swankjesse

With a significant amount of effort I was able to write ‘hello world‘ in Kotlin and run it on Spin! Hooray!

Image

One major roadblock I faced was Spin’s lack of support for 4 opt-in features in Wasmtime:

WasmFeatures::GC
WasmFeatures::REFERENCE_TYPES
WasmFeatures::EXCEPTIONS
WasmFeatures::FUNCTION_REFERENCES

I was able to get it working locally by changing Spin’s Wasmtime configuration. I enabled the required features in crates/core/src/lib.rs:

 impl Default for Config {
     fn default() -> Self {
         let mut inner = wasmtime::Config::new();
         inner.async_support(true);
         inner.epoch_interruption(true);
         inner.wasm_component_model(true);
         inner.wasm_component_model_async(true);
+        inner.wasm_gc(true);
+        inner.wasm_reference_types(true);
+        inner.wasm_exceptions(true);
+        inner.wasm_function_references(true);
         // If targeting musl, disable native unwind to address this issue:

REFERENCE_TYPES is in WasmFeatures::WASM2, and the other ones are in WasmFeatures::WASM3.

I need this capability to run Kotlin programs in Spin. I expect other languages would similarly benefit from their availability.

One solution would be to let me opt-in to Wasm features in my spin.toml:

[component.rounds-experimental]
source = "rounds-experimental.wasm"
allowed_outbound_hosts = []
require_wasm_features = ["gc", "reference_types", "exceptions", "function_references"]

An alternate solution would be for Spin to automatically inspect my .wasm file and enable the Wasmtime features required to run my app. Perhaps it could issue a warning if any experimental features are used.

If you’d like me to submit a PR to implement this behaviour, I’d be quite happy to. But I won’t proceed without your blessing. You all might have better ideas!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions