From 5917a52769f3e8d7aaa5b002d4084b1f1613210f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Jan 2024 09:50:19 -0800 Subject: [PATCH 1/2] Enable the component model by default This commit enables the component model by default in the embedding API and the CLI. This means that an opt-in of `-W component-model` is no longer required and additionally `.wasm_component_model(true)` is no longer required. Note that this won't impact existing embeddings since the component model feature doesn't do much less `wasmtime::component` is used, and if that's being used this is probably good news for you. --- crates/wasmtime/src/config.rs | 1 + src/common.rs | 2 +- tests/all/cli_tests.rs | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index fd44bd443990..49f361b087e7 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -228,6 +228,7 @@ impl Config { ret.wasm_multi_value(true); ret.wasm_bulk_memory(true); ret.wasm_simd(true); + ret.wasm_component_model(true); ret.wasm_backtrace_details(WasmBacktraceDetails::Environment); // This is on-by-default in `wasmparser` since it's a stage 4+ proposal diff --git a/src/common.rs b/src/common.rs index 70782c0b321c..2850639d016f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -107,7 +107,7 @@ impl RunCommon { #[cfg(feature = "component-model")] fn ensure_allow_components(&self) -> Result<()> { - if self.common.wasm.component_model != Some(true) { + if self.common.wasm.component_model == Some(false) { bail!("cannot execute a component without `--wasm component-model`"); } diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs index 478c25830628..f5fcc6a5ea58 100644 --- a/tests/all/cli_tests.rs +++ b/tests/all/cli_tests.rs @@ -760,6 +760,7 @@ fn component_missing_feature() -> Result<()> { let wasm = build_wasm(path)?; let output = get_wasmtime_command()? .arg("-Ccache=n") + .arg("-Wcomponent-model=n") .arg(wasm.path()) .output()?; assert!(!output.status.success()); @@ -772,6 +773,7 @@ fn component_missing_feature() -> Result<()> { // also tests with raw *.wat input let output = get_wasmtime_command()? .arg("-Ccache=n") + .arg("-Wcomponent-model=n") .arg(path) .output()?; assert!(!output.status.success()); @@ -784,6 +786,27 @@ fn component_missing_feature() -> Result<()> { Ok(()) } +#[test] +#[cfg_attr(not(feature = "component-model"), ignore)] +fn component_enabled_by_default() -> Result<()> { + let path = "tests/all/cli_tests/component-basic.wat"; + let wasm = build_wasm(path)?; + let output = get_wasmtime_command()? + .arg("-Ccache=n") + .arg(wasm.path()) + .output()?; + assert!(output.status.success()); + + // also tests with raw *.wat input + let output = get_wasmtime_command()? + .arg("-Ccache=n") + .arg(path) + .output()?; + assert!(output.status.success()); + + Ok(()) +} + // If the text format is invalid then the filename should be mentioned in the // error message. #[test] From f85d45f18c8f31fe72f5e829c7404393b458aecd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Jan 2024 10:05:02 -0800 Subject: [PATCH 2/2] Fix non-component model build --- crates/wasmtime/src/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index 49f361b087e7..221c45470753 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -228,6 +228,7 @@ impl Config { ret.wasm_multi_value(true); ret.wasm_bulk_memory(true); ret.wasm_simd(true); + #[cfg(feature = "component-model")] ret.wasm_component_model(true); ret.wasm_backtrace_details(WasmBacktraceDetails::Environment);