| ... | ... | @@ -2384,7 +2384,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2384 | 2384 | }; |
| 2385 | 2385 | comp.c_object_table.putAssumeCapacityNoClobber(c_object, {}); |
| 2386 | 2386 | } |
| 2387 | | comp.link_task_queue.pending_prelink_tasks += @intCast(comp.c_object_table.count()); |
| 2388 | 2387 | |
| 2389 | 2388 | // Add a `Win32Resource` for each `rc_source_files` and one for `manifest_file`. |
| 2390 | 2389 | const win32_resource_count = |
| ... | ... | @@ -2392,10 +2391,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2392 | 2391 | if (win32_resource_count > 0) { |
| 2393 | 2392 | dev.check(.win32_resource); |
| 2394 | 2393 | try comp.win32_resource_table.ensureTotalCapacity(gpa, win32_resource_count); |
| 2395 | | // Add this after adding logic to updateWin32Resource to pass the |
| 2396 | | // result into link.loadInput. loadInput integration is not implemented |
| 2397 | | // for Windows linking logic yet. |
| 2398 | | //comp.link_task_queue.pending_prelink_tasks += @intCast(win32_resource_count); |
| 2399 | 2394 | for (options.rc_source_files) |rc_source_file| { |
| 2400 | 2395 | const win32_resource = try gpa.create(Win32Resource); |
| 2401 | 2396 | errdefer gpa.destroy(win32_resource); |
| ... | ... | @@ -2454,58 +2449,47 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2454 | 2449 | |
| 2455 | 2450 | if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| { |
| 2456 | 2451 | comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; |
| 2457 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2458 | 2452 | } |
| 2459 | 2453 | switch (comp.config.link_mode) { |
| 2460 | 2454 | .static => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_a)] = true, |
| 2461 | 2455 | .dynamic => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_so)] = true, |
| 2462 | 2456 | } |
| 2463 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2464 | 2457 | } else if (target.isGnuLibC()) { |
| 2465 | 2458 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 2466 | 2459 | |
| 2467 | 2460 | if (glibc.needsCrt0(comp.config.output_mode)) |f| { |
| 2468 | 2461 | comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; |
| 2469 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2470 | 2462 | } |
| 2471 | 2463 | comp.queued_jobs.glibc_shared_objects = true; |
| 2472 | | comp.link_task_queue.pending_prelink_tasks += glibc.sharedObjectsCount(target); |
| 2473 | 2464 | |
| 2474 | 2465 | comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true; |
| 2475 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2476 | 2466 | } else if (target.isFreeBSDLibC()) { |
| 2477 | 2467 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 2478 | 2468 | |
| 2479 | 2469 | if (freebsd.needsCrt0(comp.config.output_mode)) |f| { |
| 2480 | 2470 | comp.queued_jobs.freebsd_crt_file[@intFromEnum(f)] = true; |
| 2481 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2482 | 2471 | } |
| 2483 | 2472 | |
| 2484 | 2473 | comp.queued_jobs.freebsd_shared_objects = true; |
| 2485 | | comp.link_task_queue.pending_prelink_tasks += freebsd.sharedObjectsCount(); |
| 2486 | 2474 | } else if (target.isNetBSDLibC()) { |
| 2487 | 2475 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 2488 | 2476 | |
| 2489 | 2477 | if (netbsd.needsCrt0(comp.config.output_mode)) |f| { |
| 2490 | 2478 | comp.queued_jobs.netbsd_crt_file[@intFromEnum(f)] = true; |
| 2491 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2492 | 2479 | } |
| 2493 | 2480 | |
| 2494 | 2481 | comp.queued_jobs.netbsd_shared_objects = true; |
| 2495 | | comp.link_task_queue.pending_prelink_tasks += netbsd.sharedObjectsCount(); |
| 2496 | 2482 | } else if (target.isWasiLibC()) { |
| 2497 | 2483 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 2498 | 2484 | |
| 2499 | 2485 | comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.execModelCrtFile(comp.config.wasi_exec_model))] = true; |
| 2500 | 2486 | comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.CrtFile.libc_a)] = true; |
| 2501 | | comp.link_task_queue.pending_prelink_tasks += 2; |
| 2502 | 2487 | } else if (target.isMinGW()) { |
| 2503 | 2488 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 2504 | 2489 | |
| 2505 | 2490 | const main_crt_file: mingw.CrtFile = if (is_dyn_lib) .dllcrt2_o else .crt2_o; |
| 2506 | 2491 | comp.queued_jobs.mingw_crt_file[@intFromEnum(main_crt_file)] = true; |
| 2507 | 2492 | comp.queued_jobs.mingw_crt_file[@intFromEnum(mingw.CrtFile.libmingw32_lib)] = true; |
| 2508 | | comp.link_task_queue.pending_prelink_tasks += 2; |
| 2509 | 2493 | |
| 2510 | 2494 | // When linking mingw-w64 there are some import libs we always need. |
| 2511 | 2495 | try comp.windows_libs.ensureUnusedCapacity(gpa, mingw.always_link_libs.len); |
| ... | ... | @@ -2519,7 +2503,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2519 | 2503 | target.isMinGW()) |
| 2520 | 2504 | { |
| 2521 | 2505 | comp.queued_jobs.zigc_lib = true; |
| 2522 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2523 | 2506 | } |
| 2524 | 2507 | } |
| 2525 | 2508 | |
| ... | ... | @@ -2536,50 +2519,41 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2536 | 2519 | } |
| 2537 | 2520 | if (comp.wantBuildLibUnwindFromSource()) { |
| 2538 | 2521 | comp.queued_jobs.libunwind = true; |
| 2539 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2540 | 2522 | } |
| 2541 | 2523 | if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.link_libcpp) { |
| 2542 | 2524 | comp.queued_jobs.libcxx = true; |
| 2543 | 2525 | comp.queued_jobs.libcxxabi = true; |
| 2544 | | comp.link_task_queue.pending_prelink_tasks += 2; |
| 2545 | 2526 | } |
| 2546 | 2527 | if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.any_sanitize_thread) { |
| 2547 | 2528 | comp.queued_jobs.libtsan = true; |
| 2548 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2549 | 2529 | } |
| 2550 | 2530 | |
| 2551 | 2531 | if (can_build_compiler_rt) { |
| 2552 | 2532 | if (comp.compiler_rt_strat == .lib) { |
| 2553 | 2533 | log.debug("queuing a job to build compiler_rt_lib", .{}); |
| 2554 | 2534 | comp.queued_jobs.compiler_rt_lib = true; |
| 2555 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2556 | 2535 | } else if (comp.compiler_rt_strat == .obj) { |
| 2557 | 2536 | log.debug("queuing a job to build compiler_rt_obj", .{}); |
| 2558 | 2537 | // In this case we are making a static library, so we ask |
| 2559 | 2538 | // for a compiler-rt object to put in it. |
| 2560 | 2539 | comp.queued_jobs.compiler_rt_obj = true; |
| 2561 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2562 | 2540 | } else if (comp.compiler_rt_strat == .dyn_lib) { |
| 2563 | 2541 | // hack for stage2_x86_64 + coff |
| 2564 | 2542 | log.debug("queuing a job to build compiler_rt_dyn_lib", .{}); |
| 2565 | 2543 | comp.queued_jobs.compiler_rt_dyn_lib = true; |
| 2566 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2567 | 2544 | } |
| 2568 | 2545 | |
| 2569 | 2546 | if (comp.ubsan_rt_strat == .lib) { |
| 2570 | 2547 | log.debug("queuing a job to build ubsan_rt_lib", .{}); |
| 2571 | 2548 | comp.queued_jobs.ubsan_rt_lib = true; |
| 2572 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2573 | 2549 | } else if (comp.ubsan_rt_strat == .obj) { |
| 2574 | 2550 | log.debug("queuing a job to build ubsan_rt_obj", .{}); |
| 2575 | 2551 | comp.queued_jobs.ubsan_rt_obj = true; |
| 2576 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2577 | 2552 | } |
| 2578 | 2553 | |
| 2579 | 2554 | if (is_exe_or_dyn_lib and comp.config.any_fuzz) { |
| 2580 | 2555 | log.debug("queuing a job to build libfuzzer", .{}); |
| 2581 | 2556 | comp.queued_jobs.fuzzer_lib = true; |
| 2582 | | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2583 | 2557 | } |
| 2584 | 2558 | } |
| 2585 | 2559 | } |
| ... | ... | @@ -2587,8 +2561,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2587 | 2561 | try comp.link_task_queue.queued_prelink.append(gpa, .load_explicitly_provided); |
| 2588 | 2562 | } |
| 2589 | 2563 | log.debug("queued prelink tasks: {d}", .{comp.link_task_queue.queued_prelink.items.len}); |
| 2590 | | log.debug("pending prelink tasks: {d}", .{comp.link_task_queue.pending_prelink_tasks}); |
| 2591 | | |
| 2592 | 2564 | return comp; |
| 2593 | 2565 | } |
| 2594 | 2566 | |
| ... | ... | @@ -4408,10 +4380,8 @@ fn performAllTheWork( |
| 4408 | 4380 | comp.link_task_wait_group.reset(); |
| 4409 | 4381 | defer comp.link_task_wait_group.wait(); |
| 4410 | 4382 | |
| 4411 | | comp.link_prog_node.increaseEstimatedTotalItems( |
| 4412 | | comp.link_task_queue.queued_prelink.items.len + // already queued prelink tasks |
| 4413 | | comp.link_task_queue.pending_prelink_tasks, // prelink tasks which will be queued |
| 4414 | | ); |
| 4383 | // Already-queued prelink tasks |
| 4384 | comp.link_prog_node.increaseEstimatedTotalItems(comp.link_task_queue.queued_prelink.items.len); |
| 4415 | 4385 | comp.link_task_queue.start(comp); |
| 4416 | 4386 | |
| 4417 | 4387 | if (comp.emit_docs != null) { |
| ... | ... | @@ -4427,6 +4397,7 @@ fn performAllTheWork( |
| 4427 | 4397 | // compiler-rt due to LLD bugs as well, e.g.: |
| 4428 | 4398 | // |
| 4429 | 4399 | // https://github.com/llvm/llvm-project/issues/43698#issuecomment-2542660611 |
| 4400 | comp.link_task_queue.startPrelinkItem(); |
| 4430 | 4401 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4431 | 4402 | comp, |
| 4432 | 4403 | "compiler_rt.zig", |
| ... | ... | @@ -4444,6 +4415,7 @@ fn performAllTheWork( |
| 4444 | 4415 | } |
| 4445 | 4416 | |
| 4446 | 4417 | if (comp.queued_jobs.compiler_rt_obj and comp.compiler_rt_obj == null) { |
| 4418 | comp.link_task_queue.startPrelinkItem(); |
| 4447 | 4419 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4448 | 4420 | comp, |
| 4449 | 4421 | "compiler_rt.zig", |
| ... | ... | @@ -4462,6 +4434,7 @@ fn performAllTheWork( |
| 4462 | 4434 | |
| 4463 | 4435 | // hack for stage2_x86_64 + coff |
| 4464 | 4436 | if (comp.queued_jobs.compiler_rt_dyn_lib and comp.compiler_rt_dyn_lib == null) { |
| 4437 | comp.link_task_queue.startPrelinkItem(); |
| 4465 | 4438 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4466 | 4439 | comp, |
| 4467 | 4440 | "compiler_rt.zig", |
| ... | ... | @@ -4479,6 +4452,7 @@ fn performAllTheWork( |
| 4479 | 4452 | } |
| 4480 | 4453 | |
| 4481 | 4454 | if (comp.queued_jobs.fuzzer_lib and comp.fuzzer_lib == null) { |
| 4455 | comp.link_task_queue.startPrelinkItem(); |
| 4482 | 4456 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4483 | 4457 | comp, |
| 4484 | 4458 | "fuzzer.zig", |
| ... | ... | @@ -4493,6 +4467,7 @@ fn performAllTheWork( |
| 4493 | 4467 | } |
| 4494 | 4468 | |
| 4495 | 4469 | if (comp.queued_jobs.ubsan_rt_lib and comp.ubsan_rt_lib == null) { |
| 4470 | comp.link_task_queue.startPrelinkItem(); |
| 4496 | 4471 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4497 | 4472 | comp, |
| 4498 | 4473 | "ubsan_rt.zig", |
| ... | ... | @@ -4509,6 +4484,7 @@ fn performAllTheWork( |
| 4509 | 4484 | } |
| 4510 | 4485 | |
| 4511 | 4486 | if (comp.queued_jobs.ubsan_rt_obj and comp.ubsan_rt_obj == null) { |
| 4487 | comp.link_task_queue.startPrelinkItem(); |
| 4512 | 4488 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4513 | 4489 | comp, |
| 4514 | 4490 | "ubsan_rt.zig", |
| ... | ... | @@ -4525,40 +4501,49 @@ fn performAllTheWork( |
| 4525 | 4501 | } |
| 4526 | 4502 | |
| 4527 | 4503 | if (comp.queued_jobs.glibc_shared_objects) { |
| 4504 | comp.link_task_queue.startPrelinkItem(); |
| 4528 | 4505 | comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); |
| 4529 | 4506 | } |
| 4530 | 4507 | |
| 4531 | 4508 | if (comp.queued_jobs.freebsd_shared_objects) { |
| 4509 | comp.link_task_queue.startPrelinkItem(); |
| 4532 | 4510 | comp.link_task_wait_group.spawnManager(buildFreeBSDSharedObjects, .{ comp, main_progress_node }); |
| 4533 | 4511 | } |
| 4534 | 4512 | |
| 4535 | 4513 | if (comp.queued_jobs.netbsd_shared_objects) { |
| 4514 | comp.link_task_queue.startPrelinkItem(); |
| 4536 | 4515 | comp.link_task_wait_group.spawnManager(buildNetBSDSharedObjects, .{ comp, main_progress_node }); |
| 4537 | 4516 | } |
| 4538 | 4517 | |
| 4539 | 4518 | if (comp.queued_jobs.libunwind) { |
| 4519 | comp.link_task_queue.startPrelinkItem(); |
| 4540 | 4520 | comp.link_task_wait_group.spawnManager(buildLibUnwind, .{ comp, main_progress_node }); |
| 4541 | 4521 | } |
| 4542 | 4522 | |
| 4543 | 4523 | if (comp.queued_jobs.libcxx) { |
| 4524 | comp.link_task_queue.startPrelinkItem(); |
| 4544 | 4525 | comp.link_task_wait_group.spawnManager(buildLibCxx, .{ comp, main_progress_node }); |
| 4545 | 4526 | } |
| 4546 | 4527 | |
| 4547 | 4528 | if (comp.queued_jobs.libcxxabi) { |
| 4529 | comp.link_task_queue.startPrelinkItem(); |
| 4548 | 4530 | comp.link_task_wait_group.spawnManager(buildLibCxxAbi, .{ comp, main_progress_node }); |
| 4549 | 4531 | } |
| 4550 | 4532 | |
| 4551 | 4533 | if (comp.queued_jobs.libtsan) { |
| 4534 | comp.link_task_queue.startPrelinkItem(); |
| 4552 | 4535 | comp.link_task_wait_group.spawnManager(buildLibTsan, .{ comp, main_progress_node }); |
| 4553 | 4536 | } |
| 4554 | 4537 | |
| 4555 | 4538 | if (comp.queued_jobs.zigc_lib and comp.zigc_static_lib == null) { |
| 4539 | comp.link_task_queue.startPrelinkItem(); |
| 4556 | 4540 | comp.link_task_wait_group.spawnManager(buildLibZigC, .{ comp, main_progress_node }); |
| 4557 | 4541 | } |
| 4558 | 4542 | |
| 4559 | 4543 | for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| { |
| 4560 | 4544 | if (comp.queued_jobs.musl_crt_file[i]) { |
| 4561 | 4545 | const tag: musl.CrtFile = @enumFromInt(i); |
| 4546 | comp.link_task_queue.startPrelinkItem(); |
| 4562 | 4547 | comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); |
| 4563 | 4548 | } |
| 4564 | 4549 | } |
| ... | ... | @@ -4566,6 +4551,7 @@ fn performAllTheWork( |
| 4566 | 4551 | for (0..@typeInfo(glibc.CrtFile).@"enum".fields.len) |i| { |
| 4567 | 4552 | if (comp.queued_jobs.glibc_crt_file[i]) { |
| 4568 | 4553 | const tag: glibc.CrtFile = @enumFromInt(i); |
| 4554 | comp.link_task_queue.startPrelinkItem(); |
| 4569 | 4555 | comp.link_task_wait_group.spawnManager(buildGlibcCrtFile, .{ comp, tag, main_progress_node }); |
| 4570 | 4556 | } |
| 4571 | 4557 | } |
| ... | ... | @@ -4573,6 +4559,7 @@ fn performAllTheWork( |
| 4573 | 4559 | for (0..@typeInfo(freebsd.CrtFile).@"enum".fields.len) |i| { |
| 4574 | 4560 | if (comp.queued_jobs.freebsd_crt_file[i]) { |
| 4575 | 4561 | const tag: freebsd.CrtFile = @enumFromInt(i); |
| 4562 | comp.link_task_queue.startPrelinkItem(); |
| 4576 | 4563 | comp.link_task_wait_group.spawnManager(buildFreeBSDCrtFile, .{ comp, tag, main_progress_node }); |
| 4577 | 4564 | } |
| 4578 | 4565 | } |
| ... | ... | @@ -4580,6 +4567,7 @@ fn performAllTheWork( |
| 4580 | 4567 | for (0..@typeInfo(netbsd.CrtFile).@"enum".fields.len) |i| { |
| 4581 | 4568 | if (comp.queued_jobs.netbsd_crt_file[i]) { |
| 4582 | 4569 | const tag: netbsd.CrtFile = @enumFromInt(i); |
| 4570 | comp.link_task_queue.startPrelinkItem(); |
| 4583 | 4571 | comp.link_task_wait_group.spawnManager(buildNetBSDCrtFile, .{ comp, tag, main_progress_node }); |
| 4584 | 4572 | } |
| 4585 | 4573 | } |
| ... | ... | @@ -4587,6 +4575,7 @@ fn performAllTheWork( |
| 4587 | 4575 | for (0..@typeInfo(wasi_libc.CrtFile).@"enum".fields.len) |i| { |
| 4588 | 4576 | if (comp.queued_jobs.wasi_libc_crt_file[i]) { |
| 4589 | 4577 | const tag: wasi_libc.CrtFile = @enumFromInt(i); |
| 4578 | comp.link_task_queue.startPrelinkItem(); |
| 4590 | 4579 | comp.link_task_wait_group.spawnManager(buildWasiLibcCrtFile, .{ comp, tag, main_progress_node }); |
| 4591 | 4580 | } |
| 4592 | 4581 | } |
| ... | ... | @@ -4594,6 +4583,7 @@ fn performAllTheWork( |
| 4594 | 4583 | for (0..@typeInfo(mingw.CrtFile).@"enum".fields.len) |i| { |
| 4595 | 4584 | if (comp.queued_jobs.mingw_crt_file[i]) { |
| 4596 | 4585 | const tag: mingw.CrtFile = @enumFromInt(i); |
| 4586 | comp.link_task_queue.startPrelinkItem(); |
| 4597 | 4587 | comp.link_task_wait_group.spawnManager(buildMingwCrtFile, .{ comp, tag, main_progress_node }); |
| 4598 | 4588 | } |
| 4599 | 4589 | } |
| ... | ... | @@ -4665,12 +4655,14 @@ fn performAllTheWork( |
| 4665 | 4655 | } |
| 4666 | 4656 | |
| 4667 | 4657 | while (comp.c_object_work_queue.readItem()) |c_object| { |
| 4658 | comp.link_task_queue.startPrelinkItem(); |
| 4668 | 4659 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateCObject, .{ |
| 4669 | 4660 | comp, c_object, main_progress_node, |
| 4670 | 4661 | }); |
| 4671 | 4662 | } |
| 4672 | 4663 | |
| 4673 | 4664 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { |
| 4665 | comp.link_task_queue.startPrelinkItem(); |
| 4674 | 4666 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateWin32Resource, .{ |
| 4675 | 4667 | comp, win32_resource, main_progress_node, |
| 4676 | 4668 | }); |
| ... | ... | @@ -4773,15 +4765,14 @@ fn performAllTheWork( |
| 4773 | 4765 | } |
| 4774 | 4766 | }; |
| 4775 | 4767 | |
| 4768 | // We aren't going to queue any more prelink tasks. |
| 4769 | comp.link_task_queue.finishPrelinkItem(comp); |
| 4770 | |
| 4776 | 4771 | if (!comp.separateCodegenThreadOk()) { |
| 4777 | 4772 | // Waits until all input files have been parsed. |
| 4778 | 4773 | comp.link_task_wait_group.wait(); |
| 4779 | 4774 | comp.link_task_wait_group.reset(); |
| 4780 | 4775 | std.log.scoped(.link).debug("finished waiting for link_task_wait_group", .{}); |
| 4781 | | if (comp.link_task_queue.pending_prelink_tasks > 0) { |
| 4782 | | // Indicates an error occurred preventing prelink phase from completing. |
| 4783 | | return; |
| 4784 | | } |
| 4785 | 4776 | } |
| 4786 | 4777 | |
| 4787 | 4778 | if (comp.zcu != null) { |
| ... | ... | @@ -5568,6 +5559,7 @@ fn workerUpdateCObject( |
| 5568 | 5559 | c_object: *CObject, |
| 5569 | 5560 | progress_node: std.Progress.Node, |
| 5570 | 5561 | ) void { |
| 5562 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5571 | 5563 | comp.updateCObject(c_object, progress_node) catch |err| switch (err) { |
| 5572 | 5564 | error.AnalysisFail => return, |
| 5573 | 5565 | else => { |
| ... | ... | @@ -5585,6 +5577,7 @@ fn workerUpdateWin32Resource( |
| 5585 | 5577 | win32_resource: *Win32Resource, |
| 5586 | 5578 | progress_node: std.Progress.Node, |
| 5587 | 5579 | ) void { |
| 5580 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5588 | 5581 | comp.updateWin32Resource(win32_resource, progress_node) catch |err| switch (err) { |
| 5589 | 5582 | error.AnalysisFail => return, |
| 5590 | 5583 | else => { |
| ... | ... | @@ -5628,6 +5621,7 @@ fn buildRt( |
| 5628 | 5621 | options: RtOptions, |
| 5629 | 5622 | out: *?CrtFile, |
| 5630 | 5623 | ) void { |
| 5624 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5631 | 5625 | comp.buildOutputFromZig( |
| 5632 | 5626 | root_source_name, |
| 5633 | 5627 | root_name, |
| ... | ... | @@ -5646,6 +5640,7 @@ fn buildRt( |
| 5646 | 5640 | } |
| 5647 | 5641 | |
| 5648 | 5642 | fn buildMuslCrtFile(comp: *Compilation, crt_file: musl.CrtFile, prog_node: std.Progress.Node) void { |
| 5643 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5649 | 5644 | if (musl.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5650 | 5645 | comp.queued_jobs.musl_crt_file[@intFromEnum(crt_file)] = false; |
| 5651 | 5646 | } else |err| switch (err) { |
| ... | ... | @@ -5657,6 +5652,7 @@ fn buildMuslCrtFile(comp: *Compilation, crt_file: musl.CrtFile, prog_node: std.P |
| 5657 | 5652 | } |
| 5658 | 5653 | |
| 5659 | 5654 | fn buildGlibcCrtFile(comp: *Compilation, crt_file: glibc.CrtFile, prog_node: std.Progress.Node) void { |
| 5655 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5660 | 5656 | if (glibc.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5661 | 5657 | comp.queued_jobs.glibc_crt_file[@intFromEnum(crt_file)] = false; |
| 5662 | 5658 | } else |err| switch (err) { |
| ... | ... | @@ -5668,6 +5664,7 @@ fn buildGlibcCrtFile(comp: *Compilation, crt_file: glibc.CrtFile, prog_node: std |
| 5668 | 5664 | } |
| 5669 | 5665 | |
| 5670 | 5666 | fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5667 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5671 | 5668 | if (glibc.buildSharedObjects(comp, prog_node)) |_| { |
| 5672 | 5669 | // The job should no longer be queued up since it succeeded. |
| 5673 | 5670 | comp.queued_jobs.glibc_shared_objects = false; |
| ... | ... | @@ -5680,6 +5677,7 @@ fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) voi |
| 5680 | 5677 | } |
| 5681 | 5678 | |
| 5682 | 5679 | fn buildFreeBSDCrtFile(comp: *Compilation, crt_file: freebsd.CrtFile, prog_node: std.Progress.Node) void { |
| 5680 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5683 | 5681 | if (freebsd.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5684 | 5682 | comp.queued_jobs.freebsd_crt_file[@intFromEnum(crt_file)] = false; |
| 5685 | 5683 | } else |err| switch (err) { |
| ... | ... | @@ -5691,6 +5689,7 @@ fn buildFreeBSDCrtFile(comp: *Compilation, crt_file: freebsd.CrtFile, prog_node: |
| 5691 | 5689 | } |
| 5692 | 5690 | |
| 5693 | 5691 | fn buildFreeBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5692 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5694 | 5693 | if (freebsd.buildSharedObjects(comp, prog_node)) |_| { |
| 5695 | 5694 | // The job should no longer be queued up since it succeeded. |
| 5696 | 5695 | comp.queued_jobs.freebsd_shared_objects = false; |
| ... | ... | @@ -5703,6 +5702,7 @@ fn buildFreeBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) v |
| 5703 | 5702 | } |
| 5704 | 5703 | |
| 5705 | 5704 | fn buildNetBSDCrtFile(comp: *Compilation, crt_file: netbsd.CrtFile, prog_node: std.Progress.Node) void { |
| 5705 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5706 | 5706 | if (netbsd.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5707 | 5707 | comp.queued_jobs.netbsd_crt_file[@intFromEnum(crt_file)] = false; |
| 5708 | 5708 | } else |err| switch (err) { |
| ... | ... | @@ -5714,6 +5714,7 @@ fn buildNetBSDCrtFile(comp: *Compilation, crt_file: netbsd.CrtFile, prog_node: s |
| 5714 | 5714 | } |
| 5715 | 5715 | |
| 5716 | 5716 | fn buildNetBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5717 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5717 | 5718 | if (netbsd.buildSharedObjects(comp, prog_node)) |_| { |
| 5718 | 5719 | // The job should no longer be queued up since it succeeded. |
| 5719 | 5720 | comp.queued_jobs.netbsd_shared_objects = false; |
| ... | ... | @@ -5726,6 +5727,7 @@ fn buildNetBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) vo |
| 5726 | 5727 | } |
| 5727 | 5728 | |
| 5728 | 5729 | fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std.Progress.Node) void { |
| 5730 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5729 | 5731 | if (mingw.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5730 | 5732 | comp.queued_jobs.mingw_crt_file[@intFromEnum(crt_file)] = false; |
| 5731 | 5733 | } else |err| switch (err) { |
| ... | ... | @@ -5737,6 +5739,7 @@ fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std |
| 5737 | 5739 | } |
| 5738 | 5740 | |
| 5739 | 5741 | fn buildWasiLibcCrtFile(comp: *Compilation, crt_file: wasi_libc.CrtFile, prog_node: std.Progress.Node) void { |
| 5742 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5740 | 5743 | if (wasi_libc.buildCrtFile(comp, crt_file, prog_node)) |_| { |
| 5741 | 5744 | comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(crt_file)] = false; |
| 5742 | 5745 | } else |err| switch (err) { |
| ... | ... | @@ -5748,6 +5751,7 @@ fn buildWasiLibcCrtFile(comp: *Compilation, crt_file: wasi_libc.CrtFile, prog_no |
| 5748 | 5751 | } |
| 5749 | 5752 | |
| 5750 | 5753 | fn buildLibUnwind(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5754 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5751 | 5755 | if (libunwind.buildStaticLib(comp, prog_node)) |_| { |
| 5752 | 5756 | comp.queued_jobs.libunwind = false; |
| 5753 | 5757 | } else |err| switch (err) { |
| ... | ... | @@ -5757,6 +5761,7 @@ fn buildLibUnwind(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5757 | 5761 | } |
| 5758 | 5762 | |
| 5759 | 5763 | fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5764 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5760 | 5765 | if (libcxx.buildLibCxx(comp, prog_node)) |_| { |
| 5761 | 5766 | comp.queued_jobs.libcxx = false; |
| 5762 | 5767 | } else |err| switch (err) { |
| ... | ... | @@ -5766,6 +5771,7 @@ fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5766 | 5771 | } |
| 5767 | 5772 | |
| 5768 | 5773 | fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5774 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5769 | 5775 | if (libcxx.buildLibCxxAbi(comp, prog_node)) |_| { |
| 5770 | 5776 | comp.queued_jobs.libcxxabi = false; |
| 5771 | 5777 | } else |err| switch (err) { |
| ... | ... | @@ -5775,6 +5781,7 @@ fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5775 | 5781 | } |
| 5776 | 5782 | |
| 5777 | 5783 | fn buildLibTsan(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5784 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5778 | 5785 | if (libtsan.buildTsan(comp, prog_node)) |_| { |
| 5779 | 5786 | comp.queued_jobs.libtsan = false; |
| 5780 | 5787 | } else |err| switch (err) { |
| ... | ... | @@ -5784,6 +5791,7 @@ fn buildLibTsan(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5784 | 5791 | } |
| 5785 | 5792 | |
| 5786 | 5793 | fn buildLibZigC(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5794 | defer comp.link_task_queue.finishPrelinkItem(comp); |
| 5787 | 5795 | comp.buildOutputFromZig( |
| 5788 | 5796 | "c.zig", |
| 5789 | 5797 | "zigc", |
| ... | ... | @@ -7721,6 +7729,7 @@ pub fn queuePrelinkTaskMode(comp: *Compilation, path: Cache.Path, config: *const |
| 7721 | 7729 | /// Only valid to call during `update`. Automatically handles queuing up a |
| 7722 | 7730 | /// linker worker task if there is not already one. |
| 7723 | 7731 | pub fn queuePrelinkTasks(comp: *Compilation, tasks: []const link.PrelinkTask) void { |
| 7732 | comp.link_prog_node.increaseEstimatedTotalItems(tasks.len); |
| 7724 | 7733 | comp.link_task_queue.enqueuePrelink(comp, tasks) catch |err| switch (err) { |
| 7725 | 7734 | error.OutOfMemory => return comp.setAllocFailure(), |
| 7726 | 7735 | }; |