authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-11 21:26:01-07:00
committergravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-25 15:17:21-07:00
log863f74dcd20e56876bdc9a86fccf4e2e07b1a60e
tree1434505624c36471748ed6e06523074404aab267
parentbb531759bcf12191b60ea199594b8d1de30dabe7
signaturelock-open Commit is signed but in an unrecognized format.

comp: rename `module` to `zcu`


16 files changed, 64 insertions(+), 65 deletions(-)

src/Compilation.zig+29-30
......@@ -50,8 +50,7 @@ gpa: Allocator,
5050/// be used for other things requiring the same lifetime as the `Compilation`.
5151arena: Allocator,
5252/// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.
53/// TODO: rename to zcu: ?*Zcu
54module: ?*Zcu,
53zcu: ?*Zcu,
5554/// Contains different state depending on whether the Compilation uses
5655/// incremental or whole cache mode.
5756cache_use: CacheUse,
......@@ -1474,7 +1473,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
14741473 comp.* = .{
14751474 .gpa = gpa,
14761475 .arena = arena,
1477 .module = opt_zcu,
1476 .zcu = opt_zcu,
14781477 .cache_use = undefined, // populated below
14791478 .bin_file = null, // populated below
14801479 .implib_emit = null, // handled below
......@@ -1926,7 +1925,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
19261925
19271926pub fn destroy(comp: *Compilation) void {
19281927 if (comp.bin_file) |lf| lf.destroy();
1929 if (comp.module) |zcu| zcu.deinit();
1928 if (comp.zcu) |zcu| zcu.deinit();
19301929 comp.cache_use.deinit();
19311930 for (comp.work_queues) |work_queue| work_queue.deinit();
19321931 if (!InternPool.single_threaded) comp.codegen_work.queue.deinit();
......@@ -2198,7 +2197,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
21982197 };
21992198 }
22002199
2201 if (comp.module) |zcu| {
2200 if (comp.zcu) |zcu| {
22022201 const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main };
22032202
22042203 zcu.compile_log_text.shrinkAndFree(gpa, 0);
......@@ -2268,7 +2267,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
22682267
22692268 try comp.performAllTheWork(main_progress_node);
22702269
2271 if (comp.module) |zcu| {
2270 if (comp.zcu) |zcu| {
22722271 const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main };
22732272
22742273 if (build_options.enable_debug_extensions and comp.verbose_intern_pool) {
......@@ -2447,7 +2446,7 @@ fn flush(
24472446 };
24482447 }
24492448
2450 if (comp.module) |zcu| {
2449 if (comp.zcu) |zcu| {
24512450 try link.File.C.flushEmitH(zcu);
24522451
24532452 if (zcu.llvm_object) |llvm_object| {
......@@ -2558,7 +2557,7 @@ fn addNonIncrementalStuffToCacheManifest(
25582557
25592558 comptime assert(link_hash_implementation_version == 14);
25602559
2561 if (comp.module) |mod| {
2560 if (comp.zcu) |mod| {
25622561 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });
25632562
25642563 // Synchronize with other matching comments: ZigOnlyHashStuff
......@@ -2692,7 +2691,7 @@ fn addNonIncrementalStuffToCacheManifest(
26922691}
26932692
26942693fn emitOthers(comp: *Compilation) void {
2695 if (comp.config.output_mode != .Obj or comp.module != null or
2694 if (comp.config.output_mode != .Obj or comp.zcu != null or
26962695 comp.c_object_table.count() == 0)
26972696 {
26982697 return;
......@@ -2951,7 +2950,7 @@ pub fn saveState(comp: *Compilation) !void {
29512950 var pt_headers = std.ArrayList(Header.PerThread).init(gpa);
29522951 defer pt_headers.deinit();
29532952
2954 if (comp.module) |zcu| {
2953 if (comp.zcu) |zcu| {
29552954 const ip = &zcu.intern_pool;
29562955 const header: Header = .{
29572956 .intern_pool = .{
......@@ -3246,7 +3245,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
32463245 }
32473246 }
32483247
3249 if (comp.module) |zcu| {
3248 if (comp.zcu) |zcu| {
32503249 if (bundle.root_list.items.len == 0 and zcu.compile_log_sources.count() != 0) {
32513250 const values = zcu.compile_log_sources.values();
32523251 // First one will be the error; subsequent ones will be notes.
......@@ -3283,7 +3282,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
32833282 }
32843283 }
32853284
3286 const compile_log_text = if (comp.module) |m| m.compile_log_text.items else "";
3285 const compile_log_text = if (comp.zcu) |m| m.compile_log_text.items else "";
32873286 return bundle.toOwnedBundle(compile_log_text);
32883287}
32893288
......@@ -3497,7 +3496,7 @@ pub fn performAllTheWork(
34973496 comp: *Compilation,
34983497 main_progress_node: std.Progress.Node,
34993498) JobError!void {
3500 defer if (comp.module) |mod| {
3499 defer if (comp.zcu) |mod| {
35013500 mod.sema_prog_node.end();
35023501 mod.sema_prog_node = std.Progress.Node.none;
35033502 mod.codegen_prog_node.end();
......@@ -3543,7 +3542,7 @@ fn performAllTheWorkInner(
35433542 // in the `astgen_wait_group`.
35443543 if (comp.job_queued_update_builtin_zig) b: {
35453544 comp.job_queued_update_builtin_zig = false;
3546 const zcu = comp.module orelse break :b;
3545 const zcu = comp.zcu orelse break :b;
35473546 _ = zcu;
35483547 // TODO put all the modules in a flat array to make them easy to iterate.
35493548 var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
......@@ -3563,7 +3562,7 @@ fn performAllTheWorkInner(
35633562 }
35643563 }
35653564
3566 if (comp.module) |zcu| {
3565 if (comp.zcu) |zcu| {
35673566 {
35683567 // Worker threads may append to zcu.files and zcu.import_table
35693568 // so we must hold the lock while spawning those tasks, since
......@@ -3606,7 +3605,7 @@ fn performAllTheWorkInner(
36063605 if (comp.job_queued_compiler_rt_obj) work_queue_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node });
36073606 if (comp.job_queued_fuzzer_lib) work_queue_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node });
36083607
3609 if (comp.module) |zcu| {
3608 if (comp.zcu) |zcu| {
36103609 const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main };
36113610 if (comp.incremental) {
36123611 const update_zir_refs_node = main_progress_node.start("Update ZIR References", 0);
......@@ -3638,7 +3637,7 @@ fn performAllTheWorkInner(
36383637 try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job, main_progress_node);
36393638 continue :work;
36403639 };
3641 if (comp.module) |zcu| {
3640 if (comp.zcu) |zcu| {
36423641 // If there's no work queued, check if there's anything outdated
36433642 // which we need to work on, and queue it if so.
36443643 if (try zcu.findOutdatedToAnalyze()) |outdated| {
......@@ -3666,7 +3665,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void {
36663665fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progress.Node) JobError!void {
36673666 switch (job) {
36683667 .codegen_nav => |nav_index| {
3669 const zcu = comp.module.?;
3668 const zcu = comp.zcu.?;
36703669 const nav = zcu.intern_pool.getNav(nav_index);
36713670 if (nav.analysis_owner.unwrap()) |cau| {
36723671 const unit = InternPool.AnalUnit.wrap(.{ .cau = cau });
......@@ -3689,14 +3688,14 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
36893688 const named_frame = tracy.namedFrame("analyze_func");
36903689 defer named_frame.end();
36913690
3692 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3691 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
36933692 pt.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
36943693 error.OutOfMemory => return error.OutOfMemory,
36953694 error.AnalysisFail => return,
36963695 };
36973696 },
36983697 .analyze_cau => |cau_index| {
3699 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3698 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
37003699 pt.ensureCauAnalyzed(cau_index) catch |err| switch (err) {
37013700 error.OutOfMemory => return error.OutOfMemory,
37023701 error.AnalysisFail => return,
......@@ -3725,7 +3724,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
37253724 const named_frame = tracy.namedFrame("resolve_type_fully");
37263725 defer named_frame.end();
37273726
3728 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3727 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
37293728 Type.fromInterned(ty).resolveFully(pt) catch |err| switch (err) {
37303729 error.OutOfMemory => return error.OutOfMemory,
37313730 error.AnalysisFail => return,
......@@ -3738,7 +3737,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
37383737 if (true) @panic("TODO: update_line_number");
37393738
37403739 const gpa = comp.gpa;
3741 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3740 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
37423741 const decl = pt.zcu.declPtr(decl_index);
37433742 const lf = comp.bin_file.?;
37443743 lf.updateDeclLineNumber(pt, decl_index) catch |err| {
......@@ -3760,7 +3759,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
37603759 const named_frame = tracy.namedFrame("analyze_mod");
37613760 defer named_frame.end();
37623761
3763 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3762 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
37643763 pt.semaPkg(mod) catch |err| switch (err) {
37653764 error.OutOfMemory => return error.OutOfMemory,
37663765 error.AnalysisFail => return,
......@@ -3924,7 +3923,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
39243923
39253924fn queueCodegenJob(comp: *Compilation, tid: usize, codegen_job: CodegenJob) !void {
39263925 if (InternPool.single_threaded or
3927 !comp.module.?.backendSupportsFeature(.separate_thread))
3926 !comp.zcu.?.backendSupportsFeature(.separate_thread))
39283927 return processOneCodegenJob(tid, comp, codegen_job);
39293928
39303929 {
......@@ -3963,14 +3962,14 @@ fn processOneCodegenJob(tid: usize, comp: *Compilation, codegen_job: CodegenJob)
39633962 const named_frame = tracy.namedFrame("codegen_nav");
39643963 defer named_frame.end();
39653964
3966 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3965 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
39673966 try pt.linkerUpdateNav(nav_index);
39683967 },
39693968 .func => |func| {
39703969 const named_frame = tracy.namedFrame("codegen_func");
39713970 defer named_frame.end();
39723971
3973 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3972 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
39743973 // This call takes ownership of `func.air`.
39753974 try pt.linkerUpdateFunc(func.func, func.air);
39763975 },
......@@ -3995,7 +3994,7 @@ fn workerDocsCopy(comp: *Compilation) void {
39953994}
39963995
39973996fn docsCopyFallible(comp: *Compilation) anyerror!void {
3998 const zcu = comp.module orelse
3997 const zcu = comp.zcu orelse
39993998 return comp.lockAndSetMiscFailure(.docs_copy, "no Zig code to document", .{});
40003999
40014000 const emit = comp.docs_emit.?;
......@@ -4352,7 +4351,7 @@ fn workerCheckEmbedFile(comp: *Compilation, embed_file: *Zcu.EmbedFile) void {
43524351}
43534352
43544353fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Zcu.EmbedFile) !void {
4355 const mod = comp.module.?;
4354 const mod = comp.zcu.?;
43564355 const ip = &mod.intern_pool;
43574356 var file = try embed_file.owner.root.openFile(embed_file.sub_file_path.toSlice(ip), .{});
43584357 defer file.close();
......@@ -4665,7 +4664,7 @@ fn reportRetryableEmbedFileError(
46654664 embed_file: *Zcu.EmbedFile,
46664665 err: anyerror,
46674666) error{OutOfMemory}!void {
4668 const mod = comp.module.?;
4667 const mod = comp.zcu.?;
46694668 const gpa = mod.gpa;
46704669 const src_loc = embed_file.src_loc;
46714670 const ip = &mod.intern_pool;
......@@ -4730,7 +4729,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
47304729 // Special case when doing build-obj for just one C file. When there are more than one object
47314730 // file and building an object we need to link them together, but with just one it should go
47324731 // directly to the output file.
4733 const direct_o = comp.c_source_files.len == 1 and comp.module == null and
4732 const direct_o = comp.c_source_files.len == 1 and comp.zcu == null and
47344733 comp.config.output_mode == .Obj and comp.objects.len == 0;
47354734 const o_basename_noext = if (direct_o)
47364735 comp.root_name
src/arch/wasm/CodeGen.zig+1-1
......@@ -6003,7 +6003,7 @@ fn airPtrSliceFieldPtr(func: *CodeGen, inst: Air.Inst.Index, offset: u32) InnerE
60036003
60046004/// NOTE: Allocates place for result on virtual stack, when integer size > 64 bits
60056005fn intZeroValue(func: *CodeGen, ty: Type) InnerError!WValue {
6006 const zcu = func.bin_file.base.comp.module.?;
6006 const zcu = func.bin_file.base.comp.zcu.?;
60076007 const int_info = ty.intInfo(zcu);
60086008 const wasm_bits = toWasmBits(int_info.bits) orelse {
60096009 return func.fail("TODO: Implement intZeroValue for integer bitsize: {d}", .{int_info.bits});
src/arch/wasm/Emit.zig+1-1
......@@ -255,7 +255,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
255255 @setCold(true);
256256 std.debug.assert(emit.error_msg == null);
257257 const comp = emit.bin_file.base.comp;
258 const zcu = comp.module.?;
258 const zcu = comp.zcu.?;
259259 const gpa = comp.gpa;
260260 emit.error_msg = try Zcu.ErrorMsg.create(gpa, zcu.navSrcLoc(emit.owner_nav), format, args);
261261 return error.EmitFail;
src/codegen/llvm.zig+2-2
......@@ -864,7 +864,7 @@ pub const Object = struct {
864864 // into the garbage can by converting into absolute paths. What
865865 // a terrible tragedy.
866866 const compile_unit_dir = blk: {
867 if (comp.module) |zcu| m: {
867 if (comp.zcu) |zcu| m: {
868868 const d = try zcu.main_mod.root.joinString(arena, "");
869869 if (d.len == 0) break :m;
870870 if (std.fs.path.isAbsolute(d)) break :blk d;
......@@ -955,7 +955,7 @@ pub const Object = struct {
955955 .gpa = gpa,
956956 .builder = builder,
957957 .pt = .{
958 .zcu = comp.module.?,
958 .zcu = comp.zcu.?,
959959 .tid = .main,
960960 },
961961 .debug_compile_unit = debug_compile_unit,
src/link.zig+1-1
......@@ -755,7 +755,7 @@ pub const File = struct {
755755 const directory = base.emit.root_dir; // Just an alias to make it shorter to type.
756756 const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path});
757757 const full_out_path_z = try arena.dupeZ(u8, full_out_path);
758 const opt_zcu = comp.module;
758 const opt_zcu = comp.zcu;
759759
760760 // If there is no Zig code to compile, then we should skip flushing the output file
761761 // because it will not be part of the linker line anyway.
src/link/C.zig+1-1
......@@ -418,7 +418,7 @@ pub fn flushModule(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
418418
419419 const comp = self.base.comp;
420420 const gpa = comp.gpa;
421 const zcu = self.base.comp.module.?;
421 const zcu = self.base.comp.zcu.?;
422422 const ip = &zcu.intern_pool;
423423 const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = tid };
424424
src/link/Coff.zig+3-3
......@@ -1354,7 +1354,7 @@ pub fn getOrCreateAtomForNav(self: *Coff, nav_index: InternPool.Nav.Index) !Atom
13541354}
13551355
13561356fn getNavOutputSection(self: *Coff, nav_index: InternPool.Nav.Index) u16 {
1357 const zcu = self.base.comp.module.?;
1357 const zcu = self.base.comp.zcu.?;
13581358 const ip = &zcu.intern_pool;
13591359 const nav = ip.getNav(nav_index);
13601360 const ty = Type.fromInterned(nav.typeOf(ip));
......@@ -1609,7 +1609,7 @@ pub fn deleteExport(
16091609 .nav => |nav| self.navs.getPtr(nav),
16101610 .uav => |uav| self.uavs.getPtr(uav),
16111611 } orelse return;
1612 const zcu = self.base.comp.module.?;
1612 const zcu = self.base.comp.zcu.?;
16131613 const name_slice = name.toSlice(&zcu.intern_pool);
16141614 const sym_index = metadata.getExportPtr(self, name_slice) orelse return;
16151615
......@@ -1691,7 +1691,7 @@ pub fn flushModule(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
16911691 defer sub_prog_node.end();
16921692
16931693 const pt: Zcu.PerThread = .{
1694 .zcu = comp.module orelse return error.LinkingWithoutZigSourceUnimplemented,
1694 .zcu = comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented,
16951695 .tid = tid,
16961696 };
16971697
src/link/Coff/lld.zig+3-3
......@@ -32,7 +32,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
3232
3333 // If there is no Zig code to compile, then we should skip flushing the output file because it
3434 // will not be part of the linker line anyway.
35 const module_obj_path: ?[]const u8 = if (comp.module != null) blk: {
35 const module_obj_path: ?[]const u8 = if (comp.zcu != null) blk: {
3636 try self.flushModule(arena, tid, prog_node);
3737
3838 if (fs.path.dirname(full_out_path)) |dirname| {
......@@ -296,7 +296,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
296296 if (self.subsystem) |explicit| break :blk explicit;
297297 switch (target.os.tag) {
298298 .windows => {
299 if (comp.module) |module| {
299 if (comp.zcu) |module| {
300300 if (module.stage1_flags.have_dllmain_crt_startup or is_dyn_lib)
301301 break :blk null;
302302 if (module.stage1_flags.have_c_main or comp.config.is_test or
......@@ -440,7 +440,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
440440 } else {
441441 try argv.append("-NODEFAULTLIB");
442442 if (!is_lib and entry_name == null) {
443 if (comp.module) |module| {
443 if (comp.zcu) |module| {
444444 if (module.stage1_flags.have_winmain_crt_startup) {
445445 try argv.append("-ENTRY:WinMainCRTStartup");
446446 } else {
src/link/Elf.zig+2-2
......@@ -212,7 +212,7 @@ pub fn createEmpty(
212212
213213 const use_lld = build_options.have_llvm and comp.config.use_lld;
214214 const use_llvm = comp.config.use_llvm;
215 const opt_zcu = comp.module;
215 const opt_zcu = comp.zcu;
216216 const output_mode = comp.config.output_mode;
217217 const link_mode = comp.config.link_mode;
218218 const optimize_mode = comp.root_mod.optimize_mode;
......@@ -2084,7 +2084,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
20842084
20852085 // If there is no Zig code to compile, then we should skip flushing the output file because it
20862086 // will not be part of the linker line anyway.
2087 const module_obj_path: ?[]const u8 = if (comp.module != null) blk: {
2087 const module_obj_path: ?[]const u8 = if (comp.zcu != null) blk: {
20882088 try self.flushModule(arena, tid, prog_node);
20892089
20902090 if (fs.path.dirname(full_out_path)) |dirname| {
src/link/Elf/ZigObject.zig+3-3
......@@ -128,7 +128,7 @@ pub fn deinit(self: *ZigObject, allocator: Allocator) void {
128128pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !void {
129129 // Handle any lazy symbols that were emitted by incremental compilation.
130130 if (self.lazy_syms.getPtr(.anyerror_type)) |metadata| {
131 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.module.?, .tid = tid };
131 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid };
132132
133133 // Most lazy symbols can be updated on first use, but
134134 // anyerror needs to wait for everything to be flushed.
......@@ -949,7 +949,7 @@ pub fn getOrCreateMetadataForNav(
949949 if (!gop.found_existing) {
950950 const any_non_single_threaded = elf_file.base.comp.config.any_non_single_threaded;
951951 const symbol_index = try self.newSymbolWithAtom(gpa, 0);
952 const zcu = elf_file.base.comp.module.?;
952 const zcu = elf_file.base.comp.zcu.?;
953953 const nav_val = Value.fromInterned(zcu.intern_pool.getNav(nav_index).status.resolved.val);
954954 const sym = self.symbol(symbol_index);
955955 if (nav_val.getVariable(zcu)) |variable| {
......@@ -1626,7 +1626,7 @@ pub fn deleteExport(
16261626 .nav => |nav| self.navs.getPtr(nav),
16271627 .uav => |uav| self.uavs.getPtr(uav),
16281628 } orelse return;
1629 const mod = elf_file.base.comp.module.?;
1629 const mod = elf_file.base.comp.zcu.?;
16301630 const exp_name = name.toSlice(&mod.intern_pool);
16311631 const esym_index = metadata.@"export"(self, exp_name) orelse return;
16321632 log.debug("deleting export '{s}'", .{exp_name});
src/link/MachO.zig+1-1
......@@ -164,7 +164,7 @@ pub fn createEmpty(
164164
165165 const gpa = comp.gpa;
166166 const use_llvm = comp.config.use_llvm;
167 const opt_zcu = comp.module;
167 const opt_zcu = comp.zcu;
168168 const optimize_mode = comp.root_mod.optimize_mode;
169169 const output_mode = comp.config.output_mode;
170170 const link_mode = comp.config.link_mode;
src/link/MachO/ZigObject.zig+3-3
......@@ -566,7 +566,7 @@ pub fn getInputSection(self: ZigObject, atom: Atom, macho_file: *MachO) macho.se
566566pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) !void {
567567 // Handle any lazy symbols that were emitted by incremental compilation.
568568 if (self.lazy_syms.getPtr(.anyerror_type)) |metadata| {
569 const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.module.?, .tid = tid };
569 const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.zcu.?, .tid = tid };
570570
571571 // Most lazy symbols can be updated on first use, but
572572 // anyerror needs to wait for everything to be flushed.
......@@ -1437,7 +1437,7 @@ pub fn deleteExport(
14371437 exported: Zcu.Exported,
14381438 name: InternPool.NullTerminatedString,
14391439) void {
1440 const mod = macho_file.base.comp.module.?;
1440 const mod = macho_file.base.comp.zcu.?;
14411441
14421442 const metadata = switch (exported) {
14431443 .nav => |nav| self.navs.getPtr(nav),
......@@ -1545,7 +1545,7 @@ pub fn getOrCreateMetadataForLazySymbol(
15451545fn isThreadlocal(macho_file: *MachO, nav_index: InternPool.Nav.Index) bool {
15461546 if (!macho_file.base.comp.config.any_non_single_threaded)
15471547 return false;
1548 const ip = &macho_file.base.comp.module.?.intern_pool;
1548 const ip = &macho_file.base.comp.zcu.?.intern_pool;
15491549 return switch (ip.indexToKey(ip.getNav(nav_index).status.resolved.val)) {
15501550 .variable => |variable| variable.is_threadlocal,
15511551 .@"extern" => |@"extern"| @"extern".is_threadlocal,
src/link/Plan9.zig+5-5
......@@ -152,7 +152,7 @@ pub const Atom = struct {
152152 return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } };
153153 }
154154 fn getCode(self: CodePtr, plan9: *const Plan9) []u8 {
155 const zcu = plan9.base.comp.module.?;
155 const zcu = plan9.base.comp.zcu.?;
156156 const ip = &zcu.intern_pool;
157157 return if (self.code_ptr) |p| p[0..self.other.code_len] else blk: {
158158 const nav_index = self.other.nav_index;
......@@ -317,7 +317,7 @@ pub fn createEmpty(
317317
318318fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void {
319319 const gpa = self.base.comp.gpa;
320 const mod = self.base.comp.module.?;
320 const mod = self.base.comp.zcu.?;
321321 const file_scope = mod.navFileScopeIndex(nav_index);
322322 const fn_map_res = try self.fn_nav_table.getOrPut(gpa, file_scope);
323323 if (fn_map_res.found_existing) {
......@@ -607,7 +607,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, tid: Zcu.PerThread.Id, prog_n
607607 defer assert(self.hdr.entry != 0x0);
608608
609609 const pt: Zcu.PerThread = .{
610 .zcu = self.base.comp.module orelse return error.LinkingWithoutZigSourceUnimplemented,
610 .zcu = self.base.comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented,
611611 .tid = tid,
612612 };
613613
......@@ -952,7 +952,7 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void {
952952 const gpa = self.base.comp.gpa;
953953 // TODO audit the lifetimes of decls table entries. It's possible to get
954954 // freeDecl without any updateDecl in between.
955 const mod = self.base.comp.module.?;
955 const mod = self.base.comp.zcu.?;
956956 const decl = mod.declPtr(decl_index);
957957 const is_fn = decl.val.isFuncBody(mod);
958958 if (is_fn) {
......@@ -1256,7 +1256,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {
12561256}
12571257
12581258pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
1259 const mod = self.base.comp.module.?;
1259 const mod = self.base.comp.zcu.?;
12601260 const ip = &mod.intern_pool;
12611261 const writer = buf.writer();
12621262 // write __GOT
src/link/SpirV.zig+1-1
......@@ -229,7 +229,7 @@ pub fn flushModule(self: *SpirV, arena: Allocator, tid: Zcu.PerThread.Id, prog_n
229229 defer error_info.deinit();
230230
231231 try error_info.appendSlice("zig_errors:");
232 const ip = &self.base.comp.module.?.intern_pool;
232 const ip = &self.base.comp.zcu.?.intern_pool;
233233 for (ip.global_error_set.getNamesFromMainThread()) |name| {
234234 // Errors can contain pretty much any character - to encode them in a string we must escape
235235 // them somehow. Easiest here is to use some established scheme, one which also preseves the
src/link/Wasm.zig+2-2
......@@ -556,7 +556,7 @@ pub fn createEmpty(
556556 }
557557 }
558558
559 if (comp.module) |zcu| {
559 if (comp.zcu) |zcu| {
560560 if (!use_llvm) {
561561 const index: File.Index = @enumFromInt(wasm.files.len);
562562 var zig_object: ZigObject = .{
......@@ -3352,7 +3352,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
33523352
33533353 // If there is no Zig code to compile, then we should skip flushing the output file because it
33543354 // will not be part of the linker line anyway.
3355 const module_obj_path: ?[]const u8 = if (comp.module != null) blk: {
3355 const module_obj_path: ?[]const u8 = if (comp.zcu != null) blk: {
33563356 try wasm.flushModule(arena, tid, prog_node);
33573357
33583358 if (fs.path.dirname(full_out_path)) |dirname| {
src/link/Wasm/ZigObject.zig+6-6
......@@ -487,7 +487,7 @@ fn lowerConst(
487487 src_loc: Zcu.LazySrcLoc,
488488) !LowerConstResult {
489489 const gpa = wasm_file.base.comp.gpa;
490 const zcu = wasm_file.base.comp.module.?;
490 const zcu = wasm_file.base.comp.zcu.?;
491491
492492 const ty = val.typeOf(zcu);
493493
......@@ -604,7 +604,7 @@ fn populateErrorNameTable(zig_object: *ZigObject, wasm_file: *Wasm, tid: Zcu.Per
604604
605605 // Addend for each relocation to the table
606606 var addend: u32 = 0;
607 const pt: Zcu.PerThread = .{ .zcu = wasm_file.base.comp.module.?, .tid = tid };
607 const pt: Zcu.PerThread = .{ .zcu = wasm_file.base.comp.zcu.?, .tid = tid };
608608 const slice_ty = Type.slice_const_u8_sentinel_0;
609609 const atom = wasm_file.getAtomPtr(atom_index);
610610 {
......@@ -803,7 +803,7 @@ pub fn getUavVAddr(
803803 const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?;
804804 const parent_atom = wasm_file.getAtomPtr(parent_atom_index);
805805 const is_wasm32 = target.cpu.arch == .wasm32;
806 const mod = wasm_file.base.comp.module.?;
806 const mod = wasm_file.base.comp.zcu.?;
807807 const ty = Type.fromInterned(mod.intern_pool.typeOf(uav));
808808 if (ty.zigTypeTag(mod) == .Fn) {
809809 std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations
......@@ -834,7 +834,7 @@ pub fn deleteExport(
834834 exported: Zcu.Exported,
835835 name: InternPool.NullTerminatedString,
836836) void {
837 const mod = wasm_file.base.comp.module.?;
837 const mod = wasm_file.base.comp.zcu.?;
838838 const nav_index = switch (exported) {
839839 .nav => |nav_index| nav_index,
840840 .uav => @panic("TODO: implement Wasm linker code for exporting a constant value"),
......@@ -930,7 +930,7 @@ pub fn updateExports(
930930
931931pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.Nav.Index) void {
932932 const gpa = wasm_file.base.comp.gpa;
933 const mod = wasm_file.base.comp.module.?;
933 const mod = wasm_file.base.comp.zcu.?;
934934 const ip = &mod.intern_pool;
935935 const nav_info = zig_object.navs.getPtr(nav_index).?;
936936 const atom_index = nav_info.atom;
......@@ -1016,7 +1016,7 @@ fn setupErrorsLen(zig_object: *ZigObject, wasm_file: *Wasm) !void {
10161016 const gpa = wasm_file.base.comp.gpa;
10171017 const sym_index = zig_object.findGlobalSymbol("__zig_errors_len") orelse return;
10181018
1019 const errors_len = 1 + wasm_file.base.comp.module.?.intern_pool.global_error_set.getNamesFromMainThread().len;
1019 const errors_len = 1 + wasm_file.base.comp.zcu.?.intern_pool.global_error_set.getNamesFromMainThread().len;
10201020 // overwrite existing atom if it already exists (maybe the error set has increased)
10211021 // if not, allocate a new atom.
10221022 const atom_index = if (wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = sym_index })) |index| blk: {