| ... | @@ -794,15 +794,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -794,15 +794,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 794 | } | 794 | } |
| 795 | } | 795 | } |
| 796 | | 796 | |
| 797 | // If we're compiling native and we can find libSystem.B.{dylib, tbd}, | 797 | // If we were given the sysroot, try to look there first for libSystem.B.{dylib, tbd}. |
| 798 | // we link against that instead of embedded libSystem.B.tbd file. | 798 | var libsystem_available = false; |
| 799 | var native_libsystem_available = false; | 799 | if (self.base.options.sysroot != null) blk: { |
| 800 | if (self.base.options.is_native_os) blk: { | | |
| 801 | // Try stub file first. If we hit it, then we're done as the stub file | 800 | // Try stub file first. If we hit it, then we're done as the stub file |
| 802 | // re-exports every single symbol definition. | 801 | // re-exports every single symbol definition. |
| 803 | if (try resolveLib(arena, lib_dirs.items, "System", ".tbd")) |full_path| { | 802 | if (try resolveLib(arena, lib_dirs.items, "System", ".tbd")) |full_path| { |
| 804 | try libs.append(full_path); | 803 | try libs.append(full_path); |
| 805 | native_libsystem_available = true; | 804 | libsystem_available = true; |
| 806 | break :blk; | 805 | break :blk; |
| 807 | } | 806 | } |
| 808 | // If we didn't hit the stub file, try .dylib next. However, libSystem.dylib | 807 | // If we didn't hit the stub file, try .dylib next. However, libSystem.dylib |
| ... | @@ -811,12 +810,12 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -811,12 +810,12 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 811 | if (try resolveLib(arena, lib_dirs.items, "c", ".dylib")) |libc_path| { | 810 | if (try resolveLib(arena, lib_dirs.items, "c", ".dylib")) |libc_path| { |
| 812 | try libs.append(libsystem_path); | 811 | try libs.append(libsystem_path); |
| 813 | try libs.append(libc_path); | 812 | try libs.append(libc_path); |
| 814 | native_libsystem_available = true; | 813 | libsystem_available = true; |
| 815 | break :blk; | 814 | break :blk; |
| 816 | } | 815 | } |
| 817 | } | 816 | } |
| 818 | } | 817 | } |
| 819 | if (!native_libsystem_available) { | 818 | if (!libsystem_available) { |
| 820 | const full_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ | 819 | const full_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 821 | "libc", "darwin", "libSystem.B.tbd", | 820 | "libc", "darwin", "libSystem.B.tbd", |
| 822 | }); | 821 | }); |
| ... | @@ -841,7 +840,7 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -841,7 +840,7 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 841 | break; | 840 | break; |
| 842 | } | 841 | } |
| 843 | } else { | 842 | } else { |
| 844 | log.warn("framework not found for '-f{s}'", .{framework}); | 843 | log.warn("framework not found for '-framework {s}'", .{framework}); |
| 845 | framework_not_found = true; | 844 | framework_not_found = true; |
| 846 | } | 845 | } |
| 847 | } | 846 | } |
| ... | @@ -901,10 +900,8 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -901,10 +900,8 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 901 | try argv.append("-o"); | 900 | try argv.append("-o"); |
| 902 | try argv.append(full_out_path); | 901 | try argv.append(full_out_path); |
| 903 | | 902 | |
| 904 | if (native_libsystem_available) { | 903 | try argv.append("-lSystem"); |
| 905 | try argv.append("-lSystem"); | 904 | try argv.append("-lc"); |
| 906 | try argv.append("-lc"); | | |
| 907 | } | | |
| 908 | | 905 | |
| 909 | for (search_lib_names.items) |l_name| { | 906 | for (search_lib_names.items) |l_name| { |
| 910 | try argv.append(try std.fmt.allocPrint(arena, "-l{s}", .{l_name})); | 907 | try argv.append(try std.fmt.allocPrint(arena, "-l{s}", .{l_name})); |
| ... | @@ -914,6 +911,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { | ... | @@ -914,6 +911,14 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 914 | try argv.append(try std.fmt.allocPrint(arena, "-L{s}", .{lib_dir})); | 911 | try argv.append(try std.fmt.allocPrint(arena, "-L{s}", .{lib_dir})); |
| 915 | } | 912 | } |
| 916 | | 913 | |
| | 914 | for (self.base.options.frameworks) |framework| { |
| | 915 | try argv.append(try std.fmt.allocPrint(arena, "-framework {s}", .{framework})); |
| | 916 | } |
| | 917 | |
| | 918 | for (self.base.options.framework_dirs) |framework_dir| { |
| | 919 | try argv.append(try std.fmt.allocPrint(arena, "-F{s}", .{framework_dir})); |
| | 920 | } |
| | 921 | |
| 917 | Compilation.dump_argv(argv.items); | 922 | Compilation.dump_argv(argv.items); |
| 918 | } | 923 | } |
| 919 | | 924 | |