authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2026-02-02 01:20:16+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-11 12:23:49-07:00
log3d482643651285143b555b61c5a6a48db6fc8518
tree119e39d56c7d0a9b036eef18441bd74860cb8efa
parent0bbf0461d9800ce5eba28cd32ef10492b2f80639

Fix `-fwasmtime` not inheriting environment variables


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

lib/std/Build/Step/Run.zig+3-16
...@@ -1323,24 +1323,11 @@ fn runCommand(...@@ -1323,24 +1323,11 @@ fn runCommand(
1323 },1323 },
1324 .wasmtime => |bin_name| {1324 .wasmtime => |bin_name| {
1325 if (b.enable_wasmtime) {1325 if (b.enable_wasmtime) {
1326 // https://github.com/bytecodealliance/wasmtime/issues/7384
1327 //
1328 // In Wasmtime versions prior to 14, options passed after the module name
1329 // could be interpreted by Wasmtime if it recognized them. As with many CLI
1330 // tools, the `--` token is used to stop that behavior and indicate that the
1331 // remaining arguments are for the WASM program being executed. Historically,
1332 // we passed `--` after the module name here.
1333 //
1334 // After version 14, the `--` can no longer be passed after the module name,
1335 // but is also not necessary as Wasmtime will no longer try to interpret
1336 // options after the module name. So, we could just simply omit `--` for
1337 // newer Wasmtime versions. But to maintain compatibility for older versions
1338 // that still try to interpret options after the module name, we have moved
1339 // the `--` before the module name. This appears to work for both old and
1340 // new Wasmtime versions.
1341 try interp_argv.append(bin_name);1326 try interp_argv.append(bin_name);
1342 try interp_argv.append("--dir=.");1327 try interp_argv.append("--dir=.");
1343 try interp_argv.append("--");1328 // Wasmtime doeesn't inherit environment variables from the parent process
1329 // by default. '-S inherit-env' was added in Wasmtime version 20.
1330 try interp_argv.append("-Sinherit-env");
1344 try interp_argv.append(argv[0]);1331 try interp_argv.append(argv[0]);
1345 try interp_argv.appendSlice(argv[1..]);1332 try interp_argv.appendSlice(argv[1..]);
1346 } else {1333 } else {