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