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,
11411141
11421142const LowerConstResult = union(enum) {
11431143 ok: Atom.Index,
1144 fail: *Module.ErrorMsg,
1144 fail: *Zcu.ErrorMsg,
11451145};
11461146
11471147fn lowerConst(
......@@ -1151,7 +1151,7 @@ fn lowerConst(
11511151 val: Value,
11521152 required_alignment: InternPool.Alignment,
11531153 sect_id: u16,
1154 src_loc: Module.LazySrcLoc,
1154 src_loc: Zcu.LazySrcLoc,
11551155) !LowerConstResult {
11561156 const gpa = self.base.comp.gpa;
11571157
......@@ -1462,15 +1462,15 @@ pub fn freeNav(self: *Coff, nav_index: InternPool.NavIndex) void {
14621462pub fn updateExports(
14631463 self: *Coff,
14641464 pt: Zcu.PerThread,
1465 exported: Module.Exported,
1465 exported: Zcu.Exported,
14661466 export_indices: []const u32,
14671467) link.File.UpdateExportsError!void {
14681468 if (build_options.skip_non_native and builtin.object_format != .coff) {
14691469 @panic("Attempted to compile for object format that was disabled by build configuration");
14701470 }
14711471
1472 const mod = pt.zcu;
1473 const ip = &mod.intern_pool;
1472 const zcu = pt.zcu;
1473 const ip = &zcu.intern_pool;
14741474 const comp = self.base.comp;
14751475 const target = comp.root_mod.resolved_target.result;
14761476
......@@ -1478,7 +1478,7 @@ pub fn updateExports(
14781478 // Even in the case of LLVM, we need to notice certain exported symbols in order to
14791479 // detect the default subsystem.
14801480 for (export_indices) |export_idx| {
1481 const exp = mod.all_exports.items[export_idx];
1481 const exp = zcu.all_exports.items[export_idx];
14821482 const exported_nav_index = switch (exp.exported) {
14831483 .nav => |nav| nav,
14841484 .uav => continue,
......@@ -1490,20 +1490,20 @@ pub fn updateExports(
14901490 .x86 => .Stdcall,
14911491 else => .C,
14921492 };
1493 const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(mod);
1493 const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(zcu);
14941494 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;
14961496 } else if (exported_cc == winapi_cc and target.os.tag == .windows) {
14971497 if (exp.opts.name.eqlSlice("WinMain", ip)) {
1498 mod.stage1_flags.have_winmain = true;
1498 zcu.stage1_flags.have_winmain = true;
14991499 } else if (exp.opts.name.eqlSlice("wWinMain", ip)) {
1500 mod.stage1_flags.have_wwinmain = true;
1500 zcu.stage1_flags.have_wwinmain = true;
15011501 } 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;
15031503 } 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;
15051505 } 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;
15071507 }
15081508 }
15091509 }
......@@ -1519,15 +1519,15 @@ pub fn updateExports(
15191519 break :blk self.navs.getPtr(nav).?;
15201520 },
15211521 .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]];
15231523 const res = try self.lowerUav(pt, uav, .none, first_exp.src);
15241524 switch (res) {
15251525 .mcv => {},
15261526 .fail => |em| {
15271527 // TODO maybe it's enough to return an error here and let Module.processExportsInner
15281528 // handle the error?
1529 try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1);
1530 mod.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em);
1529 try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1);
1530 zcu.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em);
15311531 return;
15321532 },
15331533 }
......@@ -1538,12 +1538,12 @@ pub fn updateExports(
15381538 const atom = self.getAtom(atom_index);
15391539
15401540 for (export_indices) |export_idx| {
1541 const exp = mod.all_exports.items[export_idx];
1542 log.debug("adding new export '{}'", .{exp.opts.name.fmt(&mod.intern_pool)});
1541 const exp = zcu.all_exports.items[export_idx];
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| {
15451545 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(
15471547 gpa,
15481548 exp.src,
15491549 "Unimplemented: ExportOptions.section",
......@@ -1554,7 +1554,7 @@ pub fn updateExports(
15541554 }
15551555
15561556 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(
15581558 gpa,
15591559 exp.src,
15601560 "Unimplemented: GlobalLinkage.link_once",
......@@ -1563,7 +1563,7 @@ pub fn updateExports(
15631563 continue;
15641564 }
15651565
1566 const exp_name = exp.opts.name.toSlice(&mod.intern_pool);
1566 const exp_name = exp.opts.name.toSlice(&zcu.intern_pool);
15671567 const sym_index = metadata.getExport(self, exp_name) orelse blk: {
15681568 const sym_index = if (self.getGlobalIndex(exp_name)) |global_index| ind: {
15691569 const global = self.globals.items[global_index];
......@@ -1609,14 +1609,14 @@ pub fn deleteExport(
16091609 .nav => |nav| self.navs.getPtr(nav),
16101610 .uav => |uav| self.uavs.getPtr(uav),
16111611 } orelse return;
1612 const mod = self.base.comp.module.?;
1613 const name_slice = name.toSlice(&mod.intern_pool);
1612 const zcu = self.base.comp.module.?;
1613 const name_slice = name.toSlice(&zcu.intern_pool);
16141614 const sym_index = metadata.getExportPtr(self, name_slice) orelse return;
16151615
16161616 const gpa = self.base.comp.gpa;
16171617 const sym_loc = SymbolWithLoc{ .sym_index = sym_index.*, .file = null };
16181618 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)});
16201620 assert(sym.storage_class == .EXTERNAL and sym.section_number != .UNDEFINED);
16211621 sym.* = .{
16221622 .name = [_]u8{0} ** 8,
......@@ -1843,7 +1843,7 @@ pub fn lowerUav(
18431843 pt: Zcu.PerThread,
18441844 uav: InternPool.Index,
18451845 explicit_alignment: InternPool.Alignment,
1846 src_loc: Module.LazySrcLoc,
1846 src_loc: Zcu.LazySrcLoc,
18471847) !codegen.GenResult {
18481848 const zcu = pt.zcu;
18491849 const gpa = zcu.gpa;
......@@ -1872,7 +1872,7 @@ pub fn lowerUav(
18721872 src_loc,
18731873 ) catch |err| switch (err) {
18741874 error.OutOfMemory => return error.OutOfMemory,
1875 else => |e| return .{ .fail = try Module.ErrorMsg.create(
1875 else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
18761876 gpa,
18771877 src_loc,
18781878 "lowerAnonDecl failed with error: {s}",
......@@ -2730,8 +2730,6 @@ const ImportTable = @import("Coff/ImportTable.zig");
27302730const Liveness = @import("../Liveness.zig");
27312731const LlvmObject = @import("../codegen/llvm.zig").Object;
27322732const Zcu = @import("../Zcu.zig");
2733/// Deprecated.
2734const Module = Zcu;
27352733const InternPool = @import("../InternPool.zig");
27362734const Object = @import("Coff/Object.zig");
27372735const Relocation = @import("Coff/Relocation.zig");