Skip to content

Commit

Permalink
Add support for -Wunknown-imports-trap to components (#9021)
Browse files Browse the repository at this point in the history
* Add support for `-Wunknown-imports-trap` to components

This was implemented in #8672 and is an easy addition to the CLI.

Closes #9019

* Fix non-component CLI build
  • Loading branch information
alexcrichton authored Jul 26, 2024
1 parent a47d511 commit 57049dd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,28 +375,25 @@ impl RunCommand {
// The main module might be allowed to have unknown imports, which
// should be defined as traps:
if self.run.common.wasm.unknown_imports_trap == Some(true) {
#[cfg(feature = "cranelift")]
match linker {
CliLinker::Core(linker) => {
linker.define_unknown_imports_as_traps(module.unwrap_core())?;
}
_ => bail!("cannot use `--trap-unknown-imports` with components"),
#[cfg(feature = "component-model")]
CliLinker::Component(linker) => {
linker.define_unknown_imports_as_traps(module.unwrap_component())?;
}
}
#[cfg(not(feature = "cranelift"))]
bail!("support for `unknown-imports-trap` disabled at compile time");
}

// ...or as default values.
if self.run.common.wasm.unknown_imports_default == Some(true) {
#[cfg(feature = "cranelift")]
match linker {
CliLinker::Core(linker) => {
linker.define_unknown_imports_as_default_values(module.unwrap_core())?;
}
_ => bail!("cannot use `--default-values-unknown-imports` with components"),
}
#[cfg(not(feature = "cranelift"))]
bail!("support for `unknown-imports-trap` disabled at compile time");
}

let finish_epoch_handler = self.setup_epoch_handler(store, modules)?;
Expand Down

0 comments on commit 57049dd

Please sign in to comment.