diff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs index dc6bf416aa..c81ae6e67d 100644 --- a/crates/wasmtime/src/engine.rs +++ b/crates/wasmtime/src/engine.rs @@ -390,7 +390,8 @@ impl Engine { } } - let enabled; + #[allow(unused_assignments)] + let mut enabled = None; #[cfg(target_arch = "aarch64")] { @@ -403,6 +404,24 @@ impl Engine { }; } + // There is no is_s390x_feature_detected macro yet, so for now + // we use getauxval from the libc crate directly. + #[cfg(all(target_arch = "s390x", target_os = "linux"))] + { + let v = unsafe { libc::getauxval(libc::AT_HWCAP) }; + const HWCAP_S390X_VXRS_EXT2: libc::c_ulong = 32768; + + enabled = match flag { + // There is no separate HWCAP bit for mie2, so assume + // that any machine with vxrs_ext2 also has mie2. + "has_vxrs_ext2" | "has_mie2" => Some((v & HWCAP_S390X_VXRS_EXT2) != 0), + // fall through to the very bottom to indicate that support is + // not enabled to test whether this feature is enabled on the + // host. + _ => None, + } + } + #[cfg(target_arch = "x86_64")] { enabled = match flag { @@ -429,11 +448,6 @@ impl Engine { }; } - #[cfg(not(any(target_arch = "aarch64", target_arch = "x86_64")))] - { - enabled = None; - } - match enabled { Some(true) => return Ok(()), Some(false) => {