| ... | @@ -829,55 +829,50 @@ pub fn resolveLibSystem( | ... | @@ -829,55 +829,50 @@ pub fn resolveLibSystem( |
| 829 | out_libs: anytype, | 829 | out_libs: anytype, |
| 830 | ) !void { | 830 | ) !void { |
| 831 | // If we were given the sysroot, try to look there first for libSystem.B.{dylib, tbd}. | 831 | // If we were given the sysroot, try to look there first for libSystem.B.{dylib, tbd}. |
| 832 | var libsystem_available = false; | 832 | if (syslibroot) |root| { |
| 833 | if (syslibroot != null) blk: { | 833 | const full_dir_path = try std.fs.path.join(arena, &.{ root, "usr", "lib" }); |
| 834 | // Try stub file first. If we hit it, then we're done as the stub file | 834 | if (try resolveLibSystemInDirs(arena, &.{full_dir_path}, out_libs)) return; |
| 835 | // re-exports every single symbol definition. | 835 | } |
| 836 | for (search_dirs) |dir| { | 836 | |
| 837 | if (try resolveLib(arena, dir, "System", ".tbd")) |full_path| { | 837 | // Next, try input search dirs if we are linking on a custom host such as Nix. |
| 838 | try out_libs.put(full_path, .{ | 838 | if (try resolveLibSystemInDirs(arena, search_dirs, out_libs)) return; |
| 839 | .needed = true, | 839 | |
| 840 | .weak = false, | 840 | // As a fallback, try linking against Zig shipped stub. |
| 841 | .path = full_path, | 841 | const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}.tbd", .{ |
| 842 | }); | 842 | target.os.version_range.semver.min.major, |
| 843 | libsystem_available = true; | 843 | }); |
| 844 | break :blk; | 844 | const full_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 845 | } | 845 | "libc", "darwin", libsystem_name, |
| | 846 | }); |
| | 847 | try out_libs.put(full_path, .{ |
| | 848 | .needed = true, |
| | 849 | .weak = false, |
| | 850 | .path = full_path, |
| | 851 | }); |
| | 852 | } |
| | 853 | |
| | 854 | fn resolveLibSystemInDirs(arena: Allocator, dirs: []const []const u8, out_libs: anytype) !bool { |
| | 855 | // Try stub file first. If we hit it, then we're done as the stub file |
| | 856 | // re-exports every single symbol definition. |
| | 857 | for (dirs) |dir| { |
| | 858 | if (try resolveLib(arena, dir, "System", ".tbd")) |full_path| { |
| | 859 | try out_libs.put(full_path, .{ .needed = true, .weak = false, .path = full_path }); |
| | 860 | return true; |
| 846 | } | 861 | } |
| 847 | // If we didn't hit the stub file, try .dylib next. However, libSystem.dylib | 862 | } |
| 848 | // doesn't export libc.dylib which we'll need to resolve subsequently also. | 863 | // If we didn't hit the stub file, try .dylib next. However, libSystem.dylib |
| 849 | for (search_dirs) |dir| { | 864 | // doesn't export libc.dylib which we'll need to resolve subsequently also. |
| 850 | if (try resolveLib(arena, dir, "System", ".dylib")) |libsystem_path| { | 865 | for (dirs) |dir| { |
| 851 | if (try resolveLib(arena, dir, "c", ".dylib")) |libc_path| { | 866 | if (try resolveLib(arena, dir, "System", ".dylib")) |libsystem_path| { |
| 852 | try out_libs.put(libsystem_path, .{ | 867 | if (try resolveLib(arena, dir, "c", ".dylib")) |libc_path| { |
| 853 | .needed = true, | 868 | try out_libs.put(libsystem_path, .{ .needed = true, .weak = false, .path = libsystem_path }); |
| 854 | .weak = false, | 869 | try out_libs.put(libc_path, .{ .needed = true, .weak = false, .path = libc_path }); |
| 855 | .path = libsystem_path, | 870 | return true; |
| 856 | }); | | |
| 857 | try out_libs.put(libc_path, .{ | | |
| 858 | .needed = true, | | |
| 859 | .weak = false, | | |
| 860 | .path = libc_path, | | |
| 861 | }); | | |
| 862 | libsystem_available = true; | | |
| 863 | break :blk; | | |
| 864 | } | | |
| 865 | } | 871 | } |
| 866 | } | 872 | } |
| 867 | } | 873 | } |
| 868 | if (!libsystem_available) { | 874 | |
| 869 | const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}.tbd", .{ | 875 | return false; |
| 870 | target.os.version_range.semver.min.major, | | |
| 871 | }); | | |
| 872 | const full_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ | | |
| 873 | "libc", "darwin", libsystem_name, | | |
| 874 | }); | | |
| 875 | try out_libs.put(full_path, .{ | | |
| 876 | .needed = true, | | |
| 877 | .weak = false, | | |
| 878 | .path = full_path, | | |
| 879 | }); | | |
| 880 | } | | |
| 881 | } | 876 | } |
| 882 | | 877 | |
| 883 | pub fn resolveSearchDir( | 878 | pub fn resolveSearchDir( |