Skip to content

Commit

Permalink
Add support for -Wunknown-imports-trap to components
Browse files Browse the repository at this point in the history
This was implemented in bytecodealliance#8672 and is an easy addition to the CLI.

Closes bytecodealliance#9019
  • Loading branch information
alexcrichton committed Jul 26, 2024
1 parent 3e97612 commit 51b5dd8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,28 +375,24 @@ 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"),
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 51b5dd8

Please sign in to comment.