| author | |
| committer | |
| log | 863f74dcd20e56876bdc9a86fccf4e2e07b1a60e |
| tree | 1434505624c36471748ed6e06523074404aab267 |
| parent | bb531759bcf12191b60ea199594b8d1de30dabe7 |
| signature |
16 files changed, 64 insertions(+), 65 deletions(-)
src/Compilation.zig+29-30| ... | ... | @@ -50,8 +50,7 @@ gpa: Allocator, |
| 50 | 50 | /// be used for other things requiring the same lifetime as the `Compilation`. |
| 51 | 51 | arena: Allocator, |
| 52 | 52 | /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`. |
| 53 | /// TODO: rename to zcu: ?*Zcu | |
| 54 | module: ?*Zcu, | |
| 53 | zcu: ?*Zcu, | |
| 55 | 54 | /// Contains different state depending on whether the Compilation uses |
| 56 | 55 | /// incremental or whole cache mode. |
| 57 | 56 | cache_use: CacheUse, |
| ... | ... | @@ -1474,7 +1473,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1474 | 1473 | comp.* = .{ |
| 1475 | 1474 | .gpa = gpa, |
| 1476 | 1475 | .arena = arena, |
| 1477 | .module = opt_zcu, | |
| 1476 | .zcu = opt_zcu, | |
| 1478 | 1477 | .cache_use = undefined, // populated below |
| 1479 | 1478 | .bin_file = null, // populated below |
| 1480 | 1479 | .implib_emit = null, // handled below |
| ... | ... | @@ -1926,7 +1925,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1926 | 1925 | |
| 1927 | 1926 | pub fn destroy(comp: *Compilation) void { |
| 1928 | 1927 | if (comp.bin_file) |lf| lf.destroy(); |
| 1929 | if (comp.module) |zcu| zcu.deinit(); | |
| 1928 | if (comp.zcu) |zcu| zcu.deinit(); | |
| 1930 | 1929 | comp.cache_use.deinit(); |
| 1931 | 1930 | for (comp.work_queues) |work_queue| work_queue.deinit(); |
| 1932 | 1931 | 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 { |
| 2198 | 2197 | }; |
| 2199 | 2198 | } |
| 2200 | 2199 | |
| 2201 | if (comp.module) |zcu| { | |
| 2200 | if (comp.zcu) |zcu| { | |
| 2202 | 2201 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; |
| 2203 | 2202 | |
| 2204 | 2203 | zcu.compile_log_text.shrinkAndFree(gpa, 0); |
| ... | ... | @@ -2268,7 +2267,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2268 | 2267 | |
| 2269 | 2268 | try comp.performAllTheWork(main_progress_node); |
| 2270 | 2269 | |
| 2271 | if (comp.module) |zcu| { | |
| 2270 | if (comp.zcu) |zcu| { | |
| 2272 | 2271 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; |
| 2273 | 2272 | |
| 2274 | 2273 | if (build_options.enable_debug_extensions and comp.verbose_intern_pool) { |
| ... | ... | @@ -2447,7 +2446,7 @@ fn flush( |
| 2447 | 2446 | }; |
| 2448 | 2447 | } |
| 2449 | 2448 | |
| 2450 | if (comp.module) |zcu| { | |
| 2449 | if (comp.zcu) |zcu| { | |
| 2451 | 2450 | try link.File.C.flushEmitH(zcu); |
| 2452 | 2451 | |
| 2453 | 2452 | if (zcu.llvm_object) |llvm_object| { |
| ... | ... | @@ -2558,7 +2557,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2558 | 2557 | |
| 2559 | 2558 | comptime assert(link_hash_implementation_version == 14); |
| 2560 | 2559 | |
| 2561 | if (comp.module) |mod| { | |
| 2560 | if (comp.zcu) |mod| { | |
| 2562 | 2561 | try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man }); |
| 2563 | 2562 | |
| 2564 | 2563 | // Synchronize with other matching comments: ZigOnlyHashStuff |
| ... | ... | @@ -2692,7 +2691,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 2692 | 2691 | } |
| 2693 | 2692 | |
| 2694 | 2693 | fn 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 | |
| 2696 | 2695 | comp.c_object_table.count() == 0) |
| 2697 | 2696 | { |
| 2698 | 2697 | return; |
| ... | ... | @@ -2951,7 +2950,7 @@ pub fn saveState(comp: *Compilation) !void { |
| 2951 | 2950 | var pt_headers = std.ArrayList(Header.PerThread).init(gpa); |
| 2952 | 2951 | defer pt_headers.deinit(); |
| 2953 | 2952 | |
| 2954 | if (comp.module) |zcu| { | |
| 2953 | if (comp.zcu) |zcu| { | |
| 2955 | 2954 | const ip = &zcu.intern_pool; |
| 2956 | 2955 | const header: Header = .{ |
| 2957 | 2956 | .intern_pool = .{ |
| ... | ... | @@ -3246,7 +3245,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3246 | 3245 | } |
| 3247 | 3246 | } |
| 3248 | 3247 | |
| 3249 | if (comp.module) |zcu| { | |
| 3248 | if (comp.zcu) |zcu| { | |
| 3250 | 3249 | if (bundle.root_list.items.len == 0 and zcu.compile_log_sources.count() != 0) { |
| 3251 | 3250 | const values = zcu.compile_log_sources.values(); |
| 3252 | 3251 | // First one will be the error; subsequent ones will be notes. |
| ... | ... | @@ -3283,7 +3282,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3283 | 3282 | } |
| 3284 | 3283 | } |
| 3285 | 3284 | |
| 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 ""; | |
| 3287 | 3286 | return bundle.toOwnedBundle(compile_log_text); |
| 3288 | 3287 | } |
| 3289 | 3288 | |
| ... | ... | @@ -3497,7 +3496,7 @@ pub fn performAllTheWork( |
| 3497 | 3496 | comp: *Compilation, |
| 3498 | 3497 | main_progress_node: std.Progress.Node, |
| 3499 | 3498 | ) JobError!void { |
| 3500 | defer if (comp.module) |mod| { | |
| 3499 | defer if (comp.zcu) |mod| { | |
| 3501 | 3500 | mod.sema_prog_node.end(); |
| 3502 | 3501 | mod.sema_prog_node = std.Progress.Node.none; |
| 3503 | 3502 | mod.codegen_prog_node.end(); |
| ... | ... | @@ -3543,7 +3542,7 @@ fn performAllTheWorkInner( |
| 3543 | 3542 | // in the `astgen_wait_group`. |
| 3544 | 3543 | if (comp.job_queued_update_builtin_zig) b: { |
| 3545 | 3544 | comp.job_queued_update_builtin_zig = false; |
| 3546 | const zcu = comp.module orelse break :b; | |
| 3545 | const zcu = comp.zcu orelse break :b; | |
| 3547 | 3546 | _ = zcu; |
| 3548 | 3547 | // TODO put all the modules in a flat array to make them easy to iterate. |
| 3549 | 3548 | var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{}; |
| ... | ... | @@ -3563,7 +3562,7 @@ fn performAllTheWorkInner( |
| 3563 | 3562 | } |
| 3564 | 3563 | } |
| 3565 | 3564 | |
| 3566 | if (comp.module) |zcu| { | |
| 3565 | if (comp.zcu) |zcu| { | |
| 3567 | 3566 | { |
| 3568 | 3567 | // Worker threads may append to zcu.files and zcu.import_table |
| 3569 | 3568 | // so we must hold the lock while spawning those tasks, since |
| ... | ... | @@ -3606,7 +3605,7 @@ fn performAllTheWorkInner( |
| 3606 | 3605 | 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 }); |
| 3607 | 3606 | if (comp.job_queued_fuzzer_lib) work_queue_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); |
| 3608 | 3607 | |
| 3609 | if (comp.module) |zcu| { | |
| 3608 | if (comp.zcu) |zcu| { | |
| 3610 | 3609 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; |
| 3611 | 3610 | if (comp.incremental) { |
| 3612 | 3611 | const update_zir_refs_node = main_progress_node.start("Update ZIR References", 0); |
| ... | ... | @@ -3638,7 +3637,7 @@ fn performAllTheWorkInner( |
| 3638 | 3637 | try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job, main_progress_node); |
| 3639 | 3638 | continue :work; |
| 3640 | 3639 | }; |
| 3641 | if (comp.module) |zcu| { | |
| 3640 | if (comp.zcu) |zcu| { | |
| 3642 | 3641 | // If there's no work queued, check if there's anything outdated |
| 3643 | 3642 | // which we need to work on, and queue it if so. |
| 3644 | 3643 | if (try zcu.findOutdatedToAnalyze()) |outdated| { |
| ... | ... | @@ -3666,7 +3665,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void { |
| 3666 | 3665 | fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progress.Node) JobError!void { |
| 3667 | 3666 | switch (job) { |
| 3668 | 3667 | .codegen_nav => |nav_index| { |
| 3669 | const zcu = comp.module.?; | |
| 3668 | const zcu = comp.zcu.?; | |
| 3670 | 3669 | const nav = zcu.intern_pool.getNav(nav_index); |
| 3671 | 3670 | if (nav.analysis_owner.unwrap()) |cau| { |
| 3672 | 3671 | const unit = InternPool.AnalUnit.wrap(.{ .cau = cau }); |
| ... | ... | @@ -3689,14 +3688,14 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3689 | 3688 | const named_frame = tracy.namedFrame("analyze_func"); |
| 3690 | 3689 | defer named_frame.end(); |
| 3691 | 3690 | |
| 3692 | const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) }; | |
| 3691 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3693 | 3692 | pt.ensureFuncBodyAnalyzed(func) catch |err| switch (err) { |
| 3694 | 3693 | error.OutOfMemory => return error.OutOfMemory, |
| 3695 | 3694 | error.AnalysisFail => return, |
| 3696 | 3695 | }; |
| 3697 | 3696 | }, |
| 3698 | 3697 | .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) }; | |
| 3700 | 3699 | pt.ensureCauAnalyzed(cau_index) catch |err| switch (err) { |
| 3701 | 3700 | error.OutOfMemory => return error.OutOfMemory, |
| 3702 | 3701 | error.AnalysisFail => return, |
| ... | ... | @@ -3725,7 +3724,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3725 | 3724 | const named_frame = tracy.namedFrame("resolve_type_fully"); |
| 3726 | 3725 | defer named_frame.end(); |
| 3727 | 3726 | |
| 3728 | const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) }; | |
| 3727 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3729 | 3728 | Type.fromInterned(ty).resolveFully(pt) catch |err| switch (err) { |
| 3730 | 3729 | error.OutOfMemory => return error.OutOfMemory, |
| 3731 | 3730 | error.AnalysisFail => return, |
| ... | ... | @@ -3738,7 +3737,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3738 | 3737 | if (true) @panic("TODO: update_line_number"); |
| 3739 | 3738 | |
| 3740 | 3739 | 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) }; | |
| 3742 | 3741 | const decl = pt.zcu.declPtr(decl_index); |
| 3743 | 3742 | const lf = comp.bin_file.?; |
| 3744 | 3743 | lf.updateDeclLineNumber(pt, decl_index) catch |err| { |
| ... | ... | @@ -3760,7 +3759,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3760 | 3759 | const named_frame = tracy.namedFrame("analyze_mod"); |
| 3761 | 3760 | defer named_frame.end(); |
| 3762 | 3761 | |
| 3763 | const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) }; | |
| 3762 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3764 | 3763 | pt.semaPkg(mod) catch |err| switch (err) { |
| 3765 | 3764 | error.OutOfMemory => return error.OutOfMemory, |
| 3766 | 3765 | error.AnalysisFail => return, |
| ... | ... | @@ -3924,7 +3923,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3924 | 3923 | |
| 3925 | 3924 | fn queueCodegenJob(comp: *Compilation, tid: usize, codegen_job: CodegenJob) !void { |
| 3926 | 3925 | if (InternPool.single_threaded or |
| 3927 | !comp.module.?.backendSupportsFeature(.separate_thread)) | |
| 3926 | !comp.zcu.?.backendSupportsFeature(.separate_thread)) | |
| 3928 | 3927 | return processOneCodegenJob(tid, comp, codegen_job); |
| 3929 | 3928 | |
| 3930 | 3929 | { |
| ... | ... | @@ -3963,14 +3962,14 @@ fn processOneCodegenJob(tid: usize, comp: *Compilation, codegen_job: CodegenJob) |
| 3963 | 3962 | const named_frame = tracy.namedFrame("codegen_nav"); |
| 3964 | 3963 | defer named_frame.end(); |
| 3965 | 3964 | |
| 3966 | const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) }; | |
| 3965 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3967 | 3966 | try pt.linkerUpdateNav(nav_index); |
| 3968 | 3967 | }, |
| 3969 | 3968 | .func => |func| { |
| 3970 | 3969 | const named_frame = tracy.namedFrame("codegen_func"); |
| 3971 | 3970 | defer named_frame.end(); |
| 3972 | 3971 | |
| 3973 | const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) }; | |
| 3972 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3974 | 3973 | // This call takes ownership of `func.air`. |
| 3975 | 3974 | try pt.linkerUpdateFunc(func.func, func.air); |
| 3976 | 3975 | }, |
| ... | ... | @@ -3995,7 +3994,7 @@ fn workerDocsCopy(comp: *Compilation) void { |
| 3995 | 3994 | } |
| 3996 | 3995 | |
| 3997 | 3996 | fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 3998 | const zcu = comp.module orelse | |
| 3997 | const zcu = comp.zcu orelse | |
| 3999 | 3998 | return comp.lockAndSetMiscFailure(.docs_copy, "no Zig code to document", .{}); |
| 4000 | 3999 | |
| 4001 | 4000 | const emit = comp.docs_emit.?; |
| ... | ... | @@ -4352,7 +4351,7 @@ fn workerCheckEmbedFile(comp: *Compilation, embed_file: *Zcu.EmbedFile) void { |
| 4352 | 4351 | } |
| 4353 | 4352 | |
| 4354 | 4353 | fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Zcu.EmbedFile) !void { |
| 4355 | const mod = comp.module.?; | |
| 4354 | const mod = comp.zcu.?; | |
| 4356 | 4355 | const ip = &mod.intern_pool; |
| 4357 | 4356 | var file = try embed_file.owner.root.openFile(embed_file.sub_file_path.toSlice(ip), .{}); |
| 4358 | 4357 | defer file.close(); |
| ... | ... | @@ -4665,7 +4664,7 @@ fn reportRetryableEmbedFileError( |
| 4665 | 4664 | embed_file: *Zcu.EmbedFile, |
| 4666 | 4665 | err: anyerror, |
| 4667 | 4666 | ) error{OutOfMemory}!void { |
| 4668 | const mod = comp.module.?; | |
| 4667 | const mod = comp.zcu.?; | |
| 4669 | 4668 | const gpa = mod.gpa; |
| 4670 | 4669 | const src_loc = embed_file.src_loc; |
| 4671 | 4670 | const ip = &mod.intern_pool; |
| ... | ... | @@ -4730,7 +4729,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 4730 | 4729 | // Special case when doing build-obj for just one C file. When there are more than one object |
| 4731 | 4730 | // file and building an object we need to link them together, but with just one it should go |
| 4732 | 4731 | // 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 | |
| 4734 | 4733 | comp.config.output_mode == .Obj and comp.objects.len == 0; |
| 4735 | 4734 | const o_basename_noext = if (direct_o) |
| 4736 | 4735 | 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 |
| 6003 | 6003 | |
| 6004 | 6004 | /// NOTE: Allocates place for result on virtual stack, when integer size > 64 bits |
| 6005 | 6005 | fn 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.?; | |
| 6007 | 6007 | const int_info = ty.intInfo(zcu); |
| 6008 | 6008 | const wasm_bits = toWasmBits(int_info.bits) orelse { |
| 6009 | 6009 | 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 { |
| 255 | 255 | @setCold(true); |
| 256 | 256 | std.debug.assert(emit.error_msg == null); |
| 257 | 257 | const comp = emit.bin_file.base.comp; |
| 258 | const zcu = comp.module.?; | |
| 258 | const zcu = comp.zcu.?; | |
| 259 | 259 | const gpa = comp.gpa; |
| 260 | 260 | emit.error_msg = try Zcu.ErrorMsg.create(gpa, zcu.navSrcLoc(emit.owner_nav), format, args); |
| 261 | 261 | return error.EmitFail; |
src/codegen/llvm.zig+2-2| ... | ... | @@ -864,7 +864,7 @@ pub const Object = struct { |
| 864 | 864 | // into the garbage can by converting into absolute paths. What |
| 865 | 865 | // a terrible tragedy. |
| 866 | 866 | const compile_unit_dir = blk: { |
| 867 | if (comp.module) |zcu| m: { | |
| 867 | if (comp.zcu) |zcu| m: { | |
| 868 | 868 | const d = try zcu.main_mod.root.joinString(arena, ""); |
| 869 | 869 | if (d.len == 0) break :m; |
| 870 | 870 | if (std.fs.path.isAbsolute(d)) break :blk d; |
| ... | ... | @@ -955,7 +955,7 @@ pub const Object = struct { |
| 955 | 955 | .gpa = gpa, |
| 956 | 956 | .builder = builder, |
| 957 | 957 | .pt = .{ |
| 958 | .zcu = comp.module.?, | |
| 958 | .zcu = comp.zcu.?, | |
| 959 | 959 | .tid = .main, |
| 960 | 960 | }, |
| 961 | 961 | .debug_compile_unit = debug_compile_unit, |
src/link.zig+1-1| ... | ... | @@ -755,7 +755,7 @@ pub const File = struct { |
| 755 | 755 | const directory = base.emit.root_dir; // Just an alias to make it shorter to type. |
| 756 | 756 | const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path}); |
| 757 | 757 | const full_out_path_z = try arena.dupeZ(u8, full_out_path); |
| 758 | const opt_zcu = comp.module; | |
| 758 | const opt_zcu = comp.zcu; | |
| 759 | 759 | |
| 760 | 760 | // If there is no Zig code to compile, then we should skip flushing the output file |
| 761 | 761 | // 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: |
| 418 | 418 | |
| 419 | 419 | const comp = self.base.comp; |
| 420 | 420 | const gpa = comp.gpa; |
| 421 | const zcu = self.base.comp.module.?; | |
| 421 | const zcu = self.base.comp.zcu.?; | |
| 422 | 422 | const ip = &zcu.intern_pool; |
| 423 | 423 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = tid }; |
| 424 | 424 |
src/link/Coff.zig+3-3| ... | ... | @@ -1354,7 +1354,7 @@ pub fn getOrCreateAtomForNav(self: *Coff, nav_index: InternPool.Nav.Index) !Atom |
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | fn getNavOutputSection(self: *Coff, nav_index: InternPool.Nav.Index) u16 { |
| 1357 | const zcu = self.base.comp.module.?; | |
| 1357 | const zcu = self.base.comp.zcu.?; | |
| 1358 | 1358 | const ip = &zcu.intern_pool; |
| 1359 | 1359 | const nav = ip.getNav(nav_index); |
| 1360 | 1360 | const ty = Type.fromInterned(nav.typeOf(ip)); |
| ... | ... | @@ -1609,7 +1609,7 @@ pub fn deleteExport( |
| 1609 | 1609 | .nav => |nav| self.navs.getPtr(nav), |
| 1610 | 1610 | .uav => |uav| self.uavs.getPtr(uav), |
| 1611 | 1611 | } orelse return; |
| 1612 | const zcu = self.base.comp.module.?; | |
| 1612 | const zcu = self.base.comp.zcu.?; | |
| 1613 | 1613 | const name_slice = name.toSlice(&zcu.intern_pool); |
| 1614 | 1614 | const sym_index = metadata.getExportPtr(self, name_slice) orelse return; |
| 1615 | 1615 | |
| ... | ... | @@ -1691,7 +1691,7 @@ pub fn flushModule(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 1691 | 1691 | defer sub_prog_node.end(); |
| 1692 | 1692 | |
| 1693 | 1693 | const pt: Zcu.PerThread = .{ |
| 1694 | .zcu = comp.module orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 1694 | .zcu = comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 1695 | 1695 | .tid = tid, |
| 1696 | 1696 | }; |
| 1697 | 1697 |
src/link/Coff/lld.zig+3-3| ... | ... | @@ -32,7 +32,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 32 | 32 | |
| 33 | 33 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 34 | 34 | // 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: { | |
| 36 | 36 | try self.flushModule(arena, tid, prog_node); |
| 37 | 37 | |
| 38 | 38 | 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 |
| 296 | 296 | if (self.subsystem) |explicit| break :blk explicit; |
| 297 | 297 | switch (target.os.tag) { |
| 298 | 298 | .windows => { |
| 299 | if (comp.module) |module| { | |
| 299 | if (comp.zcu) |module| { | |
| 300 | 300 | if (module.stage1_flags.have_dllmain_crt_startup or is_dyn_lib) |
| 301 | 301 | break :blk null; |
| 302 | 302 | 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 |
| 440 | 440 | } else { |
| 441 | 441 | try argv.append("-NODEFAULTLIB"); |
| 442 | 442 | if (!is_lib and entry_name == null) { |
| 443 | if (comp.module) |module| { | |
| 443 | if (comp.zcu) |module| { | |
| 444 | 444 | if (module.stage1_flags.have_winmain_crt_startup) { |
| 445 | 445 | try argv.append("-ENTRY:WinMainCRTStartup"); |
| 446 | 446 | } else { |
src/link/Elf.zig+2-2| ... | ... | @@ -212,7 +212,7 @@ pub fn createEmpty( |
| 212 | 212 | |
| 213 | 213 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 214 | 214 | const use_llvm = comp.config.use_llvm; |
| 215 | const opt_zcu = comp.module; | |
| 215 | const opt_zcu = comp.zcu; | |
| 216 | 216 | const output_mode = comp.config.output_mode; |
| 217 | 217 | const link_mode = comp.config.link_mode; |
| 218 | 218 | 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 |
| 2084 | 2084 | |
| 2085 | 2085 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 2086 | 2086 | // 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: { | |
| 2088 | 2088 | try self.flushModule(arena, tid, prog_node); |
| 2089 | 2089 | |
| 2090 | 2090 | 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 { |
| 128 | 128 | pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !void { |
| 129 | 129 | // Handle any lazy symbols that were emitted by incremental compilation. |
| 130 | 130 | 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 }; | |
| 132 | 132 | |
| 133 | 133 | // Most lazy symbols can be updated on first use, but |
| 134 | 134 | // anyerror needs to wait for everything to be flushed. |
| ... | ... | @@ -949,7 +949,7 @@ pub fn getOrCreateMetadataForNav( |
| 949 | 949 | if (!gop.found_existing) { |
| 950 | 950 | const any_non_single_threaded = elf_file.base.comp.config.any_non_single_threaded; |
| 951 | 951 | const symbol_index = try self.newSymbolWithAtom(gpa, 0); |
| 952 | const zcu = elf_file.base.comp.module.?; | |
| 952 | const zcu = elf_file.base.comp.zcu.?; | |
| 953 | 953 | const nav_val = Value.fromInterned(zcu.intern_pool.getNav(nav_index).status.resolved.val); |
| 954 | 954 | const sym = self.symbol(symbol_index); |
| 955 | 955 | if (nav_val.getVariable(zcu)) |variable| { |
| ... | ... | @@ -1626,7 +1626,7 @@ pub fn deleteExport( |
| 1626 | 1626 | .nav => |nav| self.navs.getPtr(nav), |
| 1627 | 1627 | .uav => |uav| self.uavs.getPtr(uav), |
| 1628 | 1628 | } orelse return; |
| 1629 | const mod = elf_file.base.comp.module.?; | |
| 1629 | const mod = elf_file.base.comp.zcu.?; | |
| 1630 | 1630 | const exp_name = name.toSlice(&mod.intern_pool); |
| 1631 | 1631 | const esym_index = metadata.@"export"(self, exp_name) orelse return; |
| 1632 | 1632 | log.debug("deleting export '{s}'", .{exp_name}); |
src/link/MachO.zig+1-1| ... | ... | @@ -164,7 +164,7 @@ pub fn createEmpty( |
| 164 | 164 | |
| 165 | 165 | const gpa = comp.gpa; |
| 166 | 166 | const use_llvm = comp.config.use_llvm; |
| 167 | const opt_zcu = comp.module; | |
| 167 | const opt_zcu = comp.zcu; | |
| 168 | 168 | const optimize_mode = comp.root_mod.optimize_mode; |
| 169 | 169 | const output_mode = comp.config.output_mode; |
| 170 | 170 | 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 |
| 566 | 566 | pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) !void { |
| 567 | 567 | // Handle any lazy symbols that were emitted by incremental compilation. |
| 568 | 568 | 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 }; | |
| 570 | 570 | |
| 571 | 571 | // Most lazy symbols can be updated on first use, but |
| 572 | 572 | // anyerror needs to wait for everything to be flushed. |
| ... | ... | @@ -1437,7 +1437,7 @@ pub fn deleteExport( |
| 1437 | 1437 | exported: Zcu.Exported, |
| 1438 | 1438 | name: InternPool.NullTerminatedString, |
| 1439 | 1439 | ) void { |
| 1440 | const mod = macho_file.base.comp.module.?; | |
| 1440 | const mod = macho_file.base.comp.zcu.?; | |
| 1441 | 1441 | |
| 1442 | 1442 | const metadata = switch (exported) { |
| 1443 | 1443 | .nav => |nav| self.navs.getPtr(nav), |
| ... | ... | @@ -1545,7 +1545,7 @@ pub fn getOrCreateMetadataForLazySymbol( |
| 1545 | 1545 | fn isThreadlocal(macho_file: *MachO, nav_index: InternPool.Nav.Index) bool { |
| 1546 | 1546 | if (!macho_file.base.comp.config.any_non_single_threaded) |
| 1547 | 1547 | return false; |
| 1548 | const ip = &macho_file.base.comp.module.?.intern_pool; | |
| 1548 | const ip = &macho_file.base.comp.zcu.?.intern_pool; | |
| 1549 | 1549 | return switch (ip.indexToKey(ip.getNav(nav_index).status.resolved.val)) { |
| 1550 | 1550 | .variable => |variable| variable.is_threadlocal, |
| 1551 | 1551 | .@"extern" => |@"extern"| @"extern".is_threadlocal, |
src/link/Plan9.zig+5-5| ... | ... | @@ -152,7 +152,7 @@ pub const Atom = struct { |
| 152 | 152 | return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } }; |
| 153 | 153 | } |
| 154 | 154 | fn getCode(self: CodePtr, plan9: *const Plan9) []u8 { |
| 155 | const zcu = plan9.base.comp.module.?; | |
| 155 | const zcu = plan9.base.comp.zcu.?; | |
| 156 | 156 | const ip = &zcu.intern_pool; |
| 157 | 157 | return if (self.code_ptr) |p| p[0..self.other.code_len] else blk: { |
| 158 | 158 | const nav_index = self.other.nav_index; |
| ... | ... | @@ -317,7 +317,7 @@ pub fn createEmpty( |
| 317 | 317 | |
| 318 | 318 | fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void { |
| 319 | 319 | const gpa = self.base.comp.gpa; |
| 320 | const mod = self.base.comp.module.?; | |
| 320 | const mod = self.base.comp.zcu.?; | |
| 321 | 321 | const file_scope = mod.navFileScopeIndex(nav_index); |
| 322 | 322 | const fn_map_res = try self.fn_nav_table.getOrPut(gpa, file_scope); |
| 323 | 323 | if (fn_map_res.found_existing) { |
| ... | ... | @@ -607,7 +607,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, tid: Zcu.PerThread.Id, prog_n |
| 607 | 607 | defer assert(self.hdr.entry != 0x0); |
| 608 | 608 | |
| 609 | 609 | const pt: Zcu.PerThread = .{ |
| 610 | .zcu = self.base.comp.module orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 610 | .zcu = self.base.comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 611 | 611 | .tid = tid, |
| 612 | 612 | }; |
| 613 | 613 | |
| ... | ... | @@ -952,7 +952,7 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void { |
| 952 | 952 | const gpa = self.base.comp.gpa; |
| 953 | 953 | // TODO audit the lifetimes of decls table entries. It's possible to get |
| 954 | 954 | // freeDecl without any updateDecl in between. |
| 955 | const mod = self.base.comp.module.?; | |
| 955 | const mod = self.base.comp.zcu.?; | |
| 956 | 956 | const decl = mod.declPtr(decl_index); |
| 957 | 957 | const is_fn = decl.val.isFuncBody(mod); |
| 958 | 958 | if (is_fn) { |
| ... | ... | @@ -1256,7 +1256,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void { |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 1259 | const mod = self.base.comp.module.?; | |
| 1259 | const mod = self.base.comp.zcu.?; | |
| 1260 | 1260 | const ip = &mod.intern_pool; |
| 1261 | 1261 | const writer = buf.writer(); |
| 1262 | 1262 | // 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 |
| 229 | 229 | defer error_info.deinit(); |
| 230 | 230 | |
| 231 | 231 | try error_info.appendSlice("zig_errors:"); |
| 232 | const ip = &self.base.comp.module.?.intern_pool; | |
| 232 | const ip = &self.base.comp.zcu.?.intern_pool; | |
| 233 | 233 | for (ip.global_error_set.getNamesFromMainThread()) |name| { |
| 234 | 234 | // Errors can contain pretty much any character - to encode them in a string we must escape |
| 235 | 235 | // 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( |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | if (comp.module) |zcu| { | |
| 559 | if (comp.zcu) |zcu| { | |
| 560 | 560 | if (!use_llvm) { |
| 561 | 561 | const index: File.Index = @enumFromInt(wasm.files.len); |
| 562 | 562 | var zig_object: ZigObject = .{ |
| ... | ... | @@ -3352,7 +3352,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: |
| 3352 | 3352 | |
| 3353 | 3353 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 3354 | 3354 | // 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: { | |
| 3356 | 3356 | try wasm.flushModule(arena, tid, prog_node); |
| 3357 | 3357 | |
| 3358 | 3358 | if (fs.path.dirname(full_out_path)) |dirname| { |
src/link/Wasm/ZigObject.zig+6-6| ... | ... | @@ -487,7 +487,7 @@ fn lowerConst( |
| 487 | 487 | src_loc: Zcu.LazySrcLoc, |
| 488 | 488 | ) !LowerConstResult { |
| 489 | 489 | const gpa = wasm_file.base.comp.gpa; |
| 490 | const zcu = wasm_file.base.comp.module.?; | |
| 490 | const zcu = wasm_file.base.comp.zcu.?; | |
| 491 | 491 | |
| 492 | 492 | const ty = val.typeOf(zcu); |
| 493 | 493 | |
| ... | ... | @@ -604,7 +604,7 @@ fn populateErrorNameTable(zig_object: *ZigObject, wasm_file: *Wasm, tid: Zcu.Per |
| 604 | 604 | |
| 605 | 605 | // Addend for each relocation to the table |
| 606 | 606 | 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 }; | |
| 608 | 608 | const slice_ty = Type.slice_const_u8_sentinel_0; |
| 609 | 609 | const atom = wasm_file.getAtomPtr(atom_index); |
| 610 | 610 | { |
| ... | ... | @@ -803,7 +803,7 @@ pub fn getUavVAddr( |
| 803 | 803 | const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; |
| 804 | 804 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); |
| 805 | 805 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 806 | const mod = wasm_file.base.comp.module.?; | |
| 806 | const mod = wasm_file.base.comp.zcu.?; | |
| 807 | 807 | const ty = Type.fromInterned(mod.intern_pool.typeOf(uav)); |
| 808 | 808 | if (ty.zigTypeTag(mod) == .Fn) { |
| 809 | 809 | std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations |
| ... | ... | @@ -834,7 +834,7 @@ pub fn deleteExport( |
| 834 | 834 | exported: Zcu.Exported, |
| 835 | 835 | name: InternPool.NullTerminatedString, |
| 836 | 836 | ) void { |
| 837 | const mod = wasm_file.base.comp.module.?; | |
| 837 | const mod = wasm_file.base.comp.zcu.?; | |
| 838 | 838 | const nav_index = switch (exported) { |
| 839 | 839 | .nav => |nav_index| nav_index, |
| 840 | 840 | .uav => @panic("TODO: implement Wasm linker code for exporting a constant value"), |
| ... | ... | @@ -930,7 +930,7 @@ pub fn updateExports( |
| 930 | 930 | |
| 931 | 931 | pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.Nav.Index) void { |
| 932 | 932 | const gpa = wasm_file.base.comp.gpa; |
| 933 | const mod = wasm_file.base.comp.module.?; | |
| 933 | const mod = wasm_file.base.comp.zcu.?; | |
| 934 | 934 | const ip = &mod.intern_pool; |
| 935 | 935 | const nav_info = zig_object.navs.getPtr(nav_index).?; |
| 936 | 936 | const atom_index = nav_info.atom; |
| ... | ... | @@ -1016,7 +1016,7 @@ fn setupErrorsLen(zig_object: *ZigObject, wasm_file: *Wasm) !void { |
| 1016 | 1016 | const gpa = wasm_file.base.comp.gpa; |
| 1017 | 1017 | const sym_index = zig_object.findGlobalSymbol("__zig_errors_len") orelse return; |
| 1018 | 1018 | |
| 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; | |
| 1020 | 1020 | // overwrite existing atom if it already exists (maybe the error set has increased) |
| 1021 | 1021 | // if not, allocate a new atom. |
| 1022 | 1022 | const atom_index = if (wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = sym_index })) |index| blk: { |