| author | |
| committer | |
| log | 7f5c96378d0fa91265aef7a2d5c33c7953c23b5b |
| tree | 7982d871b169cf193afe507821a87fc71252b6fc |
| parent | 317c555a5cdc52612e998d8b4bcbaf730be1a6f1 |
4 files changed, 13 insertions(+), 59 deletions(-)
lib/std/build.zig+5-29| ... | ... | @@ -1207,7 +1207,6 @@ pub const LibExeObjStep = struct { |
| 1207 | 1207 | name_only_filename: []const u8, |
| 1208 | 1208 | strip: bool, |
| 1209 | 1209 | lib_paths: ArrayList([]const u8), |
| 1210 | syslibroot: ?[]const u8 = null, | |
| 1211 | 1210 | framework_dirs: ArrayList([]const u8), |
| 1212 | 1211 | frameworks: BufSet, |
| 1213 | 1212 | verbose_link: bool, |
| ... | ... | @@ -1842,10 +1841,6 @@ pub const LibExeObjStep = struct { |
| 1842 | 1841 | self.lib_paths.append(self.builder.dupe(path)) catch unreachable; |
| 1843 | 1842 | } |
| 1844 | 1843 | |
| 1845 | pub fn addSyslibroot(self: *LibExeObjStep, path: []const u8) void { | |
| 1846 | self.syslibroot = path; | |
| 1847 | } | |
| 1848 | ||
| 1849 | 1844 | pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void { |
| 1850 | 1845 | self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable; |
| 1851 | 1846 | } |
| ... | ... | @@ -1920,18 +1915,11 @@ pub const LibExeObjStep = struct { |
| 1920 | 1915 | } |
| 1921 | 1916 | } |
| 1922 | 1917 | |
| 1923 | if (self.target.isDarwin()) { | |
| 1924 | // Inherit syslibroot | |
| 1925 | if (other.syslibroot) |path| { | |
| 1926 | self.syslibroot = path; | |
| 1927 | } | |
| 1928 | ||
| 1929 | // Inherit dependencies on darwin frameworks | |
| 1930 | if (!other.isDynamicLibrary()) { | |
| 1931 | var it = other.frameworks.iterator(); | |
| 1932 | while (it.next()) |entry| { | |
| 1933 | self.frameworks.put(entry.key) catch unreachable; | |
| 1934 | } | |
| 1918 | // Inherit dependencies on darwin frameworks | |
| 1919 | if (self.target.isDarwin() and !other.isDynamicLibrary()) { | |
| 1920 | var it = other.frameworks.iterator(); | |
| 1921 | while (it.next()) |entry| { | |
| 1922 | self.frameworks.put(entry.key) catch unreachable; | |
| 1935 | 1923 | } |
| 1936 | 1924 | } |
| 1937 | 1925 | } |
| ... | ... | @@ -2283,18 +2271,6 @@ pub const LibExeObjStep = struct { |
| 2283 | 2271 | } |
| 2284 | 2272 | |
| 2285 | 2273 | if (self.target.isDarwin()) { |
| 2286 | if (self.syslibroot) |path| { | |
| 2287 | try zig_args.append("-syslibroot"); | |
| 2288 | try zig_args.append(path); | |
| 2289 | } else { | |
| 2290 | if (self.target.isNative()) { | |
| 2291 | const syslibroot = try std.zig.system.getSDKPath(builder.allocator); | |
| 2292 | errdefer builder.allocator.free(syslibroot); | |
| 2293 | try zig_args.append("-syslibroot"); | |
| 2294 | try zig_args.append(syslibroot); | |
| 2295 | } | |
| 2296 | } | |
| 2297 | ||
| 2298 | 2274 | for (self.framework_dirs.span()) |dir| { |
| 2299 | 2275 | try zig_args.append("-F"); |
| 2300 | 2276 | try zig_args.append(dir); |
lib/std/zig/system/macos.zig+1-1| ... | ... | @@ -461,7 +461,7 @@ test "version_from_build" { |
| 461 | 461 | /// The caller needs to free the resulting path slice. |
| 462 | 462 | pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 { |
| 463 | 463 | assert(std.Target.current.isDarwin()); |
| 464 | const argv = &[_][]const u8{ "/usr/bin/xcrun", "--show-sdk-path" }; | |
| 464 | const argv = &[_][]const u8{ "xcrun", "--show-sdk-path" }; | |
| 465 | 465 | const result = try std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv }); |
| 466 | 466 | defer { |
| 467 | 467 | allocator.free(result.stderr); |
src/Compilation.zig+6-2| ... | ... | @@ -333,7 +333,6 @@ pub const InitOptions = struct { |
| 333 | 333 | keep_source_files_loaded: bool = false, |
| 334 | 334 | clang_argv: []const []const u8 = &[0][]const u8{}, |
| 335 | 335 | lld_argv: []const []const u8 = &[0][]const u8{}, |
| 336 | syslibroot: ?[]const u8 = null, | |
| 337 | 336 | lib_dirs: []const []const u8 = &[0][]const u8{}, |
| 338 | 337 | rpath_list: []const []const u8 = &[0][]const u8{}, |
| 339 | 338 | c_source_files: []const CSourceFile = &[0]CSourceFile{}, |
| ... | ... | @@ -473,6 +472,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 473 | 472 | break :blk false; |
| 474 | 473 | }; |
| 475 | 474 | |
| 475 | const syslibroot = if (use_lld and options.is_native_os and options.target.isDarwin()) blk: { | |
| 476 | const syslibroot_path = try std.zig.system.getSDKPath(arena); | |
| 477 | break :blk syslibroot_path; | |
| 478 | } else null; | |
| 479 | ||
| 476 | 480 | const link_libc = options.link_libc or target_util.osRequiresLibC(options.target); |
| 477 | 481 | |
| 478 | 482 | const must_dynamic_link = dl: { |
| ... | ... | @@ -774,7 +778,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 774 | 778 | .frameworks = options.frameworks, |
| 775 | 779 | .framework_dirs = options.framework_dirs, |
| 776 | 780 | .system_libs = system_libs, |
| 777 | .syslibroot = options.syslibroot, | |
| 781 | .syslibroot = syslibroot, | |
| 778 | 782 | .lib_dirs = options.lib_dirs, |
| 779 | 783 | .rpath_list = options.rpath_list, |
| 780 | 784 | .strip = strip, |
src/main.zig+1-27| ... | ... | @@ -315,9 +315,8 @@ const usage_build_generic = |
| 315 | 315 | \\ --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n" |
| 316 | 316 | \\ --stack [size] Override default stack size |
| 317 | 317 | \\ --image-base [addr] Set base address for executable image |
| 318 | \\ -syslibroot [dir] (darwin) prepend a prefix to all search paths | |
| 319 | 318 | \\ -framework [name] (darwin) link against framework |
| 320 | \\ -F [dir] (darwin) add search path for frameworks | |
| 319 | \\ -F[dir] (darwin) add search path for frameworks | |
| 321 | 320 | \\ |
| 322 | 321 | \\Test Options: |
| 323 | 322 | \\ --test-filter [text] Skip tests that do not match filter |
| ... | ... | @@ -493,7 +492,6 @@ fn buildOutputType( |
| 493 | 492 | var main_pkg_path: ?[]const u8 = null; |
| 494 | 493 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; |
| 495 | 494 | var subsystem: ?std.Target.SubSystem = null; |
| 496 | var syslibroot: ?[]const u8 = null; | |
| 497 | 495 | |
| 498 | 496 | var system_libs = std.ArrayList([]const u8).init(gpa); |
| 499 | 497 | defer system_libs.deinit(); |
| ... | ... | @@ -684,10 +682,6 @@ fn buildOutputType( |
| 684 | 682 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); |
| 685 | 683 | i += 1; |
| 686 | 684 | try lib_dirs.append(args[i]); |
| 687 | } else if (mem.eql(u8, arg, "-syslibroot")) { | |
| 688 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); | |
| 689 | i += 1; | |
| 690 | syslibroot = args[i]; | |
| 691 | 685 | } else if (mem.eql(u8, arg, "-F")) { |
| 692 | 686 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); |
| 693 | 687 | i += 1; |
| ... | ... | @@ -1386,12 +1380,6 @@ fn buildOutputType( |
| 1386 | 1380 | } |
| 1387 | 1381 | } |
| 1388 | 1382 | |
| 1389 | if (cross_target.isNativeOs() and std.Target.current.isDarwin()) { | |
| 1390 | if (syslibroot == null) { | |
| 1391 | syslibroot = try std.zig.system.getSDKPath(arena); | |
| 1392 | } | |
| 1393 | } | |
| 1394 | ||
| 1395 | 1383 | const object_format: std.Target.ObjectFormat = blk: { |
| 1396 | 1384 | const ofmt = target_ofmt orelse break :blk target_info.target.getObjectFormat(); |
| 1397 | 1385 | if (mem.eql(u8, ofmt, "elf")) { |
| ... | ... | @@ -1640,7 +1628,6 @@ fn buildOutputType( |
| 1640 | 1628 | .rpath_list = rpath_list.items, |
| 1641 | 1629 | .c_source_files = c_source_files.items, |
| 1642 | 1630 | .link_objects = link_objects.items, |
| 1643 | .syslibroot = syslibroot, | |
| 1644 | 1631 | .framework_dirs = framework_dirs.items, |
| 1645 | 1632 | .frameworks = frameworks.items, |
| 1646 | 1633 | .system_libs = system_libs.items, |
| ... | ... | @@ -2172,7 +2159,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2172 | 2159 | var override_lib_dir: ?[]const u8 = null; |
| 2173 | 2160 | var override_global_cache_dir: ?[]const u8 = null; |
| 2174 | 2161 | var override_local_cache_dir: ?[]const u8 = null; |
| 2175 | var syslibroot: ?[]const u8 = null; | |
| 2176 | 2162 | var child_argv = std.ArrayList([]const u8).init(arena); |
| 2177 | 2163 | |
| 2178 | 2164 | const argv_index_exe = child_argv.items.len; |
| ... | ... | @@ -2214,11 +2200,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2214 | 2200 | override_global_cache_dir = args[i]; |
| 2215 | 2201 | try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); |
| 2216 | 2202 | continue; |
| 2217 | } else if (mem.eql(u8, arg, "--syslibroot")) { | |
| 2218 | if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg}); | |
| 2219 | i += 1; | |
| 2220 | syslibroot = args[i]; | |
| 2221 | continue; | |
| 2222 | 2203 | } |
| 2223 | 2204 | } |
| 2224 | 2205 | try child_argv.append(arg); |
| ... | ... | @@ -2324,12 +2305,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2324 | 2305 | const cross_target: std.zig.CrossTarget = .{}; |
| 2325 | 2306 | const target_info = try detectNativeTargetInfo(gpa, cross_target); |
| 2326 | 2307 | |
| 2327 | if (cross_target.isNativeOs() and target_info.target.isDarwin()) { | |
| 2328 | if (syslibroot == null) { | |
| 2329 | syslibroot = try std.zig.system.getSDKPath(arena); | |
| 2330 | } | |
| 2331 | } | |
| 2332 | ||
| 2333 | 2308 | const exe_basename = try std.zig.binNameAlloc(arena, .{ |
| 2334 | 2309 | .root_name = "build", |
| 2335 | 2310 | .target = target_info.target, |
| ... | ... | @@ -2353,7 +2328,6 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2353 | 2328 | .target = target_info.target, |
| 2354 | 2329 | .is_native_os = cross_target.isNativeOs(), |
| 2355 | 2330 | .dynamic_linker = target_info.dynamic_linker.get(), |
| 2356 | .syslibroot = syslibroot, | |
| 2357 | 2331 | .output_mode = .Exe, |
| 2358 | 2332 | .root_pkg = &root_pkg, |
| 2359 | 2333 | .emit_bin = emit_bin, |