From cc29f0686379187733fe8824a2bea3ec63d93448 Mon Sep 17 00:00:00 2001 From: widberg Date: Thu, 4 Jan 2024 21:24:15 -0500 Subject: [PATCH 1/3] Don't build with LTO on Windows --- build.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.zig b/build.zig index 8856eb766..bed0bf0e0 100644 --- a/build.zig +++ b/build.zig @@ -251,6 +251,10 @@ pub fn build(b: *std.Build) !void { ); } + // Building with LTO on Windows is broken. + // https://github.com/ziglang/zig/issues/15958 + if (target.isWindows()) exe.want_lto = false; + // If we're installing, we get the install step so we can add // additional dependencies to it. const install_step = if (app_runtime != .none) step: { From 2e79b5c63dbb1ce8950e16990a8951d0c5e325fb Mon Sep 17 00:00:00 2001 From: widberg Date: Thu, 4 Jan 2024 21:24:24 -0500 Subject: [PATCH 2/3] Use `cmd.exe` instead of `sh` on Windows --- src/termio/Exec.zig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index be8a6678f..04ea9293b 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1090,14 +1090,21 @@ const Subprocess = struct { break :args try args.toOwnedSlice(); } - // We run our shell wrapped in `/bin/sh` so that we don't have - // to parse the commadnd line ourselves if it has arguments. - // Additionally, some environments (NixOS, I found) use /bin/sh - // to setup some environment variables that are important to - // have set. - try args.append("/bin/sh"); - if (internal_os.isFlatpak()) try args.append("-l"); - try args.append("-c"); + if (builtin.os.tag == .windows) { + // We run our shell wrapped in `cmd.exe` so that we don't have + // to parse the command line ourselves if it has arguments. + try args.append("C:\\Windows\\System32\\cmd.exe"); + try args.append("/C"); + } else { + // We run our shell wrapped in `/bin/sh` so that we don't have + // to parse the command line ourselves if it has arguments. + // Additionally, some environments (NixOS, I found) use /bin/sh + // to setup some environment variables that are important to + // have set. + try args.append("/bin/sh"); + if (internal_os.isFlatpak()) try args.append("-l"); + try args.append("-c"); + } try args.append(opts.full_config.command orelse default_path); break :args try args.toOwnedSlice(); }; From 38c5258d6e88e7d5e1ff7ae52e3bd8d3dd4b0a87 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 4 Jan 2024 19:48:08 -0800 Subject: [PATCH 3/3] termio/exec: small change --- src/termio/Exec.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 04ea9293b..8c55fa114 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1090,7 +1090,7 @@ const Subprocess = struct { break :args try args.toOwnedSlice(); } - if (builtin.os.tag == .windows) { + if (comptime builtin.os.tag == .windows) { // We run our shell wrapped in `cmd.exe` so that we don't have // to parse the command line ourselves if it has arguments. try args.append("C:\\Windows\\System32\\cmd.exe"); @@ -1105,6 +1105,7 @@ const Subprocess = struct { if (internal_os.isFlatpak()) try args.append("-l"); try args.append("-c"); } + try args.append(opts.full_config.command orelse default_path); break :args try args.toOwnedSlice(); };