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