authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-09 12:57:15+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-09 14:16:44+01:00
log182751ba27edf64304d2ae78043576b78c45fc1c
treec76ef52fe2d8f18d01ff2aef37fb3e2b814d725a
parent4d640f9bb98d334f7fab8d3037a36cfd95dc174a

Revert "coff: specify default base path for relative source paths in pdb"


3 files changed, 0 insertions(+), 33 deletions(-)

src/Compilation.zig-25
...@@ -1035,9 +1035,6 @@ pub const InitOptions = struct {...@@ -1035,9 +1035,6 @@ pub const InitOptions = struct {
1035 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols1035 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
1036 dead_strip_dylibs: bool = false,1036 dead_strip_dylibs: bool = false,
1037 libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,1037 libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
1038 /// (Windows) PDB source path prefix to instruct the linker how to resolve relative
1039 /// paths when consolidating CodeView streams into a single PDB file.
1040 pdb_source_path: ?[]const u8 = null,
1041};1038};
10421039
1043fn addPackageTableToCacheHash(1040fn addPackageTableToCacheHash(
...@@ -1740,27 +1737,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1740,27 +1737,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1740 };1737 };
1741 };1738 };
17421739
1743 const pdb_source_path: ?[]const u8 = options.pdb_source_path orelse blk: {
1744 if (builtin.target.os.tag == .windows) {
1745 // PDB requires all file paths to be fully resolved, and it is really the
1746 // linker's responsibility to canonicalize any path extracted from the CodeView
1747 // in the object file. However, LLD-link has some very questionable defaults, and
1748 // in particular, it purposely bakes in path separator of the host system it was
1749 // built on rather than the targets, or just throw an error. Thankfully, they have
1750 // left a backdoor we can use via -PDBSOURCEPATH.
1751 const mod = module orelse break :blk null;
1752 var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
1753 const resolved_path = if (mod.main_pkg.root_src_directory.path) |base_path| p: {
1754 if (std.fs.path.isAbsolute(base_path)) break :blk base_path;
1755 const resolved_path = std.os.realpath(base_path, &buffer) catch break :blk null;
1756 const pos = std.mem.lastIndexOfLinear(u8, resolved_path, base_path) orelse resolved_path.len;
1757 break :p resolved_path[0..pos];
1758 } else std.os.realpath(".", &buffer) catch break :blk null;
1759 break :blk try arena.dupe(u8, resolved_path);
1760 }
1761 break :blk null;
1762 };
1763
1764 const implib_emit: ?link.Emit = blk: {1740 const implib_emit: ?link.Emit = blk: {
1765 const emit_implib = options.emit_implib orelse break :blk null;1741 const emit_implib = options.emit_implib orelse break :blk null;
17661742
...@@ -1906,7 +1882,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1906,7 +1882,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1906 .headerpad_max_install_names = options.headerpad_max_install_names,1882 .headerpad_max_install_names = options.headerpad_max_install_names,
1907 .dead_strip_dylibs = options.dead_strip_dylibs,1883 .dead_strip_dylibs = options.dead_strip_dylibs,
1908 .force_undefined_symbols = .{},1884 .force_undefined_symbols = .{},
1909 .pdb_source_path = pdb_source_path,
1910 });1885 });
1911 errdefer bin_file.destroy();1886 errdefer bin_file.destroy();
1912 comp.* = .{1887 comp.* = .{
src/link.zig-4
...@@ -217,10 +217,6 @@ pub const Options = struct {...@@ -217,10 +217,6 @@ pub const Options = struct {
217 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols217 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
218 dead_strip_dylibs: bool = false,218 dead_strip_dylibs: bool = false,
219219
220 /// (Windows) PDB source path prefix to instruct the linker how to resolve relative
221 /// paths when consolidating CodeView streams into a single PDB file.
222 pdb_source_path: ?[]const u8 = null,
223
224 pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {220 pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {
225 return if (options.use_lld) .Obj else options.output_mode;221 return if (options.use_lld) .Obj else options.output_mode;
226 }222 }
src/link/Coff/lld.zig-4
...@@ -171,10 +171,6 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -171,10 +171,6 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
171 });171 });
172 try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb}));172 try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb}));
173 try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb}));173 try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb}));
174
175 if (self.base.options.pdb_source_path) |path| {
176 try argv.append(try std.fmt.allocPrint(arena, "-PDBSOURCEPATH:{s}", .{path}));
177 }
178 }174 }
179 if (self.base.options.lto) {175 if (self.base.options.lto) {
180 switch (self.base.options.optimize_mode) {176 switch (self.base.options.optimize_mode) {