| ... | ... | @@ -96,6 +96,7 @@ debug_line_sect_index: ?u8 = null, |
| 96 | 96 | has_tlv: bool = false, |
| 97 | 97 | binds_to_weak: bool = false, |
| 98 | 98 | weak_defines: bool = false, |
| 99 | has_errors: AtomicBool = AtomicBool.init(false), |
| 99 | 100 | |
| 100 | 101 | /// Options |
| 101 | 102 | /// SDK layout |
| ... | ... | @@ -469,8 +470,6 @@ pub fn flushModule(self: *MachO, arena: Allocator, tid: Zcu.PerThread.Id, prog_n |
| 469 | 470 | }; |
| 470 | 471 | } |
| 471 | 472 | |
| 472 | | if (self.base.hasErrors()) return error.FlushFailure; |
| 473 | | |
| 474 | 473 | try self.parseInputFiles(); |
| 475 | 474 | self.parseDependentDylibs() catch |err| { |
| 476 | 475 | switch (err) { |
| ... | ... | @@ -900,24 +899,36 @@ pub fn parseInputFiles(self: *MachO) !void { |
| 900 | 899 | const tracy = trace(@src()); |
| 901 | 900 | defer tracy.end(); |
| 902 | 901 | |
| 903 | | for (self.objects.items) |index| { |
| 904 | | self.getFile(index).?.parse(self) catch |err| switch (err) { |
| 905 | | error.MalformedObject, |
| 906 | | error.InvalidCpuArch, |
| 907 | | error.InvalidTarget, |
| 908 | | => {}, // already reported |
| 909 | | else => |e| try self.reportParseError2(index, "unexpected error: parsing input file failed with error {s}", .{@errorName(e)}), |
| 910 | | }; |
| 902 | const tp = self.base.comp.thread_pool; |
| 903 | var wg: WaitGroup = .{}; |
| 904 | |
| 905 | { |
| 906 | wg.reset(); |
| 907 | defer wg.wait(); |
| 908 | |
| 909 | for (self.objects.items) |index| { |
| 910 | tp.spawnWg(&wg, parseInputFileWorker, .{ self, index }); |
| 911 | } |
| 912 | for (self.dylibs.items) |index| { |
| 913 | tp.spawnWg(&wg, parseInputFileWorker, .{ self, index }); |
| 914 | } |
| 911 | 915 | } |
| 912 | | for (self.dylibs.items) |index| { |
| 913 | | self.getFile(index).?.parse(self) catch |err| switch (err) { |
| 916 | |
| 917 | if (self.has_errors.swap(false, .seq_cst)) return error.FlushFailure; |
| 918 | } |
| 919 | |
| 920 | fn parseInputFileWorker(self: *MachO, index: File.Index) void { |
| 921 | self.getFile(index).?.parse(self) catch |err| { |
| 922 | switch (err) { |
| 923 | error.MalformedObject, |
| 914 | 924 | error.MalformedDylib, |
| 915 | 925 | error.InvalidCpuArch, |
| 916 | 926 | error.InvalidTarget, |
| 917 | 927 | => {}, // already reported |
| 918 | | else => |e| try self.reportParseError2(index, "unexpected error: parsing input file failed with error {s}", .{@errorName(e)}), |
| 919 | | }; |
| 920 | | } |
| 928 | else => |e| self.reportParseError2(index, "unexpected error: parsing input file failed with error {s}", .{@errorName(e)}) catch {}, |
| 929 | } |
| 930 | _ = self.has_errors.swap(true, .seq_cst); |
| 931 | }; |
| 921 | 932 | } |
| 922 | 933 | |
| 923 | 934 | fn addArchive(self: *MachO, lib: SystemLib, must_link: bool, handle: File.HandleIndex, fat_arch: ?fat.Arch) !void { |
| ... | ... | @@ -4436,6 +4447,7 @@ const Alignment = Atom.Alignment; |
| 4436 | 4447 | const Allocator = mem.Allocator; |
| 4437 | 4448 | const Archive = @import("MachO/Archive.zig"); |
| 4438 | 4449 | pub const Atom = @import("MachO/Atom.zig"); |
| 4450 | const AtomicBool = std.atomic.Value(bool); |
| 4439 | 4451 | const Bind = bind.Bind; |
| 4440 | 4452 | const Cache = std.Build.Cache; |
| 4441 | 4453 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| ... | ... | @@ -4471,6 +4483,7 @@ const Thunk = thunks.Thunk; |
| 4471 | 4483 | const TlvPtrSection = synthetic.TlvPtrSection; |
| 4472 | 4484 | const Value = @import("../Value.zig"); |
| 4473 | 4485 | const UnwindInfo = @import("MachO/UnwindInfo.zig"); |
| 4486 | const WaitGroup = std.Thread.WaitGroup; |
| 4474 | 4487 | const WeakBind = bind.WeakBind; |
| 4475 | 4488 | const ZigGotSection = synthetic.ZigGotSection; |
| 4476 | 4489 | const ZigObject = @import("MachO/ZigObject.zig"); |