diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-09-26 13:16:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-26 13:16:07 -0700 |
| commit | 5d907171e2941be9ad62e289ceeb17e7b4c0be2b (patch) | |
| tree | 45fffa3f7d66a02820c3b3aab2273258ea60a802 /src/Compilation.zig | |
| parent | 15ce9652525de2cc245203042d8c62ef30d5de1f (diff) | |
| parent | 0c8bf405ebeab9b1c72ca31b4f066189d74048d0 (diff) | |
| download | zig-5d907171e2941be9ad62e289ceeb17e7b4c0be2b.tar.gz zig-5d907171e2941be9ad62e289ceeb17e7b4c0be2b.zip | |
Merge pull request #17152 from mikdusan/macos-sdk
macos SDK updates and enhancements
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index c1cfe4613c..4bd3218a35 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1557,6 +1557,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .link_libc = link_libc, .link_libcpp = link_libcpp, .link_libunwind = link_libunwind, + .darwin_sdk_layout = libc_dirs.darwin_sdk_layout, .objects = options.link_objects, .frameworks = options.frameworks, .framework_dirs = options.framework_dirs, @@ -5294,6 +5295,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, + .darwin_sdk_layout = null, }, } } @@ -5662,38 +5664,23 @@ const LibCDirs = struct { libc_installation: ?*const LibCInstallation, libc_framework_dir_list: []const []const u8, sysroot: ?[]const u8, + darwin_sdk_layout: ?link.DarwinSdkLayout, }; -fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8, target: Target) !LibCDirs { - const arch_name = @tagName(target.cpu.arch); - const os_name = try std.fmt.allocPrint(arena, "{s}.{d}", .{ - @tagName(target.os.tag), - target.os.version_range.semver.min.major, - }); +fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs { const s = std.fs.path.sep_str; - const list = try arena.alloc([]const u8, 3); - + const list = try arena.alloc([]const u8, 1); list[0] = try std.fmt.allocPrint( arena, - "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-none", - .{ zig_lib_dir, arch_name, os_name }, - ); - list[1] = try std.fmt.allocPrint( - arena, - "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any", - .{ zig_lib_dir, os_name }, - ); - list[2] = try std.fmt.allocPrint( - arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-macos-any", .{zig_lib_dir}, ); - return LibCDirs{ .libc_include_dir_list = list, .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, + .darwin_sdk_layout = .vendored, }; } @@ -5711,6 +5698,7 @@ pub fn detectLibCIncludeDirs( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, + .darwin_sdk_layout = null, }; } @@ -5768,6 +5756,7 @@ pub fn detectLibCIncludeDirs( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, + .darwin_sdk_layout = null, }; } @@ -5822,6 +5811,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const .libc_installation = lci, .libc_framework_dir_list = framework_list.items, .sysroot = sysroot, + .darwin_sdk_layout = if (sysroot == null) null else .sdk, }; } @@ -5831,7 +5821,7 @@ fn detectLibCFromBuilding( target: std.Target, ) !LibCDirs { if (target.isDarwin()) - return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir, target); + return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir); const generic_name = target_util.libCGenericName(target); // Some architectures are handled by the same set of headers. @@ -5883,6 +5873,7 @@ fn detectLibCFromBuilding( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, + .darwin_sdk_layout = .vendored, }; } |
