| ... | @@ -262,9 +262,6 @@ emit_asm: ?EmitLoc, | ... | @@ -262,9 +262,6 @@ emit_asm: ?EmitLoc, |
| 262 | emit_llvm_ir: ?EmitLoc, | 262 | emit_llvm_ir: ?EmitLoc, |
| 263 | emit_llvm_bc: ?EmitLoc, | 263 | emit_llvm_bc: ?EmitLoc, |
| 264 | | 264 | |
| 265 | work_queue_wait_group: WaitGroup = .{}, | | |
| 266 | astgen_wait_group: WaitGroup = .{}, | | |
| 267 | | | |
| 268 | llvm_opt_bisect_limit: c_int, | 265 | llvm_opt_bisect_limit: c_int, |
| 269 | | 266 | |
| 270 | file_system_inputs: ?*std.ArrayListUnmanaged(u8), | 267 | file_system_inputs: ?*std.ArrayListUnmanaged(u8), |
| ... | @@ -3535,13 +3532,13 @@ fn performAllTheWorkInner( | ... | @@ -3535,13 +3532,13 @@ fn performAllTheWorkInner( |
| 3535 | // (at least for now) single-threaded main work queue. However, C object compilation | 3532 | // (at least for now) single-threaded main work queue. However, C object compilation |
| 3536 | // only needs to be finished by the end of this function. | 3533 | // only needs to be finished by the end of this function. |
| 3537 | | 3534 | |
| 3538 | comp.work_queue_wait_group.reset(); | 3535 | var work_queue_wait_group: WaitGroup = .{}; |
| 3539 | defer comp.work_queue_wait_group.wait(); | 3536 | defer work_queue_wait_group.wait(); |
| 3540 | | 3537 | |
| 3541 | if (comp.docs_emit != null) { | 3538 | if (comp.docs_emit != null) { |
| 3542 | dev.check(.docs_emit); | 3539 | dev.check(.docs_emit); |
| 3543 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerDocsCopy, .{comp}); | 3540 | comp.thread_pool.spawnWg(&work_queue_wait_group, workerDocsCopy, .{comp}); |
| 3544 | comp.work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node }); | 3541 | work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node }); |
| 3545 | } | 3542 | } |
| 3546 | | 3543 | |
| 3547 | { | 3544 | { |
| ... | @@ -3551,8 +3548,8 @@ fn performAllTheWorkInner( | ... | @@ -3551,8 +3548,8 @@ fn performAllTheWorkInner( |
| 3551 | const zir_prog_node = main_progress_node.start("AST Lowering", 0); | 3548 | const zir_prog_node = main_progress_node.start("AST Lowering", 0); |
| 3552 | defer zir_prog_node.end(); | 3549 | defer zir_prog_node.end(); |
| 3553 | | 3550 | |
| 3554 | comp.astgen_wait_group.reset(); | 3551 | var astgen_wait_group: WaitGroup = .{}; |
| 3555 | defer comp.astgen_wait_group.wait(); | 3552 | defer astgen_wait_group.wait(); |
| 3556 | | 3553 | |
| 3557 | // builtin.zig is handled specially for two reasons: | 3554 | // builtin.zig is handled specially for two reasons: |
| 3558 | // 1. to avoid race condition of zig processes truncating each other's builtin.zig files | 3555 | // 1. to avoid race condition of zig processes truncating each other's builtin.zig files |
| ... | @@ -3574,7 +3571,7 @@ fn performAllTheWorkInner( | ... | @@ -3574,7 +3571,7 @@ fn performAllTheWorkInner( |
| 3574 | | 3571 | |
| 3575 | const file = mod.builtin_file orelse continue; | 3572 | const file = mod.builtin_file orelse continue; |
| 3576 | | 3573 | |
| 3577 | comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerUpdateBuiltinZigFile, .{ | 3574 | comp.thread_pool.spawnWg(&astgen_wait_group, workerUpdateBuiltinZigFile, .{ |
| 3578 | comp, mod, file, | 3575 | comp, mod, file, |
| 3579 | }); | 3576 | }); |
| 3580 | } | 3577 | } |
| ... | @@ -3594,32 +3591,36 @@ fn performAllTheWorkInner( | ... | @@ -3594,32 +3591,36 @@ fn performAllTheWorkInner( |
| 3594 | const path_digest = zcu.filePathDigest(file_index); | 3591 | const path_digest = zcu.filePathDigest(file_index); |
| 3595 | const root_decl = zcu.fileRootDecl(file_index); | 3592 | const root_decl = zcu.fileRootDecl(file_index); |
| 3596 | const file = zcu.fileByIndex(file_index); | 3593 | const file = zcu.fileByIndex(file_index); |
| 3597 | comp.thread_pool.spawnWgId(&comp.astgen_wait_group, workerAstGenFile, .{ | 3594 | comp.thread_pool.spawnWgId(&astgen_wait_group, workerAstGenFile, .{ |
| 3598 | comp, file, file_index, path_digest, root_decl, zir_prog_node, &comp.astgen_wait_group, .root, | 3595 | comp, file, file_index, path_digest, root_decl, zir_prog_node, &astgen_wait_group, .root, |
| 3599 | }); | 3596 | }); |
| 3600 | } | 3597 | } |
| 3601 | } | 3598 | } |
| 3602 | | 3599 | |
| 3603 | while (comp.embed_file_work_queue.readItem()) |embed_file| { | 3600 | while (comp.embed_file_work_queue.readItem()) |embed_file| { |
| 3604 | comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerCheckEmbedFile, .{ | 3601 | comp.thread_pool.spawnWg(&astgen_wait_group, workerCheckEmbedFile, .{ |
| 3605 | comp, embed_file, | 3602 | comp, embed_file, |
| 3606 | }); | 3603 | }); |
| 3607 | } | 3604 | } |
| 3608 | } | 3605 | } |
| 3609 | | 3606 | |
| 3610 | while (comp.c_object_work_queue.readItem()) |c_object| { | 3607 | while (comp.c_object_work_queue.readItem()) |c_object| { |
| 3611 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateCObject, .{ | 3608 | comp.thread_pool.spawnWg(&work_queue_wait_group, workerUpdateCObject, .{ |
| 3612 | comp, c_object, main_progress_node, | 3609 | comp, c_object, main_progress_node, |
| 3613 | }); | 3610 | }); |
| 3614 | } | 3611 | } |
| 3615 | | 3612 | |
| 3616 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { | 3613 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { |
| 3617 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateWin32Resource, .{ | 3614 | comp.thread_pool.spawnWg(&work_queue_wait_group, workerUpdateWin32Resource, .{ |
| 3618 | comp, win32_resource, main_progress_node, | 3615 | comp, win32_resource, main_progress_node, |
| 3619 | }); | 3616 | }); |
| 3620 | } | 3617 | } |
| 3621 | } | 3618 | } |
| 3622 | | 3619 | |
| | 3620 | if (comp.job_queued_compiler_rt_lib) work_queue_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node }); |
| | 3621 | 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 }); |
| | 3622 | if (comp.job_queued_fuzzer_lib) work_queue_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); |
| | 3623 | |
| 3623 | if (comp.module) |zcu| { | 3624 | if (comp.module) |zcu| { |
| 3624 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; | 3625 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; |
| 3625 | if (comp.incremental) { | 3626 | if (comp.incremental) { |
| ... | @@ -3633,7 +3634,7 @@ fn performAllTheWorkInner( | ... | @@ -3633,7 +3634,7 @@ fn performAllTheWorkInner( |
| 3633 | zcu.codegen_prog_node = main_progress_node.start("Code Generation", 0); | 3634 | zcu.codegen_prog_node = main_progress_node.start("Code Generation", 0); |
| 3634 | } | 3635 | } |
| 3635 | | 3636 | |
| 3636 | if (!InternPool.single_threaded) comp.thread_pool.spawnWgId(&comp.work_queue_wait_group, codegenThread, .{comp}); | 3637 | if (!InternPool.single_threaded) comp.thread_pool.spawnWgId(&work_queue_wait_group, codegenThread, .{comp}); |
| 3637 | defer if (!InternPool.single_threaded) { | 3638 | defer if (!InternPool.single_threaded) { |
| 3638 | { | 3639 | { |
| 3639 | comp.codegen_work.mutex.lock(); | 3640 | comp.codegen_work.mutex.lock(); |
| ... | @@ -3661,10 +3662,6 @@ fn performAllTheWorkInner( | ... | @@ -3661,10 +3662,6 @@ fn performAllTheWorkInner( |
| 3661 | } | 3662 | } |
| 3662 | break; | 3663 | break; |
| 3663 | } | 3664 | } |
| 3664 | | | |
| 3665 | buildCompilerRtOneShot(comp, &comp.job_queued_compiler_rt_lib, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node); | | |
| 3666 | buildCompilerRtOneShot(comp, &comp.job_queued_compiler_rt_obj, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node); | | |
| 3667 | buildCompilerRtOneShot(comp, &comp.job_queued_fuzzer_lib, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node); | | |
| 3668 | } | 3665 | } |
| 3669 | | 3666 | |
| 3670 | const JobError = Allocator.Error; | 3667 | const JobError = Allocator.Error; |
| ... | @@ -4668,18 +4665,14 @@ fn workerUpdateWin32Resource( | ... | @@ -4668,18 +4665,14 @@ fn workerUpdateWin32Resource( |
| 4668 | }; | 4665 | }; |
| 4669 | } | 4666 | } |
| 4670 | | 4667 | |
| 4671 | fn buildCompilerRtOneShot( | 4668 | fn buildRt( |
| 4672 | comp: *Compilation, | 4669 | comp: *Compilation, |
| 4673 | job_queued: *bool, | | |
| 4674 | root_source_name: []const u8, | 4670 | root_source_name: []const u8, |
| 4675 | misc_task: MiscTask, | 4671 | misc_task: MiscTask, |
| 4676 | output_mode: std.builtin.OutputMode, | 4672 | output_mode: std.builtin.OutputMode, |
| 4677 | out: *?CRTFile, | 4673 | out: *?CRTFile, |
| 4678 | prog_node: std.Progress.Node, | 4674 | prog_node: std.Progress.Node, |
| 4679 | ) void { | 4675 | ) void { |
| 4680 | if (!job_queued.*) return; | | |
| 4681 | job_queued.* = false; | | |
| 4682 | | | |
| 4683 | comp.buildOutputFromZig( | 4676 | comp.buildOutputFromZig( |
| 4684 | root_source_name, | 4677 | root_source_name, |
| 4685 | output_mode, | 4678 | output_mode, |