authorgravatar for readcuttingt@gmail.comTom Read Cutting <readcuttingt@gmail.com> 2023-02-12 10:48:39+00:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-02-14 12:05:30+01:00
log47e14b7ffbe02c800ac4c2b4f181ab6c7f022988
tree99692d15eacbc578ff18bfce5711c3a49ff7b2ea
parentd09e39aefd470ce80da0b0ada703a5c32290f4f1

Zld: Report archive file with cpu arch mismatch

This is just a simple/hacky feature to report the source of a linking error. I found this helpful in fixing-up some of my libs when recently switching from an x86_64 to aarch64 device, so thought it might be useful to others a well before zld has a fully featured error reporting system.

1 files changed, 7 insertions(+), 1 deletions(-)

src/link/MachO/zld.zig+7-1
......@@ -1065,7 +1065,13 @@ pub const Zld = struct {
10651065 assert(offsets.items.len > 0);
10661066
10671067 const object_id = @intCast(u16, self.objects.items.len);
1068 const object = try archive.parseObject(gpa, cpu_arch, offsets.items[0]);
1068 const object = archive.parseObject(gpa, cpu_arch, offsets.items[0]) catch |e| switch (e) {
1069 error.MismatchedCpuArchitecture => {
1070 log.err("CPU architecture mismatch found in {s}", .{archive.name});
1071 return e;
1072 },
1073 else => return e,
1074 };
10691075 try self.objects.append(gpa, object);
10701076 try self.resolveSymbolsInObject(object_id, resolver);
10711077