Description
Wasmtime currently performs a slightly complicated dance to allow a guest import/export of an interface to be linked with a different but semver-compatible host version of that interface. For a description of why this behavior was implemented see bytecodealliance/wasmtime#7860. Based on a discussion with @lukewagner and @alexcrichton we think this behavior can be brought into the spec itself with some relatively straightforward changes:
-
Define "interface version canonicalization", meaning roughly "trimming a version down to the part that matters for compatibility"
- e.g.
0.2.5
→0.2
,1.2.3
→1
- See Add BuildTargets.md #378; specifically https://github.com/WebAssembly/component-model/blob/3c6c4a9f1228676a342d2f971ced73b0e0ba0d2b/design/mvp/BuildTargets.md#interface-name-canonicalization
The definition in this PR preserves semver prerelease tags but we think that may not be necessary.
- e.g.
-
Update
<version>
to allow canonical versions in addition to full semver:x
(x > 0) and0.y
(y > 0) -
To allow round-tripping WIT and nicer error messages, add an optional field to imports/exports that preserves the original full version
- This could contain the entire version (
1.2.3
) or just the trimmed suffix (.2.3
/2.3
)
- This could contain the entire version (
-
(pre-1.0) start enforcing (instead of just allowing) canonical
<version>
s
With these spec changes, bindings generators would start emitting canonicalized versions in import/export names. This should effectively give behavior similar to what the Wasmtime linker does today, and additionally should solve the same underlying version compatibility problems for other tools like wac and wasi-virt.