Is the standard library compiled with target-feature=+simd128 on wasm32-unknown-unknown?

Hello,

I am compiling a relatively big project for the target wasm32-unknown-unknown. I noticed that in dev. builds, some v128 SIMD types are used, although I do not set up target-feature=+simd128 in my RUSTFLAGS. In particular, in the generated code, I see the following function:

(func $memchr::arch::wasm32::simd128::packedpair::Finder::find_impl::h5393de7f1a212dde (type 23) (param i32 i32 i32 i32 i32 i32)
    (local i32 ... i32 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128 v128)

that seems to come from the memchr package, used both by the standard library and common libraries (such as regex).

At this point it is unclear for me whether this comes from the pre-built standard library, or from one of my dependencies that somehow would be able to change the target feature flags. The later seems unlikely so I'm favoring the former. I looked for documentation on what features wasm32-unknown-unknown entails but did not find any (so I opened a documentation bug).

This is a problem because some not-so-old iOS Safari do not support WASM SIMD, and a wasm binary containing them will fail to load with an error such as:

CompileError: WebAssembly.Module doesn't parse at byte X: can't get Function local's type in group Y, in function at index Z

So, does anyone knows whether the standard library is compiled with target-feature=+simd128 on wasm32-unknown-unknown and whether that is a conscious and motivated decision?

2 Likes

I have attempted to answer the question myself. If I am not mistaken, the conclusion is that as of version 1.75, the standard library is not using any WebAssembly SIMD instructions. Here is my test:

for file in $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/*; do
    ar -x "$file"
done
for file in *.o; do
    if wasm-objdump -d "$file" | grep -q 'v128'; then
        echo "$file"
    fi
done