authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-30 06:38:44+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-01 06:23:59+01:00
logaf48ce63795ca030a5eebd163af68746b8de2f0a
treef1a94a36ce26707ca0614f65d1266e991aae0b21
parentba5f57616f69c01aa6faa5bcabab2d58969cf335
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: Sort some OS switches according to the Os enum.


1 files changed, 118 insertions(+), 96 deletions(-)

lib/std/Target.zig+118-96
......@@ -160,48 +160,58 @@ pub const Os = struct {
160160 pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? {
161161 return switch (tag) {
162162 .freestanding,
163 .other,
164
165 .contiki,
166 .elfiamcu,
163167 .fuchsia,
164 .ps3,
165 .zos,
168 .hermit,
169
170 .aix,
166171 .haiku,
172 .hurd,
173 .plan9,
167174 .rtems,
168 .aix,
169 .cuda,
170 .nvcl,
171 .amdhsa,
175 .serenity,
176 .zos,
177
178 // This should use semver once we determine the version history.
179 .bridgeos,
180
181 .illumos,
182
183 .uefi,
184
185 .ps3,
172186 .ps4,
173187 .ps5,
174 .elfiamcu,
175 .mesa3d,
176 .contiki,
177 .amdpal,
178 .hermit,
179 .hurd,
188
180189 .emscripten,
181 .uefi,
190
191 .amdhsa,
192 .amdpal,
193 .cuda,
194 .mesa3d,
195 .nvcl,
182196 .opencl, // TODO: OpenCL versions
183197 .opengl, // TODO: GLSL versions
184198 .vulkan,
185 .plan9,
186 .illumos,
187 .serenity,
188 .other,
189199 => .none,
190200
191 // This should use semver once we determine the version history.
192 .bridgeos => .none,
201 .dragonfly,
202 .freebsd,
203 .netbsd,
204 .openbsd,
193205
194206 .driverkit,
195 .freebsd,
196207 .macos,
197208 .ios,
198209 .tvos,
199 .watchos,
200210 .visionos,
201 .netbsd,
202 .openbsd,
203 .dragonfly,
211 .watchos,
212
204213 .solaris,
214
205215 .wasi,
206216 => .semver,
207217
......@@ -391,41 +401,93 @@ pub const Os = struct {
391401 pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange {
392402 return switch (tag) {
393403 .freestanding,
404 .other,
405
406 .contiki,
407 .elfiamcu,
394408 .fuchsia,
395 .ps3,
396 .zos,
409 .hermit,
410
411 .aix,
397412 .haiku,
413 .hurd,
414 .plan9,
398415 .rtems,
399 .aix,
400 .cuda,
401 .nvcl,
402 .amdhsa,
416 .serenity,
417 .zos,
418
419 // This should use semver once we determine the version history.
420 .bridgeos,
421
422 .illumos,
423
424 .uefi,
425
426 .ps3,
403427 .ps4,
404428 .ps5,
405 .elfiamcu,
406 .mesa3d,
407 .contiki,
408 .amdpal,
409 .hermit,
410 .hurd,
429
411430 .emscripten,
412 .uefi,
431
432 .amdhsa,
433 .amdpal,
434 .cuda,
435 .mesa3d,
436 .nvcl,
413437 .opencl, // TODO: OpenCL versions
414438 .opengl, // TODO: GLSL versions
415439 .vulkan,
416 .plan9,
417 .illumos,
418 .serenity,
419 .bridgeos,
420 .other,
421440 => .{ .none = {} },
422441
442 .linux => .{
443 .linux = .{
444 .range = .{
445 .min = .{ .major = 4, .minor = 19, .patch = 0 },
446 .max = .{ .major = 6, .minor = 10, .patch = 3 },
447 },
448 .glibc = blk: {
449 const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 };
450
451 for (std.zig.target.available_libcs) |libc| {
452 // We don't know the ABI here. We can get away with not checking it
453 // for now, but that may not always remain true.
454 if (libc.os != tag or libc.arch != arch) continue;
455
456 if (libc.glibc_min) |min| {
457 if (min.order(default_min) == .gt) break :blk min;
458 }
459 }
460
461 break :blk default_min;
462 },
463 },
464 },
465
466 .dragonfly => .{
467 .semver = .{
468 .min = .{ .major = 5, .minor = 8, .patch = 0 },
469 .max = .{ .major = 6, .minor = 4, .patch = 0 },
470 },
471 },
423472 .freebsd => .{
424 .semver = std.SemanticVersion.Range{
473 .semver = .{
425474 .min = .{ .major = 12, .minor = 0, .patch = 0 },
426475 .max = .{ .major = 14, .minor = 0, .patch = 0 },
427476 },
428477 },
478 .netbsd => .{
479 .semver = .{
480 .min = .{ .major = 8, .minor = 0, .patch = 0 },
481 .max = .{ .major = 10, .minor = 0, .patch = 0 },
482 },
483 },
484 .openbsd => .{
485 .semver = .{
486 .min = .{ .major = 7, .minor = 3, .patch = 0 },
487 .max = .{ .major = 7, .minor = 5, .patch = 0 },
488 },
489 },
490
429491 .driverkit => .{
430492 .semver = .{
431493 .min = .{ .major = 19, .minor = 0, .patch = 0 },
......@@ -433,13 +495,13 @@ pub const Os = struct {
433495 },
434496 },
435497 .macos => switch (arch) {
436 .aarch64 => VersionRange{
498 .aarch64 => .{
437499 .semver = .{
438500 .min = .{ .major = 11, .minor = 7, .patch = 1 },
439501 .max = .{ .major = 14, .minor = 6, .patch = 1 },
440502 },
441503 },
442 .x86_64 => VersionRange{
504 .x86_64 => .{
443505 .semver = .{
444506 .min = .{ .major = 11, .minor = 7, .patch = 1 },
445507 .max = .{ .major = 14, .minor = 6, .patch = 1 },
......@@ -453,12 +515,6 @@ pub const Os = struct {
453515 .max = .{ .major = 17, .minor = 6, .patch = 1 },
454516 },
455517 },
456 .watchos => .{
457 .semver = .{
458 .min = .{ .major = 6, .minor = 0, .patch = 0 },
459 .max = .{ .major = 10, .minor = 6, .patch = 0 },
460 },
461 },
462518 .tvos => .{
463519 .semver = .{
464520 .min = .{ .major = 13, .minor = 0, .patch = 0 },
......@@ -471,60 +527,19 @@ pub const Os = struct {
471527 .max = .{ .major = 1, .minor = 3, .patch = 0 },
472528 },
473529 },
474 .netbsd => .{
475 .semver = .{
476 .min = .{ .major = 8, .minor = 0, .patch = 0 },
477 .max = .{ .major = 10, .minor = 0, .patch = 0 },
478 },
479 },
480 .openbsd => .{
481 .semver = .{
482 .min = .{ .major = 7, .minor = 3, .patch = 0 },
483 .max = .{ .major = 7, .minor = 5, .patch = 0 },
484 },
485 },
486 .dragonfly => .{
530 .watchos => .{
487531 .semver = .{
488 .min = .{ .major = 5, .minor = 8, .patch = 0 },
489 .max = .{ .major = 6, .minor = 4, .patch = 0 },
532 .min = .{ .major = 6, .minor = 0, .patch = 0 },
533 .max = .{ .major = 10, .minor = 6, .patch = 0 },
490534 },
491535 },
536
492537 .solaris => .{
493538 .semver = .{
494539 .min = .{ .major = 11, .minor = 0, .patch = 0 },
495540 .max = .{ .major = 11, .minor = 4, .patch = 0 },
496541 },
497542 },
498 .wasi => .{
499 .semver = .{
500 .min = .{ .major = 0, .minor = 1, .patch = 0 },
501 .max = .{ .major = 0, .minor = 1, .patch = 0 },
502 },
503 },
504
505 .linux => .{
506 .linux = .{
507 .range = .{
508 .min = .{ .major = 4, .minor = 19, .patch = 0 },
509 .max = .{ .major = 6, .minor = 10, .patch = 3 },
510 },
511 .glibc = blk: {
512 const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 };
513
514 for (std.zig.target.available_libcs) |libc| {
515 // We don't know the ABI here. We can get away with not checking it
516 // for now, but that may not always remain true.
517 if (libc.os != tag or libc.arch != arch) continue;
518
519 if (libc.glibc_min) |min| {
520 if (min.order(default_min) == .gt) break :blk min;
521 }
522 }
523
524 break :blk default_min;
525 },
526 },
527 },
528543
529544 .windows => .{
530545 .windows = .{
......@@ -532,6 +547,13 @@ pub const Os = struct {
532547 .max = WindowsVersion.latest,
533548 },
534549 },
550
551 .wasi => .{
552 .semver = .{
553 .min = .{ .major = 0, .minor = 1, .patch = 0 },
554 .max = .{ .major = 0, .minor = 1, .patch = 0 },
555 },
556 },
535557 };
536558 }
537559 };