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 {...@@ -160,48 +160,58 @@ pub const Os = struct {
160 pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? {160 pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? {
161 return switch (tag) {161 return switch (tag) {
162 .freestanding,162 .freestanding,
163 .other,
164
165 .contiki,
166 .elfiamcu,
163 .fuchsia,167 .fuchsia,
164 .ps3,168 .hermit,
165 .zos,169
170 .aix,
166 .haiku,171 .haiku,
172 .hurd,
173 .plan9,
167 .rtems,174 .rtems,
168 .aix,175 .serenity,
169 .cuda,176 .zos,
170 .nvcl,177
171 .amdhsa,178 // This should use semver once we determine the version history.
179 .bridgeos,
180
181 .illumos,
182
183 .uefi,
184
185 .ps3,
172 .ps4,186 .ps4,
173 .ps5,187 .ps5,
174 .elfiamcu,188
175 .mesa3d,
176 .contiki,
177 .amdpal,
178 .hermit,
179 .hurd,
180 .emscripten,189 .emscripten,
181 .uefi,190
191 .amdhsa,
192 .amdpal,
193 .cuda,
194 .mesa3d,
195 .nvcl,
182 .opencl, // TODO: OpenCL versions196 .opencl, // TODO: OpenCL versions
183 .opengl, // TODO: GLSL versions197 .opengl, // TODO: GLSL versions
184 .vulkan,198 .vulkan,
185 .plan9,
186 .illumos,
187 .serenity,
188 .other,
189 => .none,199 => .none,
190200
191 // This should use semver once we determine the version history.201 .dragonfly,
192 .bridgeos => .none,202 .freebsd,
203 .netbsd,
204 .openbsd,
193205
194 .driverkit,206 .driverkit,
195 .freebsd,
196 .macos,207 .macos,
197 .ios,208 .ios,
198 .tvos,209 .tvos,
199 .watchos,
200 .visionos,210 .visionos,
201 .netbsd,211 .watchos,
202 .openbsd,212
203 .dragonfly,
204 .solaris,213 .solaris,
214
205 .wasi,215 .wasi,
206 => .semver,216 => .semver,
207217
...@@ -391,41 +401,93 @@ pub const Os = struct {...@@ -391,41 +401,93 @@ pub const Os = struct {
391 pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange {401 pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange {
392 return switch (tag) {402 return switch (tag) {
393 .freestanding,403 .freestanding,
404 .other,
405
406 .contiki,
407 .elfiamcu,
394 .fuchsia,408 .fuchsia,
395 .ps3,409 .hermit,
396 .zos,410
411 .aix,
397 .haiku,412 .haiku,
413 .hurd,
414 .plan9,
398 .rtems,415 .rtems,
399 .aix,416 .serenity,
400 .cuda,417 .zos,
401 .nvcl,418
402 .amdhsa,419 // This should use semver once we determine the version history.
420 .bridgeos,
421
422 .illumos,
423
424 .uefi,
425
426 .ps3,
403 .ps4,427 .ps4,
404 .ps5,428 .ps5,
405 .elfiamcu,429
406 .mesa3d,
407 .contiki,
408 .amdpal,
409 .hermit,
410 .hurd,
411 .emscripten,430 .emscripten,
412 .uefi,431
432 .amdhsa,
433 .amdpal,
434 .cuda,
435 .mesa3d,
436 .nvcl,
413 .opencl, // TODO: OpenCL versions437 .opencl, // TODO: OpenCL versions
414 .opengl, // TODO: GLSL versions438 .opengl, // TODO: GLSL versions
415 .vulkan,439 .vulkan,
416 .plan9,
417 .illumos,
418 .serenity,
419 .bridgeos,
420 .other,
421 => .{ .none = {} },440 => .{ .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 },
423 .freebsd => .{472 .freebsd => .{
424 .semver = std.SemanticVersion.Range{473 .semver = .{
425 .min = .{ .major = 12, .minor = 0, .patch = 0 },474 .min = .{ .major = 12, .minor = 0, .patch = 0 },
426 .max = .{ .major = 14, .minor = 0, .patch = 0 },475 .max = .{ .major = 14, .minor = 0, .patch = 0 },
427 },476 },
428 },477 },
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
429 .driverkit => .{491 .driverkit => .{
430 .semver = .{492 .semver = .{
431 .min = .{ .major = 19, .minor = 0, .patch = 0 },493 .min = .{ .major = 19, .minor = 0, .patch = 0 },
...@@ -433,13 +495,13 @@ pub const Os = struct {...@@ -433,13 +495,13 @@ pub const Os = struct {
433 },495 },
434 },496 },
435 .macos => switch (arch) {497 .macos => switch (arch) {
436 .aarch64 => VersionRange{498 .aarch64 => .{
437 .semver = .{499 .semver = .{
438 .min = .{ .major = 11, .minor = 7, .patch = 1 },500 .min = .{ .major = 11, .minor = 7, .patch = 1 },
439 .max = .{ .major = 14, .minor = 6, .patch = 1 },501 .max = .{ .major = 14, .minor = 6, .patch = 1 },
440 },502 },
441 },503 },
442 .x86_64 => VersionRange{504 .x86_64 => .{
443 .semver = .{505 .semver = .{
444 .min = .{ .major = 11, .minor = 7, .patch = 1 },506 .min = .{ .major = 11, .minor = 7, .patch = 1 },
445 .max = .{ .major = 14, .minor = 6, .patch = 1 },507 .max = .{ .major = 14, .minor = 6, .patch = 1 },
...@@ -453,12 +515,6 @@ pub const Os = struct {...@@ -453,12 +515,6 @@ pub const Os = struct {
453 .max = .{ .major = 17, .minor = 6, .patch = 1 },515 .max = .{ .major = 17, .minor = 6, .patch = 1 },
454 },516 },
455 },517 },
456 .watchos => .{
457 .semver = .{
458 .min = .{ .major = 6, .minor = 0, .patch = 0 },
459 .max = .{ .major = 10, .minor = 6, .patch = 0 },
460 },
461 },
462 .tvos => .{518 .tvos => .{
463 .semver = .{519 .semver = .{
464 .min = .{ .major = 13, .minor = 0, .patch = 0 },520 .min = .{ .major = 13, .minor = 0, .patch = 0 },
...@@ -471,60 +527,19 @@ pub const Os = struct {...@@ -471,60 +527,19 @@ pub const Os = struct {
471 .max = .{ .major = 1, .minor = 3, .patch = 0 },527 .max = .{ .major = 1, .minor = 3, .patch = 0 },
472 },528 },
473 },529 },
474 .netbsd => .{530 .watchos => .{
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 => .{
487 .semver = .{531 .semver = .{
488 .min = .{ .major = 5, .minor = 8, .patch = 0 },532 .min = .{ .major = 6, .minor = 0, .patch = 0 },
489 .max = .{ .major = 6, .minor = 4, .patch = 0 },533 .max = .{ .major = 10, .minor = 6, .patch = 0 },
490 },534 },
491 },535 },
536
492 .solaris => .{537 .solaris => .{
493 .semver = .{538 .semver = .{
494 .min = .{ .major = 11, .minor = 0, .patch = 0 },539 .min = .{ .major = 11, .minor = 0, .patch = 0 },
495 .max = .{ .major = 11, .minor = 4, .patch = 0 },540 .max = .{ .major = 11, .minor = 4, .patch = 0 },
496 },541 },
497 },542 },
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
529 .windows => .{544 .windows => .{
530 .windows = .{545 .windows = .{
...@@ -532,6 +547,13 @@ pub const Os = struct {...@@ -532,6 +547,13 @@ pub const Os = struct {
532 .max = WindowsVersion.latest,547 .max = WindowsVersion.latest,
533 },548 },
534 },549 },
550
551 .wasi => .{
552 .semver = .{
553 .min = .{ .major = 0, .minor = 1, .patch = 0 },
554 .max = .{ .major = 0, .minor = 1, .patch = 0 },
555 },
556 },
535 };557 };
536 }558 }
537 };559 };