diff --git a/src/build/Config.zig b/src/build/Config.zig index 53d3c737b..eaaeaac90 100644 --- a/src/build/Config.zig +++ b/src/build/Config.zig @@ -83,6 +83,19 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config { result = genericMacOSTarget(b, result.query.cpu_arch); } + // On Windows, default to the MSVC ABI so that produced COFF + // objects (including compiler_rt) are compatible with the MSVC + // linker. Zig defaults to the GNU ABI which produces objects + // with invalid COMDAT sections that MSVC rejects (LNK1143). + // Only override when no explicit ABI was requested. + if (result.result.os.tag == .windows and + result.query.abi == null) + { + var query = result.query; + query.abi = .msvc; + result = b.resolveTargetQuery(query); + } + // If we have no minimum OS version, we set the default based on // our tag. Not all tags have a minimum so this may be null. if (result.query.os_version_min == null) { diff --git a/src/build/GhosttyLibVt.zig b/src/build/GhosttyLibVt.zig index 59e7a46e3..408f1ebc8 100644 --- a/src/build/GhosttyLibVt.zig +++ b/src/build/GhosttyLibVt.zig @@ -110,11 +110,6 @@ fn initLib( // Zig's ubsan emits /exclude-symbols linker directives that // are incompatible with the MSVC linker (LNK4229). lib.bundle_ubsan_rt = false; - - // The self-hosted backend produces COFF objects with invalid - // COMDAT sections in compiler_rt that the MSVC linker rejects - // (LNK1143). Use the LLVM backend to produce valid objects. - lib.use_llvm = true; } if (lib.rootModuleTarget().abi.isAndroid()) {