Hi, I wonder if it's possible to load a pre-compiled module which was serialized by a different version of wasmtime? The use case is to upgrade wasmtime runtime without re-generating all the AOTs. I'm aware there's the precompile_compatibility_hash
function, but want to get a bit more details behind it. Thanks!
there is an option to ignore that hash that makes it possible, but its dangerous
the serialization format may change between versions, and we cant predict how that will invalidate the serialized artifacts
we left that escape hatch in to ignore the compatibility hash so that we had a way to roll out a patch to something we know doesnt make a difference to that serialization format (for example, fixing a buggy isle rule in cranelift) and send those modules to an unpatches runtime
but for anything besides that, i'd recommend not risking it unless you are willing to do a very careful audit of all the structures that get serialized into those cwasms and how they changed between versions.
I see, that's a fair point. Thank you Pat!
The precompile_compatibility_hash
function just hashes the exact same data that the compiler uses to check compatibility, which consists primarily of the wasmtime version string and various CPU features.
Guess I have to bundle multiple runtime versions into the host program, to make the upgrade smooth. Looks like 12.0 added support for that.
anb has marked this topic as resolved.
the thing I would be most scared of here is not a change to the way we package the compiled code into ELF sections (since that would probably fail pretty loudly when we tried to eg find a section with an old name that isn't in the file anymore)
the thing I would be really scared of is something like a change to the layout of the vmctx. in this scenario, we would load the code into a Module
just fine, but you'd get UB as soon as you called into Wasm
Last updated: Dec 23 2024 at 14:03 UTC