srctree

Elaine Gibson parent 6724a524 6b387585
coff: only store PDB basename

inlinesplit
lib/std/coff.zig added: 20, removed: 22, total 0
@@ -1101,7 +1101,7 @@ pub const Coff = struct {
return coff;
}
 
pub fn getPdbPath(self: *Coff, buffer: []u8) !?usize {
pub fn getPdbPath(self: *Coff) !?[]const u8 {
assert(self.is_image);
 
const data_dirs = self.getDataDirectories();
@@ -1145,17 +1145,9 @@ pub const Coff = struct {
self.age = try reader.readInt(u32, .little);
 
// Finally read the null-terminated string.
var byte = try reader.readByte();
i = 0;
while (byte != 0 and i < buffer.len) : (i += 1) {
buffer[i] = byte;
byte = try reader.readByte();
}
 
if (byte != 0 and i == buffer.len)
return error.NameTooLong;
 
return @as(usize, i);
const start = reader.context.pos;
const len = std.mem.indexOfScalar(u8, self.data[start..], 0) orelse return null;
return self.data[start .. start + len];
}
 
pub fn getCoffHeader(self: Coff) CoffHeader {
 
lib/std/debug.zig added: 20, removed: 22, total 0
@@ -1093,12 +1093,17 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_obj: *coff.Coff) !ModuleDebu
di.dwarf = dwarf;
}
 
var path_buf: [windows.MAX_PATH]u8 = undefined;
const len = try coff_obj.getPdbPath(path_buf[0..]) orelse return di;
const raw_path = path_buf[0..len];
 
const path = try fs.path.resolve(allocator, &[_][]const u8{raw_path});
defer allocator.free(path);
const raw_path = try coff_obj.getPdbPath() orelse return di;
const path = blk: {
if (fs.path.isAbsolute(raw_path)) {
break :blk raw_path;
} else {
const self_dir = try fs.selfExeDirPathAlloc(allocator);
defer allocator.free(self_dir);
break :blk try fs.path.join(allocator, &.{ self_dir, raw_path });
}
};
defer if (path.ptr != raw_path.ptr) allocator.free(path);
 
di.pdb = pdb.Pdb.init(allocator, path) catch |err| switch (err) {
error.FileNotFound, error.IsDir => {
 
src/link/Coff/lld.zig added: 20, removed: 22, total 0
@@ -184,9 +184,10 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
const out_pdb = self.pdb_out_path orelse try allocPrint(arena, "{s}.pdb", .{
full_out_path[0 .. full_out_path.len - out_ext.len],
});
const out_pdb_basename = std.fs.path.basename(out_pdb);
 
try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb}));
try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb}));
try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename}));
}
if (comp.version) |version| {
try argv.append(try allocPrint(arena, "-VERSION:{}.{}", .{ version.major, version.minor }));