Stream: git-wasmtime

Topic: wasmtime / PR #11739 Add the library version


view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2025 at 05:18):

sbeckeriv opened PR #11739 from sbeckeriv:add-library-version to bytecodealliance:main:

Dearest Reviewer,

While using wasmtime I found myself wanting to pre-compile my functions. According to https://github.com/bytecodealliance/wasmtime/pull/11687 The pre-compiled functions should work across minor and patch version changes. I would like to use the version in my cache keys.

My current options are a build script that parses Cargo.toml or I can hard code the current version when I updated my Cargo.toml version.

Providing the built version will allow users of wasttime to ergonomically access the version to use.

Discussed in https://bytecodealliance.zulipchat.com/#narrow/channel/217126-wasmtime/topic/wasmtime.20version.20access/with/541092841 I opted for a const instead of a function.

Thanks for reviewing,
becker

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2025 at 05:18):

sbeckeriv requested alexcrichton for a review on PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2025 at 05:18):

sbeckeriv requested wasmtime-core-reviewers for a review on PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2025 at 14:34):

bjorn3 commented on PR #11739:

Don't you need the ABI version of the compiled modules instead? That is currently a combination of env!("CARGO_PKG_VERSION_MAJOR") and the VERSION static in crates/wasmtime/src/engine/serialization.rs by default. Maybe extract a function to compute an opaque string with all this information to be reused both at the producer and consumer side?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2025 at 16:32):

pchickey commented on PR #11739:

Agreed with bjorn3, I think it is more useful to extract the meaningful aspects of the versioning check from https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasmtime/src/engine/serialization.rs#L46 into a method on Engine, since it can change with Config.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 03:20):

sbeckeriv updated PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 03:38):

sbeckeriv updated PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 03:49):

sbeckeriv updated PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 08:57):

bjorn3 created PR review comment:

Please also change the producer side to call this function.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 08:57):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2025 at 14:44):

sbeckeriv updated PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2025 at 05:06):

sbeckeriv updated PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 29 2025 at 17:03):

alexcrichton commented on PR #11739:

@sbeckeriv for hashing purposes have you seen precompile_compatibility_hash? I forget if that includes the version information, but if it doesn't it probably should. Have you tested out using that for your caching purposes? (it might remove the need for this standalone function)

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2025 at 04:31):

sbeckeriv closed without merge PR #11739.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2025 at 04:31):

sbeckeriv commented on PR #11739:

Thanks!

It does look like the hasher includes the ModuleVersionStrategy https://github.com/bytecodealliance/wasmtime/blob/7380932631f7784d944cb0326a6ffaaf5dac29fc/crates/wasmtime/src/compile/code_builder.rs#L315

I can use this code in my file cache names.

use std::hash::Hasher;
use std::hash::DefaultHasher;

let engine = Engine::new(&config)?;

let compatibility_hash = engine.precompile_compatibility_hash();
let mut hasher = DefaultHasher::new();
compatibility_hash.hash(&mut hasher);
let hash_value = hasher.finish();

println!("Hash value: {}", hash_value);`


Last updated: Dec 06 2025 at 07:03 UTC