Skip to content

Commit 9f235a1

Browse files
mluggandrewrk
authored andcommitted
link: mark prelink tasks as procesed under -fno-emit-bin
The old logic only decremented `remaining_prelink_tasks` if `bin_file` was not `null`. This meant that on `-fno-emit-bin` builds with registered prelink tasks (e.g. C source files), we exited from `Compilation.performAllTheWorkInner` early, assuming a prelink error. Instead, when `bin_file` is `null`, we still decrement `remaining_prelink_tasks`; we just don't do any actual work. Resolves: #22682
1 parent 9c9d393 commit 9f235a1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/link.zig

+14-6
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,10 @@ pub const Task = union(enum) {
14571457
pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
14581458
const diags = &comp.link_diags;
14591459
switch (task) {
1460-
.load_explicitly_provided => if (comp.bin_file) |base| {
1460+
.load_explicitly_provided => {
14611461
comp.remaining_prelink_tasks -= 1;
1462+
const base = comp.bin_file orelse return;
1463+
14621464
const prog_node = comp.work_queue_progress_node.start("Parse Linker Inputs", comp.link_inputs.len);
14631465
defer prog_node.end();
14641466
for (comp.link_inputs) |input| {
@@ -1475,8 +1477,10 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
14751477
prog_node.completeOne();
14761478
}
14771479
},
1478-
.load_host_libc => if (comp.bin_file) |base| {
1480+
.load_host_libc => {
14791481
comp.remaining_prelink_tasks -= 1;
1482+
const base = comp.bin_file orelse return;
1483+
14801484
const prog_node = comp.work_queue_progress_node.start("Linker Parse Host libc", 0);
14811485
defer prog_node.end();
14821486

@@ -1535,26 +1539,29 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
15351539
}
15361540
}
15371541
},
1538-
.load_object => |path| if (comp.bin_file) |base| {
1542+
.load_object => |path| {
15391543
comp.remaining_prelink_tasks -= 1;
1544+
const base = comp.bin_file orelse return;
15401545
const prog_node = comp.work_queue_progress_node.start("Linker Parse Object", 0);
15411546
defer prog_node.end();
15421547
base.openLoadObject(path) catch |err| switch (err) {
15431548
error.LinkFailure => return, // error reported via diags
15441549
else => |e| diags.addParseError(path, "failed to parse object: {s}", .{@errorName(e)}),
15451550
};
15461551
},
1547-
.load_archive => |path| if (comp.bin_file) |base| {
1552+
.load_archive => |path| {
15481553
comp.remaining_prelink_tasks -= 1;
1554+
const base = comp.bin_file orelse return;
15491555
const prog_node = comp.work_queue_progress_node.start("Linker Parse Archive", 0);
15501556
defer prog_node.end();
15511557
base.openLoadArchive(path, null) catch |err| switch (err) {
15521558
error.LinkFailure => return, // error reported via link_diags
15531559
else => |e| diags.addParseError(path, "failed to parse archive: {s}", .{@errorName(e)}),
15541560
};
15551561
},
1556-
.load_dso => |path| if (comp.bin_file) |base| {
1562+
.load_dso => |path| {
15571563
comp.remaining_prelink_tasks -= 1;
1564+
const base = comp.bin_file orelse return;
15581565
const prog_node = comp.work_queue_progress_node.start("Linker Parse Shared Library", 0);
15591566
defer prog_node.end();
15601567
base.openLoadDso(path, .{
@@ -1565,8 +1572,9 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
15651572
else => |e| diags.addParseError(path, "failed to parse shared library: {s}", .{@errorName(e)}),
15661573
};
15671574
},
1568-
.load_input => |input| if (comp.bin_file) |base| {
1575+
.load_input => |input| {
15691576
comp.remaining_prelink_tasks -= 1;
1577+
const base = comp.bin_file orelse return;
15701578
const prog_node = comp.work_queue_progress_node.start("Linker Parse Input", 0);
15711579
defer prog_node.end();
15721580
base.loadInput(input) catch |err| switch (err) {

0 commit comments

Comments
 (0)