Commit e2a71b37d8

Andrew Kelley <andrew@ziglang.org>
2024-10-16 22:41:24
fix MachO linking regression
1 parent 8cfe303
Changed files (2)
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,
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();