diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-06-15 16:10:53 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-07-07 22:59:52 -0400 |
| commit | 525f341f33af9b8aad53931fd5511f00a82cb090 (patch) | |
| tree | cec3280498c1122858580946ac5e31f8feb807ce /src/link/Elf.zig | |
| parent | 8f20e81b8816aadd8ceb1b04bd3727cc1d124464 (diff) | |
| download | zig-525f341f33af9b8aad53931fd5511f00a82cb090.tar.gz zig-525f341f33af9b8aad53931fd5511f00a82cb090.zip | |
Zcu: introduce `PerThread` and pass to all the functions
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 7510dd4956..39704d937c 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -550,11 +550,12 @@ pub fn getDeclVAddr(self: *Elf, decl_index: InternPool.DeclIndex, reloc_info: li pub fn lowerAnonDecl( self: *Elf, + pt: Zcu.PerThread, decl_val: InternPool.Index, explicit_alignment: InternPool.Alignment, src_loc: Module.LazySrcLoc, ) !codegen.Result { - return self.zigObjectPtr().?.lowerAnonDecl(self, decl_val, explicit_alignment, src_loc); + return self.zigObjectPtr().?.lowerAnonDecl(self, pt, decl_val, explicit_alignment, src_loc); } pub fn getAnonDeclVAddr(self: *Elf, decl_val: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 { @@ -1064,15 +1065,15 @@ pub fn markDirty(self: *Elf, shdr_index: u32) void { } } -pub fn flush(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { +pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) link.File.FlushError!void { const use_lld = build_options.have_llvm and self.base.comp.config.use_lld; if (use_lld) { - return self.linkWithLLD(arena, prog_node); + return self.linkWithLLD(arena, tid, prog_node); } - try self.flushModule(arena, prog_node); + try self.flushModule(arena, tid, prog_node); } -pub fn flushModule(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { +pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) link.File.FlushError!void { const tracy = trace(@src()); defer tracy.end(); @@ -1103,7 +1104,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) l // --verbose-link if (comp.verbose_link) try self.dumpArgv(comp); - if (self.zigObjectPtr()) |zig_object| try zig_object.flushModule(self); + if (self.zigObjectPtr()) |zig_object| try zig_object.flushModule(self, tid); if (self.base.isStaticLib()) return relocatable.flushStaticLib(self, comp, module_obj_path); if (self.base.isObject()) return relocatable.flushObject(self, comp, module_obj_path); @@ -2146,7 +2147,7 @@ fn scanRelocs(self: *Elf) !void { } } -fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) !void { +fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) !void { const tracy = trace(@src()); defer tracy.end(); @@ -2159,7 +2160,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) !void // If there is no Zig code to compile, then we should skip flushing the output file because it // will not be part of the linker line anyway. const module_obj_path: ?[]const u8 = if (comp.module != null) blk: { - try self.flushModule(arena, prog_node); + try self.flushModule(arena, tid, prog_node); if (fs.path.dirname(full_out_path)) |dirname| { break :blk try fs.path.join(arena, &.{ dirname, self.base.zcu_object_sub_path.? }); @@ -2983,41 +2984,41 @@ pub fn freeDecl(self: *Elf, decl_index: InternPool.DeclIndex) void { return self.zigObjectPtr().?.freeDecl(self, decl_index); } -pub fn updateFunc(self: *Elf, mod: *Module, func_index: InternPool.Index, air: Air, liveness: Liveness) !void { +pub fn updateFunc(self: *Elf, pt: Zcu.PerThread, func_index: InternPool.Index, air: Air, liveness: Liveness) !void { if (build_options.skip_non_native and builtin.object_format != .elf) { @panic("Attempted to compile for object format that was disabled by build configuration"); } - if (self.llvm_object) |llvm_object| return llvm_object.updateFunc(mod, func_index, air, liveness); - return self.zigObjectPtr().?.updateFunc(self, mod, func_index, air, liveness); + if (self.llvm_object) |llvm_object| return llvm_object.updateFunc(pt, func_index, air, liveness); + return self.zigObjectPtr().?.updateFunc(self, pt, func_index, air, liveness); } pub fn updateDecl( self: *Elf, - mod: *Module, + pt: Zcu.PerThread, decl_index: InternPool.DeclIndex, ) link.File.UpdateDeclError!void { if (build_options.skip_non_native and builtin.object_format != .elf) { @panic("Attempted to compile for object format that was disabled by build configuration"); } - if (self.llvm_object) |llvm_object| return llvm_object.updateDecl(mod, decl_index); - return self.zigObjectPtr().?.updateDecl(self, mod, decl_index); + if (self.llvm_object) |llvm_object| return llvm_object.updateDecl(pt, decl_index); + return self.zigObjectPtr().?.updateDecl(self, pt, decl_index); } -pub fn lowerUnnamedConst(self: *Elf, val: Value, decl_index: InternPool.DeclIndex) !u32 { - return self.zigObjectPtr().?.lowerUnnamedConst(self, val, decl_index); +pub fn lowerUnnamedConst(self: *Elf, pt: Zcu.PerThread, val: Value, decl_index: InternPool.DeclIndex) !u32 { + return self.zigObjectPtr().?.lowerUnnamedConst(self, pt, val, decl_index); } pub fn updateExports( self: *Elf, - mod: *Module, + pt: Zcu.PerThread, exported: Module.Exported, export_indices: []const u32, ) link.File.UpdateExportsError!void { if (build_options.skip_non_native and builtin.object_format != .elf) { @panic("Attempted to compile for object format that was disabled by build configuration"); } - if (self.llvm_object) |llvm_object| return llvm_object.updateExports(mod, exported, export_indices); - return self.zigObjectPtr().?.updateExports(self, mod, exported, export_indices); + if (self.llvm_object) |llvm_object| return llvm_object.updateExports(pt, exported, export_indices); + return self.zigObjectPtr().?.updateExports(self, pt, exported, export_indices); } pub fn updateDeclLineNumber(self: *Elf, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
