From 8a76e2569aa08ee74e50c4449ffa9a57b84abd9c Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Sat, 9 Jul 2022 21:20:41 -0700 Subject: [PATCH] fix(wasm): Version modules by wasmtime version Compiled modules can't be shared across wasmtime versions. Make sure to include the current version of wasmtime in the module filename. --- internal/ext/wasm/wasm.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/ext/wasm/wasm.go b/internal/ext/wasm/wasm.go index 10fa846278..a55d8551d1 100644 --- a/internal/ext/wasm/wasm.go +++ b/internal/ext/wasm/wasm.go @@ -24,6 +24,9 @@ import ( "github.com/kyleconroy/sqlc/internal/plugin" ) +// This version must be updated whenever the wasmtime-go dependency is updated +const wasmtimeVersion = `v0.38.1` + func cacheDir() (string, error) { cache := os.Getenv("SQLCCACHE") if cache != "" { @@ -68,7 +71,8 @@ func (r *Runner) loadModule(ctx context.Context, engine *wasmtime.Engine) (*wasm } pluginDir := filepath.Join(cache, expected) - modPath := filepath.Join(pluginDir, fmt.Sprintf("plugin_%s_%s.module", runtime.GOOS, runtime.GOARCH)) + modName := fmt.Sprintf("plugin_%s_%s_%s.module", runtime.GOOS, runtime.GOARCH, wasmtimeVersion) + modPath := filepath.Join(pluginDir, modName) _, staterr := os.Stat(modPath) if staterr == nil { data, err := os.ReadFile(modPath)