link.MachO: fix missing input classification

This commit is contained in:
Andrew Kelley 2024-10-16 14:38:46 -07:00
parent 65d42086ff
commit cbcd67ea90
2 changed files with 16 additions and 6 deletions

View File

@ -1997,8 +1997,8 @@ pub fn openObjectInput(diags: *Diags, path: Path) error{LinkFailure}!Input {
} };
}
pub fn openArchiveInput(diags: *Diags, path: Path) error{LinkFailure}!Input {
return .{ .archive = openObject(path, false, false) catch |err| {
pub fn openArchiveInput(diags: *Diags, path: Path, must_link: bool, hidden: bool) error{LinkFailure}!Input {
return .{ .archive = openObject(path, must_link, hidden) catch |err| {
return diags.failParse(path, "failed to open {}: {s}", .{ path, @errorName(err) });
} };
}

View File

@ -447,15 +447,25 @@ pub fn flushModule(self: *MachO, arena: Allocator, tid: Zcu.PerThread.Id, prog_n
};
for (system_libs.items) |lib| {
const dso_input = try link.openDsoInput(diags, lib.path, lib.needed, lib.weak, lib.reexport);
self.classifyInputFile(dso_input) catch |err|
diags.addParseError(lib.path, "failed to parse input file: {s}", .{@errorName(err)});
switch (Compilation.classifyFileExt(lib.path.sub_path)) {
.shared_library => {
const dso_input = try link.openDsoInput(diags, lib.path, lib.needed, lib.weak, lib.reexport);
self.classifyInputFile(dso_input) catch |err|
diags.addParseError(lib.path, "failed to parse input file: {s}", .{@errorName(err)});
},
.static_library => {
const archive_input = try link.openArchiveInput(diags, lib.path, lib.must_link, lib.hidden);
self.classifyInputFile(archive_input) catch |err|
diags.addParseError(lib.path, "failed to parse input file: {s}", .{@errorName(err)});
},
else => unreachable,
}
}
// Finally, link against compiler_rt.
if (comp.compiler_rt_lib) |crt_file| {
const path = crt_file.full_object_path;
self.classifyInputFile(try link.openArchiveInput(diags, path)) catch |err|
self.classifyInputFile(try link.openArchiveInput(diags, path, false, false)) catch |err|
diags.addParseError(path, "failed to parse archive: {s}", .{@errorName(err)});
} else if (comp.compiler_rt_obj) |crt_file| {
const path = crt_file.full_object_path;