diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-11-24 23:41:09 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-11-25 12:19:16 +0100 |
| commit | 1954cdc1066f2d59961e4cdd24a9d80fd6eb86c3 (patch) | |
| tree | a445b605f63b4951328ce6da925ce32a07296d05 /src | |
| parent | c42439dff9bdfa1ff90e4243ec7eaad94f4241ca (diff) | |
| download | zig-1954cdc1066f2d59961e4cdd24a9d80fd6eb86c3.tar.gz zig-1954cdc1066f2d59961e4cdd24a9d80fd6eb86c3.zip | |
Autofetch macOS SDK if native target on macOS only
This means that I am purposefully regressing linking iOS and related
which will require manual specification of the sysroot path, etc.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 8 | ||||
| -rw-r--r-- | src/main.zig | 12 |
2 files changed, 6 insertions, 14 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 7520e7cb4b..20d67e7c77 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -962,15 +962,17 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { break :blk false; }; - const darwin_can_use_system_sdk = blk: { + const darwin_use_system_sdk = blk: { if (comptime !builtin.target.isDarwin()) break :blk false; - break :blk builtin.os.tag == .macos and options.target.isDarwin(); + if (!options.is_native_os) break :blk false; + if (builtin.os.tag != .macos or !options.target.isDarwin()) break :blk false; + break :blk options.frameworks.len > 0 or options.framework_dirs.len > 0; }; const sysroot = blk: { if (options.sysroot) |sysroot| { break :blk sysroot; - } else if (darwin_can_use_system_sdk) { + } else if (darwin_use_system_sdk) { break :blk try std.zig.system.darwin.getSDKPath(arena, options.target); } else { break :blk null; diff --git a/src/main.zig b/src/main.zig index 87086bf874..20ea5caded 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1848,11 +1848,7 @@ fn buildOutputType( want_native_include_dirs = true; } - const is_darwin_on_darwin = (comptime builtin.target.isDarwin()) and cross_target.isDarwin(); - - if (sysroot == null and (cross_target.isNativeOs() or is_darwin_on_darwin) and - (system_libs.count() != 0 or want_native_include_dirs)) - { + if (sysroot == null and cross_target.isNativeOs() and (system_libs.count() != 0 or want_native_include_dirs)) { const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| { fatal("unable to detect native system paths: {s}", .{@errorName(err)}); }; @@ -1861,12 +1857,6 @@ fn buildOutputType( } const has_sysroot = if (comptime builtin.target.isDarwin()) outer: { - const should_get_sdk_path = if (cross_target.isNativeOs() and target_info.target.os.tag == .macos) inner: { - const min = target_info.target.os.getVersionRange().semver.min; - const at_least_mojave = min.major >= 11 or (min.major >= 10 and min.minor >= 14); - break :inner at_least_mojave; - } else true; - if (!should_get_sdk_path) break :outer false; if (try std.zig.system.darwin.getSDKPath(arena, target_info.target)) |sdk_path| { try clang_argv.ensureUnusedCapacity(2); clang_argv.appendAssumeCapacity("-isysroot"); |
