authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-11-24 20:34:13+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-11-25 12:19:16+01:00
logc42439dff9bdfa1ff90e4243ec7eaad94f4241ca
treed7d4bf42c509fbc1d4e4a53b47646ae6a15e74c0
parent42a351e099dd41fe96dab4f6dadd277884188f3f

Pass inferred cpu_arch to defaultVersionRange

This is mainly because arm64 macOS doesn't support all versions supported by x86_64 macOS. This is just a temporary thing until both architectures support the same set of OSes.

4 files changed, 20 insertions(+), 10 deletions(-)

lib/std/target.zig+17-7
...@@ -81,10 +81,10 @@ pub const Target = struct {...@@ -81,10 +81,10 @@ pub const Target = struct {
81 }81 }
82 }82 }
8383
84 pub fn defaultVersionRange(tag: Tag) Os {84 pub fn defaultVersionRange(tag: Tag, arch: Cpu.Arch) Os {
85 return .{85 return .{
86 .tag = tag,86 .tag = tag,
87 .version_range = VersionRange.default(tag),87 .version_range = VersionRange.default(tag, arch),
88 };88 };
89 }89 }
90 };90 };
...@@ -226,7 +226,7 @@ pub const Target = struct {...@@ -226,7 +226,7 @@ pub const Target = struct {
226226
227 /// The default `VersionRange` represents the range that the Zig Standard Library227 /// The default `VersionRange` represents the range that the Zig Standard Library
228 /// bases its abstractions on.228 /// bases its abstractions on.
229 pub fn default(tag: Tag) VersionRange {229 pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange {
230 switch (tag) {230 switch (tag) {
231 .freestanding,231 .freestanding,
232 .ananas,232 .ananas,
...@@ -266,12 +266,22 @@ pub const Target = struct {...@@ -266,12 +266,22 @@ pub const Target = struct {
266 .max = .{ .major = 13, .minor = 0 },266 .max = .{ .major = 13, .minor = 0 },
267 },267 },
268 },268 },
269 .macos => return .{269 .macos => return switch (arch) {
270 .semver = .{270 .aarch64 => VersionRange{
271 .min = .{ .major = 10, .minor = 13 },271 .semver = .{
272 .max = .{ .major = 12, .minor = 0 },272 .min = .{ .major = 11, .minor = 6 },
273 .max = .{ .major = 12, .minor = 0 },
274 },
273 },275 },
276 .x86_64 => VersionRange{
277 .semver = .{
278 .min = .{ .major = 10, .minor = 13 },
279 .max = .{ .major = 12, .minor = 0 },
280 },
281 },
282 else => unreachable,
274 },283 },
284
275 .ios => return .{285 .ios => return .{
276 .semver = .{286 .semver = .{
277 .min = .{ .major = 12, .minor = 0 },287 .min = .{ .major = 12, .minor = 0 },
lib/std/zig/cross_target.zig+1-1
...@@ -375,7 +375,7 @@ pub const CrossTarget = struct {...@@ -375,7 +375,7 @@ pub const CrossTarget = struct {
375 // `builtin.os` works when doing `zig build` because Zig generates a build executable using375 // `builtin.os` works when doing `zig build` because Zig generates a build executable using
376 // native OS version range. However this will not be accurate otherwise, and376 // native OS version range. However this will not be accurate otherwise, and
377 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.377 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.
378 var adjusted_os = if (self.os_tag) |os_tag| os_tag.defaultVersionRange() else builtin.os;378 var adjusted_os = if (self.os_tag) |os_tag| os_tag.defaultVersionRange(self.getCpuArch()) else builtin.os;
379379
380 if (self.os_version_min) |min| switch (min) {380 if (self.os_version_min) |min| switch (min) {
381 .none => {},381 .none => {},
lib/std/zig/system.zig+1-1
...@@ -238,7 +238,7 @@ pub const NativeTargetInfo = struct {...@@ -238,7 +238,7 @@ pub const NativeTargetInfo = struct {
238 /// deinitialization method.238 /// deinitialization method.
239 /// TODO Remove the Allocator requirement from this function.239 /// TODO Remove the Allocator requirement from this function.
240 pub fn detect(allocator: *Allocator, cross_target: CrossTarget) DetectError!NativeTargetInfo {240 pub fn detect(allocator: *Allocator, cross_target: CrossTarget) DetectError!NativeTargetInfo {
241 var os = cross_target.getOsTag().defaultVersionRange();241 var os = cross_target.getOsTag().defaultVersionRange(cross_target.getCpuArch());
242 if (cross_target.os_tag == null) {242 if (cross_target.os_tag == null) {
243 switch (builtin.target.os.tag) {243 switch (builtin.target.os.tag) {
244 .linux => {244 .linux => {
src/stage1/codegen.cpp+1-1
...@@ -9305,7 +9305,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {...@@ -9305,7 +9305,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
9305 buf_appendf(contents, "pub const abi = std.Target.Abi.%s;\n", cur_abi);9305 buf_appendf(contents, "pub const abi = std.Target.Abi.%s;\n", cur_abi);
9306 buf_appendf(contents, "pub const cpu = std.Target.Cpu.baseline(.%s);\n", cur_arch);9306 buf_appendf(contents, "pub const cpu = std.Target.Cpu.baseline(.%s);\n", cur_arch);
9307 buf_appendf(contents, "pub const stage2_arch: std.Target.Cpu.Arch = .%s;\n", cur_arch);9307 buf_appendf(contents, "pub const stage2_arch: std.Target.Cpu.Arch = .%s;\n", cur_arch);
9308 buf_appendf(contents, "pub const os = std.Target.Os.Tag.defaultVersionRange(.%s);\n", cur_os);9308 buf_appendf(contents, "pub const os = std.Target.Os.Tag.defaultVersionRange(.%s, .%s);\n", cur_os, cur_arch);
9309 buf_appendf(contents,9309 buf_appendf(contents,
9310 "pub const target = std.Target{\n"9310 "pub const target = std.Target{\n"
9311 " .cpu = cpu,\n"9311 " .cpu = cpu,\n"