authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-11 21:20:41-07:00
committergravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-25 15:16:46-07:00
logbb531759bcf12191b60ea199594b8d1de30dabe7
treefbfd4826965da61b70895c5c8a7ccae11ad7e608
parent8d2b495b2aa38cc1e0dfe0a7a0c3ffd39d7e7dcc
signaturelock-open Commit is signed but in an unrecognized format.

coff: remove deprecated `Module` usages


1 files changed, 27 insertions(+), 29 deletions(-)

src/link/Coff.zig+27-29
...@@ -1141,7 +1141,7 @@ pub fn updateFunc(self: *Coff, pt: Zcu.PerThread, func_index: InternPool.Index,...@@ -1141,7 +1141,7 @@ pub fn updateFunc(self: *Coff, pt: Zcu.PerThread, func_index: InternPool.Index,
11411141
1142const LowerConstResult = union(enum) {1142const LowerConstResult = union(enum) {
1143 ok: Atom.Index,1143 ok: Atom.Index,
1144 fail: *Module.ErrorMsg,1144 fail: *Zcu.ErrorMsg,
1145};1145};
11461146
1147fn lowerConst(1147fn lowerConst(
...@@ -1151,7 +1151,7 @@ fn lowerConst(...@@ -1151,7 +1151,7 @@ fn lowerConst(
1151 val: Value,1151 val: Value,
1152 required_alignment: InternPool.Alignment,1152 required_alignment: InternPool.Alignment,
1153 sect_id: u16,1153 sect_id: u16,
1154 src_loc: Module.LazySrcLoc,1154 src_loc: Zcu.LazySrcLoc,
1155) !LowerConstResult {1155) !LowerConstResult {
1156 const gpa = self.base.comp.gpa;1156 const gpa = self.base.comp.gpa;
11571157
...@@ -1462,15 +1462,15 @@ pub fn freeNav(self: *Coff, nav_index: InternPool.NavIndex) void {...@@ -1462,15 +1462,15 @@ pub fn freeNav(self: *Coff, nav_index: InternPool.NavIndex) void {
1462pub fn updateExports(1462pub fn updateExports(
1463 self: *Coff,1463 self: *Coff,
1464 pt: Zcu.PerThread,1464 pt: Zcu.PerThread,
1465 exported: Module.Exported,1465 exported: Zcu.Exported,
1466 export_indices: []const u32,1466 export_indices: []const u32,
1467) link.File.UpdateExportsError!void {1467) link.File.UpdateExportsError!void {
1468 if (build_options.skip_non_native and builtin.object_format != .coff) {1468 if (build_options.skip_non_native and builtin.object_format != .coff) {
1469 @panic("Attempted to compile for object format that was disabled by build configuration");1469 @panic("Attempted to compile for object format that was disabled by build configuration");
1470 }1470 }
14711471
1472 const mod = pt.zcu;1472 const zcu = pt.zcu;
1473 const ip = &mod.intern_pool;1473 const ip = &zcu.intern_pool;
1474 const comp = self.base.comp;1474 const comp = self.base.comp;
1475 const target = comp.root_mod.resolved_target.result;1475 const target = comp.root_mod.resolved_target.result;
14761476
...@@ -1478,7 +1478,7 @@ pub fn updateExports(...@@ -1478,7 +1478,7 @@ pub fn updateExports(
1478 // Even in the case of LLVM, we need to notice certain exported symbols in order to1478 // Even in the case of LLVM, we need to notice certain exported symbols in order to
1479 // detect the default subsystem.1479 // detect the default subsystem.
1480 for (export_indices) |export_idx| {1480 for (export_indices) |export_idx| {
1481 const exp = mod.all_exports.items[export_idx];1481 const exp = zcu.all_exports.items[export_idx];
1482 const exported_nav_index = switch (exp.exported) {1482 const exported_nav_index = switch (exp.exported) {
1483 .nav => |nav| nav,1483 .nav => |nav| nav,
1484 .uav => continue,1484 .uav => continue,
...@@ -1490,20 +1490,20 @@ pub fn updateExports(...@@ -1490,20 +1490,20 @@ pub fn updateExports(
1490 .x86 => .Stdcall,1490 .x86 => .Stdcall,
1491 else => .C,1491 else => .C,
1492 };1492 };
1493 const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(mod);1493 const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(zcu);
1494 if (exported_cc == .C and exp.opts.name.eqlSlice("main", ip) and comp.config.link_libc) {1494 if (exported_cc == .C and exp.opts.name.eqlSlice("main", ip) and comp.config.link_libc) {
1495 mod.stage1_flags.have_c_main = true;1495 zcu.stage1_flags.have_c_main = true;
1496 } else if (exported_cc == winapi_cc and target.os.tag == .windows) {1496 } else if (exported_cc == winapi_cc and target.os.tag == .windows) {
1497 if (exp.opts.name.eqlSlice("WinMain", ip)) {1497 if (exp.opts.name.eqlSlice("WinMain", ip)) {
1498 mod.stage1_flags.have_winmain = true;1498 zcu.stage1_flags.have_winmain = true;
1499 } else if (exp.opts.name.eqlSlice("wWinMain", ip)) {1499 } else if (exp.opts.name.eqlSlice("wWinMain", ip)) {
1500 mod.stage1_flags.have_wwinmain = true;1500 zcu.stage1_flags.have_wwinmain = true;
1501 } else if (exp.opts.name.eqlSlice("WinMainCRTStartup", ip)) {1501 } else if (exp.opts.name.eqlSlice("WinMainCRTStartup", ip)) {
1502 mod.stage1_flags.have_winmain_crt_startup = true;1502 zcu.stage1_flags.have_winmain_crt_startup = true;
1503 } else if (exp.opts.name.eqlSlice("wWinMainCRTStartup", ip)) {1503 } else if (exp.opts.name.eqlSlice("wWinMainCRTStartup", ip)) {
1504 mod.stage1_flags.have_wwinmain_crt_startup = true;1504 zcu.stage1_flags.have_wwinmain_crt_startup = true;
1505 } else if (exp.opts.name.eqlSlice("DllMainCRTStartup", ip)) {1505 } else if (exp.opts.name.eqlSlice("DllMainCRTStartup", ip)) {
1506 mod.stage1_flags.have_dllmain_crt_startup = true;1506 zcu.stage1_flags.have_dllmain_crt_startup = true;
1507 }1507 }
1508 }1508 }
1509 }1509 }
...@@ -1519,15 +1519,15 @@ pub fn updateExports(...@@ -1519,15 +1519,15 @@ pub fn updateExports(
1519 break :blk self.navs.getPtr(nav).?;1519 break :blk self.navs.getPtr(nav).?;
1520 },1520 },
1521 .uav => |uav| self.uavs.getPtr(uav) orelse blk: {1521 .uav => |uav| self.uavs.getPtr(uav) orelse blk: {
1522 const first_exp = mod.all_exports.items[export_indices[0]];1522 const first_exp = zcu.all_exports.items[export_indices[0]];
1523 const res = try self.lowerUav(pt, uav, .none, first_exp.src);1523 const res = try self.lowerUav(pt, uav, .none, first_exp.src);
1524 switch (res) {1524 switch (res) {
1525 .mcv => {},1525 .mcv => {},
1526 .fail => |em| {1526 .fail => |em| {
1527 // TODO maybe it's enough to return an error here and let Module.processExportsInner1527 // TODO maybe it's enough to return an error here and let Module.processExportsInner
1528 // handle the error?1528 // handle the error?
1529 try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1);1529 try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1);
1530 mod.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em);1530 zcu.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em);
1531 return;1531 return;
1532 },1532 },
1533 }1533 }
...@@ -1538,12 +1538,12 @@ pub fn updateExports(...@@ -1538,12 +1538,12 @@ pub fn updateExports(
1538 const atom = self.getAtom(atom_index);1538 const atom = self.getAtom(atom_index);
15391539
1540 for (export_indices) |export_idx| {1540 for (export_indices) |export_idx| {
1541 const exp = mod.all_exports.items[export_idx];1541 const exp = zcu.all_exports.items[export_idx];
1542 log.debug("adding new export '{}'", .{exp.opts.name.fmt(&mod.intern_pool)});1542 log.debug("adding new export '{}'", .{exp.opts.name.fmt(&zcu.intern_pool)});
15431543
1544 if (exp.opts.section.toSlice(&mod.intern_pool)) |section_name| {1544 if (exp.opts.section.toSlice(&zcu.intern_pool)) |section_name| {
1545 if (!mem.eql(u8, section_name, ".text")) {1545 if (!mem.eql(u8, section_name, ".text")) {
1546 try mod.failed_exports.putNoClobber(gpa, export_idx, try Module.ErrorMsg.create(1546 try zcu.failed_exports.putNoClobber(gpa, export_idx, try Zcu.ErrorMsg.create(
1547 gpa,1547 gpa,
1548 exp.src,1548 exp.src,
1549 "Unimplemented: ExportOptions.section",1549 "Unimplemented: ExportOptions.section",
...@@ -1554,7 +1554,7 @@ pub fn updateExports(...@@ -1554,7 +1554,7 @@ pub fn updateExports(
1554 }1554 }
15551555
1556 if (exp.opts.linkage == .link_once) {1556 if (exp.opts.linkage == .link_once) {
1557 try mod.failed_exports.putNoClobber(gpa, export_idx, try Module.ErrorMsg.create(1557 try zcu.failed_exports.putNoClobber(gpa, export_idx, try Zcu.ErrorMsg.create(
1558 gpa,1558 gpa,
1559 exp.src,1559 exp.src,
1560 "Unimplemented: GlobalLinkage.link_once",1560 "Unimplemented: GlobalLinkage.link_once",
...@@ -1563,7 +1563,7 @@ pub fn updateExports(...@@ -1563,7 +1563,7 @@ pub fn updateExports(
1563 continue;1563 continue;
1564 }1564 }
15651565
1566 const exp_name = exp.opts.name.toSlice(&mod.intern_pool);1566 const exp_name = exp.opts.name.toSlice(&zcu.intern_pool);
1567 const sym_index = metadata.getExport(self, exp_name) orelse blk: {1567 const sym_index = metadata.getExport(self, exp_name) orelse blk: {
1568 const sym_index = if (self.getGlobalIndex(exp_name)) |global_index| ind: {1568 const sym_index = if (self.getGlobalIndex(exp_name)) |global_index| ind: {
1569 const global = self.globals.items[global_index];1569 const global = self.globals.items[global_index];
...@@ -1609,14 +1609,14 @@ pub fn deleteExport(...@@ -1609,14 +1609,14 @@ pub fn deleteExport(
1609 .nav => |nav| self.navs.getPtr(nav),1609 .nav => |nav| self.navs.getPtr(nav),
1610 .uav => |uav| self.uavs.getPtr(uav),1610 .uav => |uav| self.uavs.getPtr(uav),
1611 } orelse return;1611 } orelse return;
1612 const mod = self.base.comp.module.?;1612 const zcu = self.base.comp.module.?;
1613 const name_slice = name.toSlice(&mod.intern_pool);1613 const name_slice = name.toSlice(&zcu.intern_pool);
1614 const sym_index = metadata.getExportPtr(self, name_slice) orelse return;1614 const sym_index = metadata.getExportPtr(self, name_slice) orelse return;
16151615
1616 const gpa = self.base.comp.gpa;1616 const gpa = self.base.comp.gpa;
1617 const sym_loc = SymbolWithLoc{ .sym_index = sym_index.*, .file = null };1617 const sym_loc = SymbolWithLoc{ .sym_index = sym_index.*, .file = null };
1618 const sym = self.getSymbolPtr(sym_loc);1618 const sym = self.getSymbolPtr(sym_loc);
1619 log.debug("deleting export '{}'", .{name.fmt(&mod.intern_pool)});1619 log.debug("deleting export '{}'", .{name.fmt(&zcu.intern_pool)});
1620 assert(sym.storage_class == .EXTERNAL and sym.section_number != .UNDEFINED);1620 assert(sym.storage_class == .EXTERNAL and sym.section_number != .UNDEFINED);
1621 sym.* = .{1621 sym.* = .{
1622 .name = [_]u8{0} ** 8,1622 .name = [_]u8{0} ** 8,
...@@ -1843,7 +1843,7 @@ pub fn lowerUav(...@@ -1843,7 +1843,7 @@ pub fn lowerUav(
1843 pt: Zcu.PerThread,1843 pt: Zcu.PerThread,
1844 uav: InternPool.Index,1844 uav: InternPool.Index,
1845 explicit_alignment: InternPool.Alignment,1845 explicit_alignment: InternPool.Alignment,
1846 src_loc: Module.LazySrcLoc,1846 src_loc: Zcu.LazySrcLoc,
1847) !codegen.GenResult {1847) !codegen.GenResult {
1848 const zcu = pt.zcu;1848 const zcu = pt.zcu;
1849 const gpa = zcu.gpa;1849 const gpa = zcu.gpa;
...@@ -1872,7 +1872,7 @@ pub fn lowerUav(...@@ -1872,7 +1872,7 @@ pub fn lowerUav(
1872 src_loc,1872 src_loc,
1873 ) catch |err| switch (err) {1873 ) catch |err| switch (err) {
1874 error.OutOfMemory => return error.OutOfMemory,1874 error.OutOfMemory => return error.OutOfMemory,
1875 else => |e| return .{ .fail = try Module.ErrorMsg.create(1875 else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
1876 gpa,1876 gpa,
1877 src_loc,1877 src_loc,
1878 "lowerAnonDecl failed with error: {s}",1878 "lowerAnonDecl failed with error: {s}",
...@@ -2730,8 +2730,6 @@ const ImportTable = @import("Coff/ImportTable.zig");...@@ -2730,8 +2730,6 @@ const ImportTable = @import("Coff/ImportTable.zig");
2730const Liveness = @import("../Liveness.zig");2730const Liveness = @import("../Liveness.zig");
2731const LlvmObject = @import("../codegen/llvm.zig").Object;2731const LlvmObject = @import("../codegen/llvm.zig").Object;
2732const Zcu = @import("../Zcu.zig");2732const Zcu = @import("../Zcu.zig");
2733/// Deprecated.
2734const Module = Zcu;
2735const InternPool = @import("../InternPool.zig");2733const InternPool = @import("../InternPool.zig");
2736const Object = @import("Coff/Object.zig");2734const Object = @import("Coff/Object.zig");
2737const Relocation = @import("Coff/Relocation.zig");2735const Relocation = @import("Coff/Relocation.zig");