From f5dbcd1cb4374be619ba0b18e40a069a7e860d93 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 4 Feb 2024 17:56:26 +0100 Subject: [PATCH] macho: add -macosx to target strings as a fallback target Turns out that around 10.13/10.14 macOS release version, Apple changed the target tags in tbd files from `macosx` to `macos`. In order to be compliant and therefore actually support linking on older platforms against `libSystem.tbd`, we add `-macosx` to target strings. --- src/link/MachO/Dylib.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index 41b877579b..aa853cdbc6 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -677,6 +677,15 @@ pub const TargetMatcher = struct { const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS); try self.target_strings.append(allocator, host_target); }, + .MACOS => { + // Turns out that around 10.13/10.14 macOS release version, Apple changed the target tags in + // tbd files from `macosx` to `macos`. In order to be compliant and therefore actually support + // linking on older platforms against `libSystem.tbd`, we add `-macosx` to target_strings. + const fallback_target = try std.fmt.allocPrint(allocator, "{s}-macosx", .{ + cpuArchToAppleString(cpu_arch), + }); + try self.target_strings.append(allocator, fallback_target); + }, else => {}, }