aboutsummaryrefslogtreecommitdiff
path: root/src/link/Coff.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-04-29 19:57:44 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-05-01 19:22:52 -0400
commit372bc960b8315ea1ff17b369b0b33485d5e34cfb (patch)
tree8f492631dec579c28b8430e80213f6ad4d286dd9 /src/link/Coff.zig
parentf37ca3fa7370c501c630c53b370fecdeb313e3be (diff)
downloadzig-372bc960b8315ea1ff17b369b0b33485d5e34cfb.tar.gz
zig-372bc960b8315ea1ff17b369b0b33485d5e34cfb.zip
link: update decl-specific lazy symbols
Diffstat (limited to 'src/link/Coff.zig')
-rw-r--r--src/link/Coff.zig23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index d20d17f2b1..deac8d1fd6 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -1136,7 +1136,11 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In
return atom.getSymbolIndex().?;
}
-pub fn updateDecl(self: *Coff, module: *Module, decl_index: Module.Decl.Index) !void {
+pub fn updateDecl(
+ self: *Coff,
+ module: *Module,
+ decl_index: Module.Decl.Index,
+) link.File.UpdateDeclError!void {
if (build_options.skip_non_native and builtin.object_format != .coff) {
@panic("Attempted to compile for object format that was disabled by build configuration");
}
@@ -1146,6 +1150,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl_index: Module.Decl.Index) !
const tracy = trace(@src());
defer tracy.end();
+ try self.updateLazySymbol(decl_index);
+
const decl = module.declPtr(decl_index);
if (decl.val.tag() == .extern_fn) {
@@ -1188,7 +1194,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl_index: Module.Decl.Index) !
return self.updateDeclExports(module, decl_index, module.getDeclExports(decl_index));
}
-fn updateLazySymbol(self: *Coff, decl: Module.Decl.OptionalIndex, metadata: LazySymbolMetadata) !void {
+fn updateLazySymbol(self: *Coff, decl: ?Module.Decl.Index) !void {
+ const metadata = self.lazy_syms.get(Module.Decl.OptionalIndex.init(decl)) orelse return;
const mod = self.base.options.module.?;
if (metadata.text_atom) |atom| try self.updateLazySymbolAtom(
link.File.LazySymbol.initDecl(.code, decl, mod),
@@ -1402,7 +1409,7 @@ pub fn updateDeclExports(
module: *Module,
decl_index: Module.Decl.Index,
exports: []const *Module.Export,
-) !void {
+) link.File.UpdateDeclExportsError!void {
if (build_options.skip_non_native and builtin.object_format != .coff) {
@panic("Attempted to compile for object format that was disabled by build configuration");
}
@@ -1599,12 +1606,10 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
// Most lazy symbols can be updated when the corresponding decl is,
// so we only have to worry about the one without an associated decl.
- if (self.lazy_syms.get(.none)) |metadata| {
- self.updateLazySymbol(.none, metadata) catch |err| switch (err) {
- error.CodegenFail => return error.FlushFailure,
- else => |e| return e,
- };
- }
+ self.updateLazySymbol(null) catch |err| switch (err) {
+ error.CodegenFail => return error.FlushFailure,
+ else => |e| return e,
+ };
const gpa = self.base.allocator;