diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 49111b761b23e2552dc5bdb090c7c7c7c67e3e01..8023418f02e21b36a21e35d70b308b7fdc4b13b5 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -160,48 +160,58 @@ pub const Os = struct { pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { return switch (tag) { .freestanding, + .other, + + .contiki, + .elfiamcu, .fuchsia, - .ps3, - .zos, + .hermit, + + .aix, .haiku, + .hurd, + .plan9, .rtems, - .aix, - .cuda, - .nvcl, - .amdhsa, + .serenity, + .zos, + + // This should use semver once we determine the version history. + .bridgeos, + + .illumos, + + .uefi, + + .ps3, .ps4, .ps5, - .elfiamcu, - .mesa3d, - .contiki, - .amdpal, - .hermit, - .hurd, + .emscripten, - .uefi, + + .amdhsa, + .amdpal, + .cuda, + .mesa3d, + .nvcl, .opencl, // TODO: OpenCL versions .opengl, // TODO: GLSL versions .vulkan, - .plan9, - .illumos, - .serenity, - .other, => .none, - // This should use semver once we determine the version history. - .bridgeos => .none, - - .driverkit, + .dragonfly, .freebsd, - .macos, - .ios, - .tvos, - .watchos, - .visionos, .netbsd, .openbsd, - .dragonfly, + + .driverkit, + .macos, + .ios, + .tvos, + .visionos, + .watchos, + .solaris, + .wasi, => .semver, @@ -391,41 +401,93 @@ pub const Os = struct { pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange { return switch (tag) { .freestanding, + .other, + + .contiki, + .elfiamcu, .fuchsia, - .ps3, - .zos, + .hermit, + + .aix, .haiku, + .hurd, + .plan9, .rtems, - .aix, - .cuda, - .nvcl, - .amdhsa, + .serenity, + .zos, + + // This should use semver once we determine the version history. + .bridgeos, + + .illumos, + + .uefi, + + .ps3, .ps4, .ps5, - .elfiamcu, - .mesa3d, - .contiki, - .amdpal, - .hermit, - .hurd, + .emscripten, - .uefi, + + .amdhsa, + .amdpal, + .cuda, + .mesa3d, + .nvcl, .opencl, // TODO: OpenCL versions .opengl, // TODO: GLSL versions .vulkan, - .plan9, - .illumos, - .serenity, - .bridgeos, - .other, => .{ .none = {} }, + .linux => .{ + .linux = .{ + .range = .{ + .min = .{ .major = 4, .minor = 19, .patch = 0 }, + .max = .{ .major = 6, .minor = 10, .patch = 3 }, + }, + .glibc = blk: { + const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 }; + + for (std.zig.target.available_libcs) |libc| { + // We don't know the ABI here. We can get away with not checking it + // for now, but that may not always remain true. + if (libc.os != tag or libc.arch != arch) continue; + + if (libc.glibc_min) |min| { + if (min.order(default_min) == .gt) break :blk min; + } + } + + break :blk default_min; + }, + }, + }, + + .dragonfly => .{ + .semver = .{ + .min = .{ .major = 5, .minor = 8, .patch = 0 }, + .max = .{ .major = 6, .minor = 4, .patch = 0 }, + }, + }, .freebsd => .{ - .semver = std.SemanticVersion.Range{ + .semver = .{ .min = .{ .major = 12, .minor = 0, .patch = 0 }, .max = .{ .major = 14, .minor = 0, .patch = 0 }, }, }, + .netbsd => .{ + .semver = .{ + .min = .{ .major = 8, .minor = 0, .patch = 0 }, + .max = .{ .major = 10, .minor = 0, .patch = 0 }, + }, + }, + .openbsd => .{ + .semver = .{ + .min = .{ .major = 7, .minor = 3, .patch = 0 }, + .max = .{ .major = 7, .minor = 5, .patch = 0 }, + }, + }, + .driverkit => .{ .semver = .{ .min = .{ .major = 19, .minor = 0, .patch = 0 }, @@ -433,13 +495,13 @@ pub const Os = struct { }, }, .macos => switch (arch) { - .aarch64 => VersionRange{ + .aarch64 => .{ .semver = .{ .min = .{ .major = 11, .minor = 7, .patch = 1 }, .max = .{ .major = 14, .minor = 6, .patch = 1 }, }, }, - .x86_64 => VersionRange{ + .x86_64 => .{ .semver = .{ .min = .{ .major = 11, .minor = 7, .patch = 1 }, .max = .{ .major = 14, .minor = 6, .patch = 1 }, @@ -453,12 +515,6 @@ pub const Os = struct { .max = .{ .major = 17, .minor = 6, .patch = 1 }, }, }, - .watchos => .{ - .semver = .{ - .min = .{ .major = 6, .minor = 0, .patch = 0 }, - .max = .{ .major = 10, .minor = 6, .patch = 0 }, - }, - }, .tvos => .{ .semver = .{ .min = .{ .major = 13, .minor = 0, .patch = 0 }, @@ -471,60 +527,19 @@ pub const Os = struct { .max = .{ .major = 1, .minor = 3, .patch = 0 }, }, }, - .netbsd => .{ + .watchos => .{ .semver = .{ - .min = .{ .major = 8, .minor = 0, .patch = 0 }, - .max = .{ .major = 10, .minor = 0, .patch = 0 }, - }, - }, - .openbsd => .{ - .semver = .{ - .min = .{ .major = 7, .minor = 3, .patch = 0 }, - .max = .{ .major = 7, .minor = 5, .patch = 0 }, - }, - }, - .dragonfly => .{ - .semver = .{ - .min = .{ .major = 5, .minor = 8, .patch = 0 }, - .max = .{ .major = 6, .minor = 4, .patch = 0 }, + .min = .{ .major = 6, .minor = 0, .patch = 0 }, + .max = .{ .major = 10, .minor = 6, .patch = 0 }, }, }, + .solaris => .{ .semver = .{ .min = .{ .major = 11, .minor = 0, .patch = 0 }, .max = .{ .major = 11, .minor = 4, .patch = 0 }, }, }, - .wasi => .{ - .semver = .{ - .min = .{ .major = 0, .minor = 1, .patch = 0 }, - .max = .{ .major = 0, .minor = 1, .patch = 0 }, - }, - }, - - .linux => .{ - .linux = .{ - .range = .{ - .min = .{ .major = 4, .minor = 19, .patch = 0 }, - .max = .{ .major = 6, .minor = 10, .patch = 3 }, - }, - .glibc = blk: { - const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 }; - - for (std.zig.target.available_libcs) |libc| { - // We don't know the ABI here. We can get away with not checking it - // for now, but that may not always remain true. - if (libc.os != tag or libc.arch != arch) continue; - - if (libc.glibc_min) |min| { - if (min.order(default_min) == .gt) break :blk min; - } - } - - break :blk default_min; - }, - }, - }, .windows => .{ .windows = .{ @@ -532,6 +547,13 @@ pub const Os = struct { .max = WindowsVersion.latest, }, }, + + .wasi => .{ + .semver = .{ + .min = .{ .major = 0, .minor = 1, .patch = 0 }, + .max = .{ .major = 0, .minor = 1, .patch = 0 }, + }, + }, }; } };