Skip to content

Commit 2117eeb

Browse files
Allow enabling experimental wasm features (#3377)
Signed-off-by: Brian Hardock <[email protected]>
1 parent d3df1d0 commit 2117eeb

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ jobs:
120120
with:
121121
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
122122

123+
- name: build release (canary)
124+
if: github.ref == 'refs/heads/main'
125+
shell: bash
126+
run: cargo build --features experimental-wasm-features --release ${{ matrix.config.extraArgs }}
127+
123128
- name: build release
129+
if: github.ref != 'refs/heads/main'
124130
shell: bash
125131
run: cargo build --release ${{ matrix.config.extraArgs }}
126132

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ llm-metal = ["llm", "spin-runtime-factors/llm-metal"]
115115
llm-cublas = ["llm", "spin-runtime-factors/llm-cublas"]
116116
# This enables the collection and emission CPU time elapsed per component execution.
117117
cpu-time-metrics = ["spin-factors-executor/cpu-time-metrics"]
118+
experimental-wasm-features = ["spin-trigger/experimental-wasm-features"]
118119

119120
[workspace]
120121
members = [

crates/trigger/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ rust-version.workspace = true
1313
# `ComponentLoader::enable_loading_aot_compiled_components`
1414
# documentation for more information about the safety risks.
1515
unsafe-aot-compilation = []
16+
# Enables configuring unstable Wasm features.
17+
experimental-wasm-features = []
1618

1719
[dependencies]
1820
anyhow = { workspace = true }

crates/trigger/src/cli.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use std::path::PathBuf;
1010
use std::{future::Future, sync::Arc};
1111

1212
use anyhow::{Context, Result};
13+
#[cfg(feature = "experimental-wasm-features")]
14+
use clap::ValueEnum;
1315
use clap::{Args, IntoApp, Parser};
1416
use spin_app::App;
1517
use spin_common::sloth;
@@ -111,6 +113,10 @@ pub struct FactorsTriggerCommand<T: Trigger<B::Factors>, B: RuntimeFactorsBuilde
111113
)]
112114
pub runtime_config_file: Option<PathBuf>,
113115

116+
#[cfg(feature = "experimental-wasm-features")]
117+
#[clap(long, value_enum)]
118+
pub experimental_wasm_feature: Vec<ExperimentalWasmFeature>,
119+
114120
/// Set the application state directory path. This is used in the default
115121
/// locations for logs, key value stores, etc.
116122
///
@@ -133,6 +139,15 @@ pub struct FactorsTriggerCommand<T: Trigger<B::Factors>, B: RuntimeFactorsBuilde
133139
pub launch_metadata_only: bool,
134140
}
135141

142+
#[cfg(feature = "experimental-wasm-features")]
143+
#[derive(Clone, Debug, ValueEnum)]
144+
pub enum ExperimentalWasmFeature {
145+
Gc,
146+
ReferenceTypes,
147+
Exceptions,
148+
FunctionReferences,
149+
}
150+
136151
/// Configuration options that are common to all triggers.
137152
#[derive(Debug, Default)]
138153
pub struct FactorsConfig {
@@ -212,6 +227,23 @@ impl<T: Trigger<B::Factors>, B: RuntimeFactorsBuilder> FactorsTriggerCommand<T,
212227
config.disable_pooling();
213228
}
214229

230+
#[cfg(feature = "experimental-wasm-features")]
231+
{
232+
let wasmtime_config = config.wasmtime_config();
233+
for wasm_feature in self.experimental_wasm_feature {
234+
match wasm_feature {
235+
ExperimentalWasmFeature::Gc => wasmtime_config.wasm_gc(true),
236+
ExperimentalWasmFeature::ReferenceTypes => {
237+
wasmtime_config.wasm_reference_types(true)
238+
}
239+
ExperimentalWasmFeature::Exceptions => wasmtime_config.wasm_exceptions(true),
240+
ExperimentalWasmFeature::FunctionReferences => {
241+
wasmtime_config.wasm_function_references(true)
242+
}
243+
};
244+
}
245+
}
246+
215247
let state_dir = match &self.state_dir {
216248
// Make sure `--state-dir=""` unsets the state dir
217249
Some(s) if s.is_empty() => UserProvidedPath::Unset,

0 commit comments

Comments
 (0)