authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-04 17:56:26+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-05 00:09:26+01:00
logf5dbcd1cb4374be619ba0b18e40a069a7e860d93
treefff614baa3c0860cd5d0cbd3fed417ef9ed602e2
parenta1b607acb5c1e9dd03760efd7078185e7628b29d

macho: add <cpu_arch>-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 `<cpu_arch>-macosx` to target strings.

1 files changed, 9 insertions(+), 0 deletions(-)

src/link/MachO/Dylib.zig+9
......@@ -677,6 +677,15 @@ pub const TargetMatcher = struct {
677677 const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS);
678678 try self.target_strings.append(allocator, host_target);
679679 },
680 .MACOS => {
681 // Turns out that around 10.13/10.14 macOS release version, Apple changed the target tags in
682 // tbd files from `macosx` to `macos`. In order to be compliant and therefore actually support
683 // linking on older platforms against `libSystem.tbd`, we add `<cpu_arch>-macosx` to target_strings.
684 const fallback_target = try std.fmt.allocPrint(allocator, "{s}-macosx", .{
685 cpuArchToAppleString(cpu_arch),
686 });
687 try self.target_strings.append(allocator, fallback_target);
688 },
680689 else => {},
681690 }
682691