Skip to content

cannot test if target-specific flag "has_sse42" is available at runtime #4224

Description

@JamesMcGuigan

I am trying to run linux wasmtime on Xeon E5430 CPUs (2007) without SSE4 (Streaming SIMD Extensions 4) support

I am getting the following error:

$ wasmtime gcd.wasm --invoke gcd 42 36

Error: failed to run main module `gcd.wasm`

Caused by:
    0: compilation settings are not compatible with the native host
    1: compilation setting "has_sse42" is enabled but not available on the host

Test Case

WASM code is taken directly from the manual, and is 28 lines of handcoded WAT implementing the GCD (Greatest common divisor) algoritm, and compiled using wat2wasm

Steps to Reproduce

git clone https://github.com/JamesMcGuigan/ecosystem-research/
cd ./ecosystem-research/wasm/wat/gcd
git checkout 04a8056151602f6de71feb6ce12f77f0ddd3cb8e
wat2wasm gcd.wat
wasmtime gcd.wasm --invoke gcd 42 36

Expected Results

WASM file can be validated through a custom nodejs runtime

$ node ./gcd.js 42 36
GCD of 42 and 36 is 6

Actual Results

$ wasmtime gcd.wasm --invoke gcd 42 36

Error: failed to run main module `gcd.wasm`

Caused by:
    0: compilation settings are not compatible with the native host
    1: compilation setting "has_sse42" is enabled but not available on the host

Versions and Environment

I have tired both with the prebuilt binary version of wasmtime

sudo pacman -S wasmtime
wasmtime 0.36.0

I have also tried installing from source:

cd /usr/local/src/
git clone https://github.com/bytecodealliance/wasmtime.git
cd ./wasmtime/
git submodule update --init
cargo clean
cargo build --release
/usr/local/src/wasmtime/target/release/wasmtime --version  
# wasmtime-cli 0.38.0

And then even attempting applying the following diff (which didn't help)

iff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs
index fbef95923..7df50ec5f 100644
--- a/crates/wasmtime/src/engine.rs
+++ b/crates/wasmtime/src/engine.rs
@@ -446,8 +446,8 @@ impl Engine {
             enabled = match flag {
                 "has_sse3" => Some(std::is_x86_feature_detected!("sse3")),
                 "has_ssse3" => Some(std::is_x86_feature_detected!("ssse3")),
-                "has_sse41" => Some(std::is_x86_feature_detected!("sse4.1")),
-                "has_sse42" => Some(std::is_x86_feature_detected!("sse4.2")),
+                // "has_sse41" => Some(std::is_x86_feature_detected!("sse4.1")),
+                // "has_sse42" => Some(std::is_x86_feature_detected!("sse4.2")),
                 "has_popcnt" => Some(std::is_x86_feature_detected!("popcnt")),
                 "has_avx" => Some(std::is_x86_feature_detected!("avx")),
                 "has_avx2" => Some(std::is_x86_feature_detected!("avx2")),
diff --git a/src/commands/compile.rs b/src/commands/compile.rs
index 08c3b06fb..c4d4350dd 100644
--- a/src/commands/compile.rs
+++ b/src/commands/compile.rs
@@ -143,14 +143,14 @@ mod test {
         let command = CompileCommand::try_parse_from(vec![
             "compile",
             "--disable-logging",
-            "--cranelift-enable",
-            "has_sse3",
-            "--cranelift-enable",
-            "has_ssse3",
-            "--cranelift-enable",
-            "has_sse41",
-            "--cranelift-enable",
-            "has_sse42",
+            //"--cranelift-enable",
+            //"has_sse3",
+            //"--cranelift-enable",
+            //"has_ssse3",
+            //"--cranelift-enable",
+            //"has_sse41",
+            // "--cranelift-enable",
+            // "has_sse42",
             "--cranelift-enable",
             "has_avx",
             "--cranelift-enable",

Operating system: Manjaro / Arch Linux

cat /etc/lsb-release
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.2.6
DISTRIB_CODENAME=Qonos
DISTRIB_DESCRIPTION="Manjaro Linux"

Architecture:

cat /proc/cpuinfo

vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5430  @ 2.66GHz
stepping        : 10
microcode       : 0xa0b
cpu MHz         : 2660.057
cache size      : 6144 KB
physical id     : 1
siblings        : 4
core id         : 3
cpu cores       : 4
apicid          : 7
initial apicid  : 7
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl cpuid aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 xsave lahf_lm pti dtherm
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips        : 5322.88
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions