Skip to content

Commit d7d0c18

Browse files
committed
Add a knob to wasmtime::Config and a CLI flag for GC support in the component-model
1 parent 7aea45a commit d7d0c18

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

crates/cli-flags/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ wasmtime_option_group! {
375375
/// Component model support for `error-context`: this corresponds
376376
/// to the 📝 emoji in the component model specification.
377377
pub component_model_error_context: Option<bool>,
378+
/// GC support in the component model: this corresponds to the 🛸 emoji
379+
/// in the component model specification.
380+
pub component_model_gc: Option<bool>,
378381
/// Configure support for the function-references proposal.
379382
pub function_references: Option<bool>,
380383
/// Configure support for the stack-switching proposal.
@@ -1042,6 +1045,16 @@ impl CommonOptions {
10421045
("gc", function_references, wasm_function_references)
10431046
("stack-switching", stack_switching, wasm_stack_switching)
10441047
}
1048+
1049+
if let Some(enable) = self.wasm.component_model_gc {
1050+
#[cfg(all(feature = "component-model", feature = "gc"))]
1051+
config.wasm_component_model_gc(enable);
1052+
#[cfg(not(all(feature = "component-model", feature = "gc")))]
1053+
if enable && all.is_none() {
1054+
anyhow::bail!("support for `component-model-gc` was disabled at compile time")
1055+
}
1056+
}
1057+
10451058
Ok(())
10461059
}
10471060

crates/wasmtime/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,21 @@ impl Config {
11711171
self
11721172
}
11731173

1174+
/// Configures whether the [GC extension to the component-model
1175+
/// proposal][proposal] is enabled or not.
1176+
///
1177+
/// This corresponds to the 🛸 emoji in the component model specification.
1178+
///
1179+
/// Please note that Wasmtime's support for this feature is _very_
1180+
/// incomplete.
1181+
///
1182+
/// [proposal]: https://github.com/WebAssembly/component-model/issues/525
1183+
#[cfg(feature = "component-model")]
1184+
pub fn wasm_component_model_gc(&mut self, enable: bool) -> &mut Self {
1185+
self.wasm_feature(WasmFeatures::CM_GC, enable);
1186+
self
1187+
}
1188+
11741189
#[doc(hidden)] // FIXME(#3427) - if/when implemented then un-hide this
11751190
pub fn wasm_exceptions(&mut self, enable: bool) -> &mut Self {
11761191
self.wasm_feature(WasmFeatures::EXCEPTIONS, enable);

0 commit comments

Comments
 (0)