zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 47e14b7ffbe02c800ac4c2b4f181ab6c7f022988 (tree)
parent d09e39aefd470ce80da0b0ada703a5c32290f4f1
Author: Tom Read Cutting <readcuttingt@gmail.com>
Date:   Sun, 12 Feb 2023 10:48:39 +0000

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.

Diffstat:
Msrc/link/MachO/zld.zig | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig @@ -1065,7 +1065,13 @@ pub const Zld = struct { assert(offsets.items.len > 0); const object_id = @intCast(u16, self.objects.items.len); - const object = try archive.parseObject(gpa, cpu_arch, offsets.items[0]); + const object = archive.parseObject(gpa, cpu_arch, offsets.items[0]) catch |e| switch (e) { + error.MismatchedCpuArchitecture => { + log.err("CPU architecture mismatch found in {s}", .{archive.name}); + return e; + }, + else => return e, + }; try self.objects.append(gpa, object); try self.resolveSymbolsInObject(object_id, resolver);