Skip to content

Commit be1e1fa

Browse files
alexrpandrewrk
authored andcommitted
std.Build.Step.Run: Fix invocation syntax for Wasmtime 14+.
bytecodealliance/wasmtime#7384
1 parent 718f8d5 commit be1e1fa

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,25 @@ fn runCommand(
10071007
},
10081008
.wasmtime => |bin_name| {
10091009
if (b.enable_wasmtime) {
1010+
// https://github.com/bytecodealliance/wasmtime/issues/7384
1011+
//
1012+
// In Wasmtime versions prior to 14, options passed after the module name
1013+
// could be interpreted by Wasmtime if it recognized them. As with many CLI
1014+
// tools, the `--` token is used to stop that behavior and indicate that the
1015+
// remaining arguments are for the WASM program being executed. Historically,
1016+
// we passed `--` after the module name here.
1017+
//
1018+
// After version 14, the `--` can no longer be passed after the module name,
1019+
// but is also not necessary as Wasmtime will no longer try to interpret
1020+
// options after the module name. So, we could just simply omit `--` for
1021+
// newer Wasmtime versions. But to maintain compatibility for older versions
1022+
// that still try to interpret options after the module name, we have moved
1023+
// the `--` before the module name. This appears to work for both old and
1024+
// new Wasmtime versions.
10101025
try interp_argv.append(bin_name);
10111026
try interp_argv.append("--dir=.");
1012-
try interp_argv.append(argv[0]);
10131027
try interp_argv.append("--");
1028+
try interp_argv.append(argv[0]);
10141029
try interp_argv.appendSlice(argv[1..]);
10151030
} else {
10161031
return failForeign(run, "-fwasmtime", argv[0], exe);

0 commit comments

Comments
 (0)