Commit dd8df1caf3

J.C. Moyer <jcmoyer32@gmail.com>
2022-10-07 12:39:50
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.
1 parent 2d5fbbb
Changed files (1)
src
link
Coff
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) {