@@ -10,6 +10,8 @@ use std::path::PathBuf;
1010use std:: { future:: Future , sync:: Arc } ;
1111
1212use anyhow:: { Context , Result } ;
13+ #[ cfg( feature = "experimental-wasm-features" ) ]
14+ use clap:: ValueEnum ;
1315use clap:: { Args , IntoApp , Parser } ;
1416use spin_app:: App ;
1517use 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 ) ]
138153pub 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