From 51b5dd8355f1a2d078ea71ee470c695e20ff55bd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 26 Jul 2024 08:20:43 -0700 Subject: [PATCH] Add support for `-Wunknown-imports-trap` to components This was implemented in #8672 and is an easy addition to the CLI. Closes #9019 --- src/commands/run.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/commands/run.rs b/src/commands/run.rs index 1c160959989a..df186abbf0b9 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -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)?;