authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-22 21:59:56+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-23 12:39:40-07:00
logbe1e1fa180f333bb4c0818b988eb30e87773a583
tree56fbc8acf939bd7c443eb2687bc84271cb03ae74
parent718f8d531488866ff3623c83e05d8ad9a8f72659

std.Build.Step.Run: Fix invocation syntax for Wasmtime 14+.

https://github.com/bytecodealliance/wasmtime/issues/7384

1 files changed, 16 insertions(+), 1 deletions(-)

lib/std/Build/Step/Run.zig+16-1
...@@ -1007,10 +1007,25 @@ fn runCommand(...@@ -1007,10 +1007,25 @@ fn runCommand(
1007 },1007 },
1008 .wasmtime => |bin_name| {1008 .wasmtime => |bin_name| {
1009 if (b.enable_wasmtime) {1009 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.
1010 try interp_argv.append(bin_name);1025 try interp_argv.append(bin_name);
1011 try interp_argv.append("--dir=.");1026 try interp_argv.append("--dir=.");
1012 try interp_argv.append(argv[0]);
1013 try interp_argv.append("--");1027 try interp_argv.append("--");
1028 try interp_argv.append(argv[0]);
1014 try interp_argv.appendSlice(argv[1..]);1029 try interp_argv.appendSlice(argv[1..]);
1015 } else {1030 } else {
1016 return failForeign(run, "-fwasmtime", argv[0], exe);1031 return failForeign(run, "-fwasmtime", argv[0], exe);