MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / _check_compatible_with_native_host

Method _check_compatible_with_native_host

crates/wasmtime/src/engine.rs:343–417  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

341 }
342
343 fn _check_compatible_with_native_host(&self) -> Result<(), String> {
344 use target_lexicon::Triple;
345
346 let host = Triple::host();
347 let target = self.config().compiler_target();
348
349 let target_matches_host = || {
350 // If the host target and target triple match, then it's valid
351 // to run results of compilation on this host.
352 if host == target {
353 return true;
354 }
355
356 // If there's a mismatch and the target is a compatible pulley
357 // target, then that's also ok to run.
358 if cfg!(feature = "pulley")
359 && target.is_pulley()
360 && target.pointer_width() == host.pointer_width()
361 && target.endianness() == host.endianness()
362 {
363 return true;
364 }
365
366 // ... otherwise everything else is considered not a match.
367 false
368 };
369
370 if !target_matches_host() {
371 return Err(format!(
372 "target '{target}' specified in the configuration does not match the host"
373 ));
374 }
375
376 #[cfg(any(feature = "cranelift", feature = "winch"))]
377 {
378 if let Some(compiler) = self.compiler() {
379 // Also double-check all compiler settings
380 for (key, value) in compiler.flags().iter() {
381 self.check_compatible_with_shared_flag(key, value)?;
382 }
383 for (key, value) in compiler.isa_flags().iter() {
384 self.check_compatible_with_isa_flag(key, value)?;
385 }
386 }
387 }
388
389 // Double-check that this configuration isn't requesting capabilities
390 // that this build of Wasmtime doesn't support.
391 if !cfg!(has_native_signals) && self.tunables().signals_based_traps {
392 return Err("signals-based-traps disabled at compile time -- cannot be enabled".into());
393 }
394 if !cfg!(has_virtual_memory) && self.tunables().memory_init_cow {
395 return Err("virtual memory disabled at compile time -- cannot enable CoW".into());
396 }
397 if !cfg!(target_has_atomic = "64") && self.tunables().epoch_interruption {
398 return Err("epochs currently require 64-bit atomics".into());
399 }
400

Callers 1

Calls 13

OkFunction · 0.85
compiler_targetMethod · 0.80
configMethod · 0.45
is_pulleyMethod · 0.45
pointer_widthMethod · 0.45
endiannessMethod · 0.45
compilerMethod · 0.45
iterMethod · 0.45
flagsMethod · 0.45
isa_flagsMethod · 0.45

Tested by

no test coverage detected