From e2a71b37d867e5567e06c8e57b04e648ade4aca3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 16 Oct 2024 13:41:24 -0700 Subject: fix MachO linking regression --- src/link.zig | 6 ++++++ src/link/MachO.zig | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/link.zig b/src/link.zig index a50ad5f8ea..9363876cb2 100644 --- a/src/link.zig +++ b/src/link.zig @@ -2003,6 +2003,12 @@ pub fn openArchiveInput(diags: *Diags, path: Path) error{LinkFailure}!Input { } }; } +pub fn openDsoInput(diags: *Diags, path: Path, needed: bool, weak: bool, reexport: bool) error{LinkFailure}!Input { + return .{ .dso = openDso(path, needed, weak, reexport) catch |err| { + return diags.failParse(path, "failed to open {}: {s}", .{ path, @errorName(err) }); + } }; +} + fn stripLibPrefixAndSuffix(path: []const u8, target: std.Target) ?struct { []const u8, std.builtin.LinkMode } { const prefix = target.libPrefix(); const static_suffix = target.staticLibSuffix(); diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 4af02ee7a8..7182e0640f 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -446,6 +446,12 @@ pub fn flushModule(self: *MachO, arena: Allocator, tid: Zcu.PerThread.Id, prog_n }, }; + for (system_libs.items) |lib| { + const dso_input = try link.openDsoInput(diags, lib.path, lib.needed, lib.weak, lib.reexport); + self.classifyInputFile(dso_input) catch |err| + diags.addParseError(lib.path, "failed to parse input file: {s}", .{@errorName(err)}); + } + // Finally, link against compiler_rt. if (comp.compiler_rt_lib) |crt_file| { const path = crt_file.full_object_path; @@ -765,7 +771,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { Compilation.dump_argv(argv.items); } -/// TODO delete this, libsystem must be resolved when setting up the compilationt pipeline +/// TODO delete this, libsystem must be resolved when setting up the compilation pipeline pub fn resolveLibSystem( self: *MachO, arena: Allocator, -- cgit v1.2.3