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 {
10351035 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
10361036 dead_strip_dylibs: bool = false,
10371037 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,
10411038};
10421039
10431040fn addPackageTableToCacheHash(
......@@ -1740,27 +1737,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
17401737 };
17411738 };
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
17641740 const implib_emit: ?link.Emit = blk: {
17651741 const emit_implib = options.emit_implib orelse break :blk null;
17661742
......@@ -1906,7 +1882,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
19061882 .headerpad_max_install_names = options.headerpad_max_install_names,
19071883 .dead_strip_dylibs = options.dead_strip_dylibs,
19081884 .force_undefined_symbols = .{},
1909 .pdb_source_path = pdb_source_path,
19101885 });
19111886 errdefer bin_file.destroy();
19121887 comp.* = .{
src/link.zig-4
......@@ -217,10 +217,6 @@ pub const Options = struct {
217217 /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
218218 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
224220 pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {
225221 return if (options.use_lld) .Obj else options.output_mode;
226222 }
src/link/Coff/lld.zig-4
......@@ -171,10 +171,6 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
171171 });
172172 try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb}));
173173 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 }
178174 }
179175 if (self.base.options.lto) {
180176 switch (self.base.options.optimize_mode) {