diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-02-06 12:46:41 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-02-07 19:27:25 +0100 |
| commit | 352e27c55ca32fdc31dd01e3e60893775f03a318 (patch) | |
| tree | 73eaa40922d8a76e3cb1ed3a3239d3d5cacd2b01 /src | |
| parent | ee36131e6a8bf8611f8a6fd55116e98eae2ed63c (diff) | |
| download | zig-352e27c55ca32fdc31dd01e3e60893775f03a318.tar.gz zig-352e27c55ca32fdc31dd01e3e60893775f03a318.zip | |
macho: move static lib flushing logic into Archive
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO.zig | 18 | ||||
| -rw-r--r-- | src/link/MachO/Archive.zig | 12 |
2 files changed, 13 insertions, 17 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index c5fe26bc57..d825671b10 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -379,10 +379,6 @@ pub fn deinit(self: *MachO) void { } pub fn flush(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { - // TODO: I think this is just a temp and can be removed once we can emit static archives - if (self.base.isStaticLib() and build_options.have_llvm) { - return self.base.linkAsArchive(arena, prog_node); - } try self.flushModule(arena, prog_node); } @@ -395,8 +391,6 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node if (self.llvm_object) |llvm_object| { try self.base.emitLlvmObject(arena, llvm_object, prog_node); - // TODO: I think this is just a temp and can be removed once we can emit static archives - if (self.base.isStaticLib() and build_options.have_llvm) return; } 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 if (comp.verbose_link) try self.dumpArgv(comp); if (self.getZigObject()) |zo| try zo.flushModule(self); - if (self.base.isStaticLib()) return self.flushStaticLib(comp, module_obj_path); + if (self.base.isStaticLib()) return Archive.flush(self, comp, module_obj_path); if (self.base.isObject()) return relocatable.flush(self, comp, module_obj_path); var positionals = std.ArrayList(Compilation.LinkObject).init(gpa); @@ -892,16 +886,6 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { Compilation.dump_argv(argv.items); } -fn flushStaticLib(self: *MachO, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void { - _ = comp; - _ = module_obj_path; - - var err = try self.addErrorWithNotes(0); - try err.addMsg(self, "TODO implement flushStaticLib", .{}); - - return error.FlushFailure; -} - pub fn resolveLibSystem( self: *MachO, arena: Allocator, diff --git a/src/link/MachO/Archive.zig b/src/link/MachO/Archive.zig index fd87b8e260..449fd709d9 100644 --- a/src/link/MachO/Archive.zig +++ b/src/link/MachO/Archive.zig @@ -143,7 +143,18 @@ pub fn parse(self: *Archive, macho_file: *MachO, path: []const u8, handle_index: } } +pub fn flush(macho_file: *MachO, comp: *Compilation, module_obj_path: ?[]const u8) link.File.FlushError!void { + _ = comp; + _ = module_obj_path; + + var err = try macho_file.addErrorWithNotes(0); + try err.addMsg(macho_file, "TODO implement flushStaticLib", .{}); + + return error.FlushFailure; +} + const fat = @import("fat.zig"); +const link = @import("../../link.zig"); const log = std.log.scoped(.link); const macho = std.macho; const mem = std.mem; @@ -151,6 +162,7 @@ const std = @import("std"); const Allocator = mem.Allocator; const Archive = @This(); +const Compilation = @import("../../Compilation.zig"); const File = @import("file.zig").File; const MachO = @import("../MachO.zig"); const Object = @import("Object.zig"); |
