Skip to content

Commit

Permalink
Enable the component model by default (bytecodealliance#7821)
Browse files Browse the repository at this point in the history
* 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.

* Fix non-component model build
  • Loading branch information
alexcrichton authored Jan 25, 2024
1 parent 30f2c8b commit 94b3e84
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ 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);

// 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 94b3e84

Please sign in to comment.