Skip to content

Commit

Permalink
Enable the component model by default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Jan 25, 2024
1 parent e7064d4 commit 5917a52
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`");
}

Expand Down
23 changes: 23 additions & 0 deletions tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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]
Expand Down

0 comments on commit 5917a52

Please sign in to comment.