From dd8df1caf33291c2deddf684354c3dd80c402b45 Mon Sep 17 00:00:00 2001 From: "J.C. Moyer" Date: Fri, 7 Oct 2022 06:39:50 -0400 Subject: [PATCH] Windows: Explicitly pass PDB paths to lld-link On Windows, lld-link resolves PDB output paths using `/` and embeds the result in the final executable, which breaks some native tooling like WPR/WPA. This commit overrides the default behavior of lld-link by explicitly setting the output PDB filename and binary-embedded path. --- src/link/Coff/lld.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig index 7047d4fdba..9d9d1e4094 100644 --- a/src/link/Coff/lld.zig +++ b/src/link/Coff/lld.zig @@ -181,6 +181,13 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod try argv.append("-NOLOGO"); if (!self.base.options.strip) { try argv.append("-DEBUG"); + + const out_ext = std.fs.path.extension(full_out_path); + const out_pdb = try allocPrint(arena, "{s}.pdb", .{ + full_out_path[0 .. full_out_path.len - out_ext.len], + }); + try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb})); + try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb})); } if (self.base.options.lto) { switch (self.base.options.optimize_mode) {