aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-11-26 16:08:44 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-11-26 16:26:44 +0100
commit8317dbd1cb32eaeafa509e7142766f3d9a82de5f (patch)
tree780a0c6d17d3b10b22a3cce70543240a4900d13e /src/Compilation.zig
parent02d8ca71f98800df08754ce3d2d2e39541178f64 (diff)
downloadzig-8317dbd1cb32eaeafa509e7142766f3d9a82de5f.tar.gz
zig-8317dbd1cb32eaeafa509e7142766f3d9a82de5f.zip
macos: detect SDK path and version, then pass to the linker
Since we are already detecting the path to the native SDK, if available, also fetch SDK's version and route that to the linker. The linker can then use it to correctly populate LC_BUILD_VERSION load command.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 0d299d6572..ac25519190 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -773,8 +773,8 @@ pub const InitOptions = struct {
wasi_exec_model: ?std.builtin.WasiExecModel = null,
/// (Zig compiler development) Enable dumping linker's state as JSON.
enable_link_snapshots: bool = false,
- /// (Darwin). Path to native macOS SDK if detected.
- native_macos_sdk_path: ?[]const u8 = null,
+ /// (Darwin) Path and version of the native SDK if detected.
+ native_darwin_sdk: ?std.zig.system.darwin.DarwinSDK = null,
};
fn addPackageTableToCacheHash(
@@ -967,8 +967,8 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
const sysroot = blk: {
if (options.sysroot) |sysroot| {
break :blk sysroot;
- } else if (options.native_macos_sdk_path) |sdk_path| {
- break :blk sdk_path;
+ } else if (options.native_darwin_sdk) |sdk| {
+ break :blk sdk.path;
} else {
break :blk null;
}
@@ -1055,7 +1055,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
link_libc,
options.system_lib_names.len != 0 or options.frameworks.len != 0,
options.libc_installation,
- options.native_macos_sdk_path != null,
+ options.native_darwin_sdk != null,
);
const must_pie = target_util.requiresPIE(options.target);
@@ -1492,6 +1492,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
.wasi_exec_model = wasi_exec_model,
.use_stage1 = use_stage1,
.enable_link_snapshots = options.enable_link_snapshots,
+ .native_darwin_sdk = options.native_darwin_sdk,
});
errdefer bin_file.destroy();
comp.* = .{
@@ -3829,7 +3830,7 @@ fn detectLibCIncludeDirs(
if (link_system_libs and is_native_abi and !target.isMinGW()) {
if (target.isDarwin()) {
return if (has_macos_sdk)
- // For Darwin/macOS, we are all set with getSDKPath found earlier.
+ // For Darwin/macOS, we are all set with getDarwinSDK found earlier.
LibCDirs{
.libc_include_dir_list = &[0][]u8{},
.libc_installation = null,
@@ -3846,7 +3847,14 @@ fn detectLibCIncludeDirs(
// default if possible.
if (target_util.canBuildLibC(target)) {
switch (target.os.tag) {
- .macos => return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir, target),
+ .macos => return if (has_macos_sdk)
+ // For Darwin/macOS, we are all set with getDarwinSDK found earlier.
+ LibCDirs{
+ .libc_include_dir_list = &[0][]u8{},
+ .libc_installation = null,
+ }
+ else
+ getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir, target),
else => {
const generic_name = target_util.libCGenericName(target);
// Some architectures are handled by the same set of headers.