authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-06 12:46:41+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-07 19:27:25+01:00
log352e27c55ca32fdc31dd01e3e60893775f03a318
tree73eaa40922d8a76e3cb1ed3a3239d3d5cacd2b01
parentee36131e6a8bf8611f8a6fd55116e98eae2ed63c

macho: move static lib flushing logic into Archive


2 files changed, 13 insertions(+), 17 deletions(-)

src/link/MachO.zig+1-17
......@@ -379,10 +379,6 @@ pub fn deinit(self: *MachO) void {
379379}
380380
381381pub fn flush(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void {
382 // TODO: I think this is just a temp and can be removed once we can emit static archives
383 if (self.base.isStaticLib() and build_options.have_llvm) {
384 return self.base.linkAsArchive(arena, prog_node);
385 }
386382 try self.flushModule(arena, prog_node);
387383}
388384
......@@ -395,8 +391,6 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node
395391
396392 if (self.llvm_object) |llvm_object| {
397393 try self.base.emitLlvmObject(arena, llvm_object, prog_node);
398 // TODO: I think this is just a temp and can be removed once we can emit static archives
399 if (self.base.isStaticLib() and build_options.have_llvm) return;
400394 }
401395
402396 var sub_prog_node = prog_node.start("MachO Flush", 0);
......@@ -417,7 +411,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node
417411 if (comp.verbose_link) try self.dumpArgv(comp);
418412
419413 if (self.getZigObject()) |zo| try zo.flushModule(self);
420 if (self.base.isStaticLib()) return self.flushStaticLib(comp, module_obj_path);
414 if (self.base.isStaticLib()) return Archive.flush(self, comp, module_obj_path);
421415 if (self.base.isObject()) return relocatable.flush(self, comp, module_obj_path);
422416
423417 var positionals = std.ArrayList(Compilation.LinkObject).init(gpa);
......@@ -892,16 +886,6 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void {
892886 Compilation.dump_argv(argv.items);
893887}
894888
895fn flushStaticLib(self: *MachO, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void {
896 _ = comp;
897 _ = module_obj_path;
898
899 var err = try self.addErrorWithNotes(0);
900 try err.addMsg(self, "TODO implement flushStaticLib", .{});
901
902 return error.FlushFailure;
903}
904
905889pub fn resolveLibSystem(
906890 self: *MachO,
907891 arena: Allocator,
src/link/MachO/Archive.zig+12
......@@ -143,7 +143,18 @@ pub fn parse(self: *Archive, macho_file: *MachO, path: []const u8, handle_index:
143143 }
144144}
145145
146pub fn flush(macho_file: *MachO, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void {
147 _ = comp;
148 _ = module_obj_path;
149
150 var err = try macho_file.addErrorWithNotes(0);
151 try err.addMsg(macho_file, "TODO implement flushStaticLib", .{});
152
153 return error.FlushFailure;
154}
155
146156const fat = @import("fat.zig");
157const link = @import("../../link.zig");
147158const log = std.log.scoped(.link);
148159const macho = std.macho;
149160const mem = std.mem;
......@@ -151,6 +162,7 @@ const std = @import("std");
151162
152163const Allocator = mem.Allocator;
153164const Archive = @This();
165const Compilation = @import("../../Compilation.zig");
154166const File = @import("file.zig").File;
155167const MachO = @import("../MachO.zig");
156168const Object = @import("Object.zig");