Stream: wasmtime

Topic: Selecting Cranelift ISA in wasmtime::Config


view this post on Zulip Andrew Gutekanst (Mar 20 2024 at 17:14):

Hello! This is probably a bit of a dumb/weird question, but hoping that maybe someone knows the answer to this.

I'm trying to precompile wasm modules to be run on other machines with slightly old(er) x86_64 CPUs (without AVX512). If I understand correctly, I _should_ be able to somehow select the one of these ISA micro-architecture versions in Cranelift with the CPU features I want:
https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/meta/src/isa/x86.rs#L384-L399

I've tried setting the target triple on the wasmtime::Config to x86_64_v3-unknown-linux-gnu, but I just get an "Unrecognized Architecture: x86_64_v3" error from the target-lexicon crate.

Is there another way that I can specify this directly, or is this a matter of updating the target-lexicon create to support this?

Target "triple" support. Contribute to bytecodealliance/target-lexicon development by creating an account on GitHub.

view this post on Zulip Alex Crichton (Mar 20 2024 at 17:19):

You should be able to do this by:

By default wasmtime infers features from the host, but once a target is set that inference is disabled and you have to re-enable anything over the bare-minimum baseline

view this post on Zulip Alex Crichton (Mar 20 2024 at 17:19):

although packaging that all up as a target string through support in target-lexicon would still be nice to have regardless

view this post on Zulip Andrew Gutekanst (Mar 20 2024 at 19:02):

Oh shoot. Thanks!

view this post on Zulip Andrew Gutekanst (Mar 20 2024 at 19:05):

It wasn't working when I set the target triple to that - but I just realized that I'm 2 minor versions behind this fix was merged:
https://github.com/bytecodealliance/wasmtime/pull/7991

So I suspect that will solve my issue :)

Thanks for the help!

This commit fixes an accidental regression from #7766 where infer_native_flags is called even if a target is explicitly specified to a Config. Now inference only happens if a target isn't specified...

Last updated: Nov 22 2024 at 17:03 UTC