diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-11-26 16:08:44 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-11-26 16:26:44 +0100 |
| commit | 8317dbd1cb32eaeafa509e7142766f3d9a82de5f (patch) | |
| tree | 780a0c6d17d3b10b22a3cce70543240a4900d13e /src/link | |
| parent | 02d8ca71f98800df08754ce3d2d2e39541178f64 (diff) | |
| download | zig-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/link')
| -rw-r--r-- | src/link/MachO.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 4d5133a959..b718afe1f7 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -4077,8 +4077,16 @@ pub fn populateMissingMetadata(self: *MachO) !void { @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version), @sizeOf(u64), )); - const ver = self.base.options.target.os.version_range.semver.min; - const version = ver.major << 16 | ver.minor << 8 | ver.patch; + const platform_version = blk: { + const ver = self.base.options.target.os.version_range.semver.min; + const platform_version = ver.major << 16 | ver.minor << 8; + break :blk platform_version; + }; + const sdk_version = if (self.base.options.native_darwin_sdk) |sdk| blk: { + const ver = sdk.version; + const sdk_version = ver.major << 16 | ver.minor << 8; + break :blk sdk_version; + } else platform_version; const is_simulator_abi = self.base.options.target.abi == .simulator; var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{ .cmd = macho.LC_BUILD_VERSION, @@ -4090,8 +4098,8 @@ pub fn populateMissingMetadata(self: *MachO) !void { .tvos => if (is_simulator_abi) macho.PLATFORM_TVOSSIMULATOR else macho.PLATFORM_TVOS, else => unreachable, }, - .minos = version, - .sdk = version, + .minos = platform_version, + .sdk = sdk_version, .ntools = 1, }); const ld_ver = macho.build_tool_version{ |
