authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-02-21 18:39:22+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-17 13:17:34-07:00
log6e84f469904a24615a6721265a88ad8dcb4ed83a
treed390e7738b996686749adbbd9a1c18f647058b3b
parent96acc204b2c6080f0169ca3721c3b95a433c185b

std: replace builtin.Version with SemanticVersion


34 files changed, 189 insertions(+), 280 deletions(-)

build.zig+2-2
...@@ -9,7 +9,7 @@ const fs = std.fs;...@@ -9,7 +9,7 @@ const fs = std.fs;
9const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;9const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
10const assert = std.debug.assert;10const assert = std.debug.assert;
1111
12const zig_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };12const zig_version = std.SemanticVersion{ .major = 0, .minor = 11, .patch = 0 };
13const stack_size = 32 * 1024 * 1024;13const stack_size = 32 * 1024 * 1024;
1414
15pub fn build(b: *std.Build) !void {15pub fn build(b: *std.Build) !void {
...@@ -242,7 +242,7 @@ pub fn build(b: *std.Build) !void {...@@ -242,7 +242,7 @@ pub fn build(b: *std.Build) !void {
242 const commit_height = it.next().?;242 const commit_height = it.next().?;
243 const commit_id = it.next().?;243 const commit_id = it.next().?;
244244
245 const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor);245 const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor);
246 if (zig_version.order(ancestor_ver) != .gt) {246 if (zig_version.order(ancestor_ver) != .gt) {
247 std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });247 std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });
248 std.process.exit(1);248 std.process.exit(1);
lib/std/Build.zig+4-4
...@@ -472,7 +472,7 @@ pub fn addOptions(self: *Build) *Step.Options {...@@ -472,7 +472,7 @@ pub fn addOptions(self: *Build) *Step.Options {
472pub const ExecutableOptions = struct {472pub const ExecutableOptions = struct {
473 name: []const u8,473 name: []const u8,
474 root_source_file: ?FileSource = null,474 root_source_file: ?FileSource = null,
475 version: ?std.builtin.Version = null,475 version: ?std.SemanticVersion = null,
476 target: CrossTarget = .{},476 target: CrossTarget = .{},
477 optimize: std.builtin.Mode = .Debug,477 optimize: std.builtin.Mode = .Debug,
478 linkage: ?Step.Compile.Linkage = null,478 linkage: ?Step.Compile.Linkage = null,
...@@ -530,7 +530,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile {...@@ -530,7 +530,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile {
530pub const SharedLibraryOptions = struct {530pub const SharedLibraryOptions = struct {
531 name: []const u8,531 name: []const u8,
532 root_source_file: ?FileSource = null,532 root_source_file: ?FileSource = null,
533 version: ?std.builtin.Version = null,533 version: ?std.SemanticVersion = null,
534 target: CrossTarget,534 target: CrossTarget,
535 optimize: std.builtin.Mode,535 optimize: std.builtin.Mode,
536 max_rss: usize = 0,536 max_rss: usize = 0,
...@@ -562,7 +562,7 @@ pub const StaticLibraryOptions = struct {...@@ -562,7 +562,7 @@ pub const StaticLibraryOptions = struct {
562 root_source_file: ?FileSource = null,562 root_source_file: ?FileSource = null,
563 target: CrossTarget,563 target: CrossTarget,
564 optimize: std.builtin.Mode,564 optimize: std.builtin.Mode,
565 version: ?std.builtin.Version = null,565 version: ?std.SemanticVersion = null,
566 max_rss: usize = 0,566 max_rss: usize = 0,
567 link_libc: ?bool = null,567 link_libc: ?bool = null,
568 single_threaded: ?bool = null,568 single_threaded: ?bool = null,
...@@ -592,7 +592,7 @@ pub const TestOptions = struct {...@@ -592,7 +592,7 @@ pub const TestOptions = struct {
592 root_source_file: FileSource,592 root_source_file: FileSource,
593 target: CrossTarget = .{},593 target: CrossTarget = .{},
594 optimize: std.builtin.Mode = .Debug,594 optimize: std.builtin.Mode = .Debug,
595 version: ?std.builtin.Version = null,595 version: ?std.SemanticVersion = null,
596 max_rss: usize = 0,596 max_rss: usize = 0,
597 filter: ?[]const u8 = null,597 filter: ?[]const u8 = null,
598 test_runner: ?[]const u8 = null,598 test_runner: ?[]const u8 = null,
lib/std/Build/Cache.zig+1-1
...@@ -212,7 +212,7 @@ pub const HashHelper = struct {...@@ -212,7 +212,7 @@ pub const HashHelper = struct {
212 /// Convert the input value into bytes and record it as a dependency of the process being cached.212 /// Convert the input value into bytes and record it as a dependency of the process being cached.
213 pub fn add(hh: *HashHelper, x: anytype) void {213 pub fn add(hh: *HashHelper, x: anytype) void {
214 switch (@TypeOf(x)) {214 switch (@TypeOf(x)) {
215 std.builtin.Version => {215 std.SemanticVersion => {
216 hh.add(x.major);216 hh.add(x.major);
217 hh.add(x.minor);217 hh.add(x.minor);
218 hh.add(x.patch);218 hh.add(x.patch);
lib/std/Build/Step/Compile.zig+2-2
...@@ -32,7 +32,7 @@ linker_script: ?FileSource = null,...@@ -32,7 +32,7 @@ linker_script: ?FileSource = null,
32version_script: ?[]const u8 = null,32version_script: ?[]const u8 = null,
33out_filename: []const u8,33out_filename: []const u8,
34linkage: ?Linkage = null,34linkage: ?Linkage = null,
35version: ?std.builtin.Version,35version: ?std.SemanticVersion,
36kind: Kind,36kind: Kind,
37major_only_filename: ?[]const u8,37major_only_filename: ?[]const u8,
38name_only_filename: ?[]const u8,38name_only_filename: ?[]const u8,
...@@ -278,7 +278,7 @@ pub const Options = struct {...@@ -278,7 +278,7 @@ pub const Options = struct {
278 optimize: std.builtin.Mode,278 optimize: std.builtin.Mode,
279 kind: Kind,279 kind: Kind,
280 linkage: ?Linkage = null,280 linkage: ?Linkage = null,
281 version: ?std.builtin.Version = null,281 version: ?std.SemanticVersion = null,
282 max_rss: usize = 0,282 max_rss: usize = 0,
283 filter: ?[]const u8 = null,283 filter: ?[]const u8 = null,
284 test_runner: ?[]const u8 = null,284 test_runner: ?[]const u8 = null,
lib/std/Build/Step/Options.zig-23
...@@ -76,23 +76,6 @@ fn addOptionFallible(self: *Options, comptime T: type, name: []const u8, value:...@@ -76,23 +76,6 @@ fn addOptionFallible(self: *Options, comptime T: type, name: []const u8, value:
76 }76 }
77 return;77 return;
78 },78 },
79 std.builtin.Version => {
80 try out.print(
81 \\pub const {}: @import("std").builtin.Version = .{{
82 \\ .major = {d},
83 \\ .minor = {d},
84 \\ .patch = {d},
85 \\}};
86 \\
87 , .{
88 std.zig.fmtId(name),
89
90 value.major,
91 value.minor,
92 value.patch,
93 });
94 return;
95 },
96 std.SemanticVersion => {79 std.SemanticVersion => {
97 try out.print(80 try out.print(
98 \\pub const {}: @import("std").SemanticVersion = .{{81 \\pub const {}: @import("std").SemanticVersion = .{{
...@@ -367,7 +350,6 @@ test Options {...@@ -367,7 +350,6 @@ test Options {
367 options.addOption([2][2]u16, "nested_array", nested_array);350 options.addOption([2][2]u16, "nested_array", nested_array);
368 options.addOption([]const []const u16, "nested_slice", nested_slice);351 options.addOption([]const []const u16, "nested_slice", nested_slice);
369 //options.addOption(KeywordEnum, "keyword_enum", .@"0.8.1");352 //options.addOption(KeywordEnum, "keyword_enum", .@"0.8.1");
370 options.addOption(std.builtin.Version, "version", try std.builtin.Version.parse("0.1.2"));
371 options.addOption(std.SemanticVersion, "semantic_version", try std.SemanticVersion.parse("0.1.2-foo+bar"));353 options.addOption(std.SemanticVersion, "semantic_version", try std.SemanticVersion.parse("0.1.2-foo+bar"));
372354
373 try std.testing.expectEqualStrings(355 try std.testing.expectEqualStrings(
...@@ -401,11 +383,6 @@ test Options {...@@ -401,11 +383,6 @@ test Options {
401 //\\ @"0.8.1",383 //\\ @"0.8.1",
402 //\\};384 //\\};
403 //\\pub const keyword_enum: KeywordEnum = KeywordEnum.@"0.8.1";385 //\\pub const keyword_enum: KeywordEnum = KeywordEnum.@"0.8.1";
404 \\pub const version: @import("std").builtin.Version = .{
405 \\ .major = 0,
406 \\ .minor = 1,
407 \\ .patch = 2,
408 \\};
409 \\pub const semantic_version: @import("std").SemanticVersion = .{386 \\pub const semantic_version: @import("std").SemanticVersion = .{
410 \\ .major = 0,387 \\ .major = 0,
411 \\ .minor = 1,388 \\ .minor = 1,
lib/std/Build/Step/TranslateC.zig+1-1
...@@ -47,7 +47,7 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC {...@@ -47,7 +47,7 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC {
4747
48pub const AddExecutableOptions = struct {48pub const AddExecutableOptions = struct {
49 name: ?[]const u8 = null,49 name: ?[]const u8 = null,
50 version: ?std.builtin.Version = null,50 version: ?std.SemanticVersion = null,
51 target: ?CrossTarget = null,51 target: ?CrossTarget = null,
52 optimize: ?std.builtin.Mode = null,52 optimize: ?std.builtin.Mode = null,
53 linkage: ?Step.Compile.Linkage = null,53 linkage: ?Step.Compile.Linkage = null,
lib/std/SemanticVersion.zig+22-2
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1//! A software version formatted according to the Semantic Version 2 specification.1//! A software version formatted according to the Semantic Versioning 2.0.0 specification.
2//!2//!
3//! See: https://semver.org3//! See: https://semver.org
44
...@@ -167,7 +167,7 @@ const expect = std.testing.expect;...@@ -167,7 +167,7 @@ const expect = std.testing.expect;
167const expectError = std.testing.expectError;167const expectError = std.testing.expectError;
168168
169test "SemanticVersion format" {169test "SemanticVersion format" {
170 // Test vectors are from https://github.com/semver/semver.org/issues/59#issuecomment-390854010.170 // Many of these test strings are from https://github.com/semver/semver.org/issues/59#issuecomment-390854010.
171171
172 // Valid version strings should be accepted.172 // Valid version strings should be accepted.
173 for ([_][]const u8{173 for ([_][]const u8{
...@@ -200,6 +200,8 @@ test "SemanticVersion format" {...@@ -200,6 +200,8 @@ test "SemanticVersion format" {
200 "1.2.3----R-S.12.9.1--.12+meta",200 "1.2.3----R-S.12.9.1--.12+meta",
201 "1.2.3----RC-SNAPSHOT.12.9.1--.12",201 "1.2.3----RC-SNAPSHOT.12.9.1--.12",
202 "1.0.0+0.build.1-rc.10000aaa-kk-0.1",202 "1.0.0+0.build.1-rc.10000aaa-kk-0.1",
203 "5.4.0-1018-raspi",
204 "5.7.123",
203 }) |valid| try std.testing.expectFmt(valid, "{}", .{try parse(valid)});205 }) |valid| try std.testing.expectFmt(valid, "{}", .{try parse(valid)});
204206
205 // Invalid version strings should be rejected.207 // Invalid version strings should be rejected.
...@@ -244,6 +246,24 @@ test "SemanticVersion format" {...@@ -244,6 +246,24 @@ test "SemanticVersion format" {
244 "+justmeta",246 "+justmeta",
245 "9.8.7+meta+meta",247 "9.8.7+meta+meta",
246 "9.8.7-whatever+meta+meta",248 "9.8.7-whatever+meta+meta",
249 "2.6.32.11-svn21605",
250 "2.11.2(0.329/5/3)",
251 "2.13-DEVELOPMENT",
252 "2.3-35",
253 "1a.4",
254 "3.b1.0",
255 "1.4beta",
256 "2.7.pre",
257 "0..3",
258 "8.008.",
259 "01...",
260 "55",
261 "foobar",
262 "",
263 "-1",
264 "+4",
265 ".",
266 "....3",
247 }) |invalid| try expectError(error.InvalidVersion, parse(invalid));267 }) |invalid| try expectError(error.InvalidVersion, parse(invalid));
248268
249 // Valid version string that may overflow.269 // Valid version string that may overflow.
lib/std/builtin.zig-133
...@@ -483,139 +483,6 @@ pub const WasiExecModel = enum {...@@ -483,139 +483,6 @@ pub const WasiExecModel = enum {
483 reactor,483 reactor,
484};484};
485485
486/// This data structure is used by the Zig language code generation and
487/// therefore must be kept in sync with the compiler implementation.
488pub const Version = struct {
489 major: u32,
490 minor: u32,
491 patch: u32 = 0,
492
493 pub const Range = struct {
494 min: Version,
495 max: Version,
496
497 pub fn includesVersion(self: Range, ver: Version) bool {
498 if (self.min.order(ver) == .gt) return false;
499 if (self.max.order(ver) == .lt) return false;
500 return true;
501 }
502
503 /// Checks if system is guaranteed to be at least `version` or older than `version`.
504 /// Returns `null` if a runtime check is required.
505 pub fn isAtLeast(self: Range, ver: Version) ?bool {
506 if (self.min.order(ver) != .lt) return true;
507 if (self.max.order(ver) == .lt) return false;
508 return null;
509 }
510 };
511
512 pub fn order(lhs: Version, rhs: Version) std.math.Order {
513 if (lhs.major < rhs.major) return .lt;
514 if (lhs.major > rhs.major) return .gt;
515 if (lhs.minor < rhs.minor) return .lt;
516 if (lhs.minor > rhs.minor) return .gt;
517 if (lhs.patch < rhs.patch) return .lt;
518 if (lhs.patch > rhs.patch) return .gt;
519 return .eq;
520 }
521
522 pub fn parse(text: []const u8) !Version {
523 var end: usize = 0;
524 while (end < text.len) : (end += 1) {
525 const c = text[end];
526 if (!std.ascii.isDigit(c) and c != '.') break;
527 }
528 // found no digits or '.' before unexpected character
529 if (end == 0) return error.InvalidVersion;
530
531 var it = std.mem.splitScalar(u8, text[0..end], '.');
532 // substring is not empty, first call will succeed
533 const major = it.first();
534 if (major.len == 0) return error.InvalidVersion;
535 const minor = it.next() orelse "0";
536 // ignore 'patch' if 'minor' is invalid
537 const patch = if (minor.len == 0) "0" else (it.next() orelse "0");
538
539 return Version{
540 .major = try std.fmt.parseUnsigned(u32, major, 10),
541 .minor = try std.fmt.parseUnsigned(u32, if (minor.len == 0) "0" else minor, 10),
542 .patch = try std.fmt.parseUnsigned(u32, if (patch.len == 0) "0" else patch, 10),
543 };
544 }
545
546 pub fn format(
547 self: Version,
548 comptime fmt: []const u8,
549 options: std.fmt.FormatOptions,
550 out_stream: anytype,
551 ) !void {
552 _ = options;
553 if (fmt.len == 0) {
554 if (self.patch == 0) {
555 if (self.minor == 0) {
556 return std.fmt.format(out_stream, "{d}", .{self.major});
557 } else {
558 return std.fmt.format(out_stream, "{d}.{d}", .{ self.major, self.minor });
559 }
560 } else {
561 return std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
562 }
563 } else {
564 std.fmt.invalidFmtError(fmt, self);
565 }
566 }
567};
568
569test "Version.parse" {
570 @setEvalBranchQuota(3000);
571 try testVersionParse();
572 comptime (try testVersionParse());
573}
574
575fn testVersionParse() !void {
576 const f = struct {
577 fn eql(text: []const u8, v1: u32, v2: u32, v3: u32) !void {
578 const v = try Version.parse(text);
579 try std.testing.expect(v.major == v1 and v.minor == v2 and v.patch == v3);
580 }
581
582 fn err(text: []const u8, expected_err: anyerror) !void {
583 _ = Version.parse(text) catch |actual_err| {
584 if (actual_err == expected_err) return;
585 return actual_err;
586 };
587 return error.Unreachable;
588 }
589 };
590
591 try f.eql("2.6.32.11-svn21605", 2, 6, 32); // Debian PPC
592 try f.eql("2.11.2(0.329/5/3)", 2, 11, 2); // MinGW
593 try f.eql("5.4.0-1018-raspi", 5, 4, 0); // Ubuntu
594 try f.eql("5.7.12_3", 5, 7, 12); // Void
595 try f.eql("2.13-DEVELOPMENT", 2, 13, 0); // DragonFly
596 try f.eql("2.3-35", 2, 3, 0);
597 try f.eql("1a.4", 1, 0, 0);
598 try f.eql("3.b1.0", 3, 0, 0);
599 try f.eql("1.4beta", 1, 4, 0);
600 try f.eql("2.7.pre", 2, 7, 0);
601 try f.eql("0..3", 0, 0, 0);
602 try f.eql("8.008.", 8, 8, 0);
603 try f.eql("01...", 1, 0, 0);
604 try f.eql("55", 55, 0, 0);
605 try f.eql("4294967295.0.1", 4294967295, 0, 1);
606 try f.eql("429496729_6", 429496729, 0, 0);
607
608 try f.err("foobar", error.InvalidVersion);
609 try f.err("", error.InvalidVersion);
610 try f.err("-1", error.InvalidVersion);
611 try f.err("+4", error.InvalidVersion);
612 try f.err(".", error.InvalidVersion);
613 try f.err("....3", error.InvalidVersion);
614 try f.err("4294967296", error.Overflow);
615 try f.err("5000877755", error.Overflow);
616 // error.InvalidCharacter is not possible anymore
617}
618
619/// This data structure is used by the Zig language code generation and486/// This data structure is used by the Zig language code generation and
620/// therefore must be kept in sync with the compiler implementation.487/// therefore must be kept in sync with the compiler implementation.
621pub const CallModifier = enum {488pub const CallModifier = enum {
lib/std/c.zig+1-1
...@@ -20,7 +20,7 @@ pub const Tokenizer = tokenizer.Tokenizer;...@@ -20,7 +20,7 @@ pub const Tokenizer = tokenizer.Tokenizer;
20/// If linking gnu libc (glibc), the `ok` value will be true if the target20/// If linking gnu libc (glibc), the `ok` value will be true if the target
21/// version is greater than or equal to `glibc_version`.21/// version is greater than or equal to `glibc_version`.
22/// If linking a libc other than these, returns `false`.22/// If linking a libc other than these, returns `false`.
23pub fn versionCheck(comptime glibc_version: std.builtin.Version) type {23pub fn versionCheck(comptime glibc_version: std.SemanticVersion) type {
24 return struct {24 return struct {
25 pub const ok = blk: {25 pub const ok = blk: {
26 if (!builtin.link_libc) break :blk false;26 if (!builtin.link_libc) break :blk false;
lib/std/crypto/tlcsprng.zig+1
...@@ -38,6 +38,7 @@ const want_fork_safety = os_has_fork and !os_has_arc4random and...@@ -38,6 +38,7 @@ const want_fork_safety = os_has_fork and !os_has_arc4random and
38const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{38const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
39 .major = 4,39 .major = 4,
40 .minor = 14,40 .minor = 14,
41 .patch = 0,
41}) orelse true;42}) orelse true;
42const is_haiku = builtin.os.tag == .haiku;43const is_haiku = builtin.os.tag == .haiku;
4344
lib/std/os.zig+9-9
...@@ -488,7 +488,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {...@@ -488,7 +488,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
488 if (builtin.os.tag == .linux or builtin.os.tag == .freebsd) {488 if (builtin.os.tag == .linux or builtin.os.tag == .freebsd) {
489 var buf = buffer;489 var buf = buffer;
490 const use_c = builtin.os.tag != .linux or490 const use_c = builtin.os.tag != .linux or
491 std.c.versionCheck(std.builtin.Version{ .major = 2, .minor = 25, .patch = 0 }).ok;491 std.c.versionCheck(std.SemanticVersion{ .major = 2, .minor = 25, .patch = 0 }).ok;
492492
493 while (buf.len != 0) {493 while (buf.len != 0) {
494 const res = if (use_c) blk: {494 const res = if (use_c) blk: {
...@@ -5272,7 +5272,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -5272,7 +5272,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
5272 return target;5272 return target;
5273 },5273 },
5274 .freebsd => {5274 .freebsd => {
5275 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .gt) {5275 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0, .patch = 0 }) == .gt) {
5276 var kfile: system.kinfo_file = undefined;5276 var kfile: system.kinfo_file = undefined;
5277 kfile.structsize = system.KINFO_FILE_SIZE;5277 kfile.structsize = system.KINFO_FILE_SIZE;
5278 switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) {5278 switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) {
...@@ -5325,7 +5325,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -5325,7 +5325,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
5325 }5325 }
5326 },5326 },
5327 .dragonfly => {5327 .dragonfly => {
5328 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 6, .minor = 0 }) == .lt) {5328 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 6, .minor = 0, .patch = 0 }) == .lt) {
5329 @compileError("querying for canonical path of a handle is unsupported on this host");5329 @compileError("querying for canonical path of a handle is unsupported on this host");
5330 }5330 }
5331 @memset(out_buffer[0..MAX_PATH_BYTES], 0);5331 @memset(out_buffer[0..MAX_PATH_BYTES], 0);
...@@ -5339,7 +5339,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -5339,7 +5339,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
5339 return out_buffer[0..len];5339 return out_buffer[0..len];
5340 },5340 },
5341 .netbsd => {5341 .netbsd => {
5342 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 10, .minor = 0 }) == .lt) {5342 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 10, .minor = 0, .patch = 0 }) == .lt) {
5343 @compileError("querying for canonical path of a handle is unsupported on this host");5343 @compileError("querying for canonical path of a handle is unsupported on this host");
5344 }5344 }
5345 @memset(out_buffer[0..MAX_PATH_BYTES], 0);5345 @memset(out_buffer[0..MAX_PATH_BYTES], 0);
...@@ -6152,9 +6152,9 @@ pub fn sendfile(...@@ -6152,9 +6152,9 @@ pub fn sendfile(
6152 .linux => sf: {6152 .linux => sf: {
6153 // sendfile() first appeared in Linux 2.2, glibc 2.1.6153 // sendfile() first appeared in Linux 2.2, glibc 2.1.
6154 const call_sf = comptime if (builtin.link_libc)6154 const call_sf = comptime if (builtin.link_libc)
6155 std.c.versionCheck(.{ .major = 2, .minor = 1 }).ok6155 std.c.versionCheck(.{ .major = 2, .minor = 1, .patch = 0 }).ok
6156 else6156 else
6157 builtin.os.version_range.linux.range.max.order(.{ .major = 2, .minor = 2 }) != .lt;6157 builtin.os.version_range.linux.range.max.order(.{ .major = 2, .minor = 2, .patch = 0 }) != .lt;
6158 if (!call_sf) break :sf;6158 if (!call_sf) break :sf;
61596159
6160 if (headers.len != 0) {6160 if (headers.len != 0) {
...@@ -6453,8 +6453,8 @@ var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true);...@@ -6453,8 +6453,8 @@ var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true);
6453///6453///
6454/// Maximum offsets on Linux and FreeBSD are `math.maxInt(i64)`.6454/// Maximum offsets on Linux and FreeBSD are `math.maxInt(i64)`.
6455pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize {6455pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize {
6456 if ((comptime builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0 }) orelse false) or6456 if ((comptime builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) or
6457 ((comptime builtin.os.isAtLeast(.linux, .{ .major = 4, .minor = 5 }) orelse false and6457 ((comptime builtin.os.isAtLeast(.linux, .{ .major = 4, .minor = 5, .patch = 0 }) orelse false and
6458 std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok) and6458 std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok) and
6459 has_copy_file_range_syscall.load(.Monotonic)))6459 has_copy_file_range_syscall.load(.Monotonic)))
6460 {6460 {
...@@ -6787,7 +6787,7 @@ pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {...@@ -6787,7 +6787,7 @@ pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {
6787 }6787 }
6788 },6788 },
6789 .freebsd => {6789 .freebsd => {
6790 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .lt)6790 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0, .patch = 0 }) == .lt)
6791 @compileError("memfd_create is unavailable on FreeBSD < 13.0");6791 @compileError("memfd_create is unavailable on FreeBSD < 13.0");
6792 const rc = system.memfd_create(name, flags);6792 const rc = system.memfd_create(name, flags);
6793 switch (errno(rc)) {6793 switch (errno(rc)) {
lib/std/os/test.zig+1-1
...@@ -541,7 +541,7 @@ test "memfd_create" {...@@ -541,7 +541,7 @@ test "memfd_create" {
541 switch (native_os) {541 switch (native_os) {
542 .linux => {},542 .linux => {},
543 .freebsd => {543 .freebsd => {
544 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .lt)544 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0, .patch = 0 }) == .lt)
545 return error.SkipZigTest;545 return error.SkipZigTest;
546 },546 },
547 else => return error.SkipZigTest,547 else => return error.SkipZigTest,
lib/std/target.zig+18-18
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const std = @import("std.zig");1const std = @import("std.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const mem = std.mem;3const mem = std.mem;
4const Version = std.builtin.Version;4const Version = std.SemanticVersion;
55
6/// TODO Nearly all the functions in this namespace would be6/// TODO Nearly all the functions in this namespace would be
7/// better off if https://github.com/ziglang/zig/issues/4257/// better off if https://github.com/ziglang/zig/issues/425
...@@ -272,75 +272,75 @@ pub const Target = struct {...@@ -272,75 +272,75 @@ pub const Target = struct {
272272
273 .freebsd => return .{273 .freebsd => return .{
274 .semver = Version.Range{274 .semver = Version.Range{
275 .min = .{ .major = 12, .minor = 0 },275 .min = .{ .major = 12, .minor = 0, .patch = 0 },
276 .max = .{ .major = 13, .minor = 1 },276 .max = .{ .major = 13, .minor = 1, .patch = 0 },
277 },277 },
278 },278 },
279 .macos => return switch (arch) {279 .macos => return switch (arch) {
280 .aarch64 => VersionRange{280 .aarch64 => VersionRange{
281 .semver = .{281 .semver = .{
282 .min = .{ .major = 11, .minor = 7, .patch = 1 },282 .min = .{ .major = 11, .minor = 7, .patch = 1 },
283 .max = .{ .major = 13, .minor = 3 },283 .max = .{ .major = 13, .minor = 3, .patch = 0 },
284 },284 },
285 },285 },
286 .x86_64 => VersionRange{286 .x86_64 => VersionRange{
287 .semver = .{287 .semver = .{
288 .min = .{ .major = 11, .minor = 7, .patch = 1 },288 .min = .{ .major = 11, .minor = 7, .patch = 1 },
289 .max = .{ .major = 13, .minor = 3 },289 .max = .{ .major = 13, .minor = 3, .patch = 0 },
290 },290 },
291 },291 },
292 else => unreachable,292 else => unreachable,
293 },293 },
294 .ios => return .{294 .ios => return .{
295 .semver = .{295 .semver = .{
296 .min = .{ .major = 12, .minor = 0 },296 .min = .{ .major = 12, .minor = 0, .patch = 0 },
297 .max = .{ .major = 13, .minor = 4, .patch = 0 },297 .max = .{ .major = 13, .minor = 4, .patch = 0 },
298 },298 },
299 },299 },
300 .watchos => return .{300 .watchos => return .{
301 .semver = .{301 .semver = .{
302 .min = .{ .major = 6, .minor = 0 },302 .min = .{ .major = 6, .minor = 0, .patch = 0 },
303 .max = .{ .major = 6, .minor = 2, .patch = 0 },303 .max = .{ .major = 6, .minor = 2, .patch = 0 },
304 },304 },
305 },305 },
306 .tvos => return .{306 .tvos => return .{
307 .semver = .{307 .semver = .{
308 .min = .{ .major = 13, .minor = 0 },308 .min = .{ .major = 13, .minor = 0, .patch = 0 },
309 .max = .{ .major = 13, .minor = 4, .patch = 0 },309 .max = .{ .major = 13, .minor = 4, .patch = 0 },
310 },310 },
311 },311 },
312 .netbsd => return .{312 .netbsd => return .{
313 .semver = .{313 .semver = .{
314 .min = .{ .major = 8, .minor = 0 },314 .min = .{ .major = 8, .minor = 0, .patch = 0 },
315 .max = .{ .major = 10, .minor = 0 },315 .max = .{ .major = 10, .minor = 0, .patch = 0 },
316 },316 },
317 },317 },
318 .openbsd => return .{318 .openbsd => return .{
319 .semver = .{319 .semver = .{
320 .min = .{ .major = 6, .minor = 8 },320 .min = .{ .major = 6, .minor = 8, .patch = 0 },
321 .max = .{ .major = 7, .minor = 2 },321 .max = .{ .major = 7, .minor = 2, .patch = 0 },
322 },322 },
323 },323 },
324 .dragonfly => return .{324 .dragonfly => return .{
325 .semver = .{325 .semver = .{
326 .min = .{ .major = 5, .minor = 8 },326 .min = .{ .major = 5, .minor = 8, .patch = 0 },
327 .max = .{ .major = 6, .minor = 4 },327 .max = .{ .major = 6, .minor = 4, .patch = 0 },
328 },328 },
329 },329 },
330 .solaris => return .{330 .solaris => return .{
331 .semver = .{331 .semver = .{
332 .min = .{ .major = 5, .minor = 11 },332 .min = .{ .major = 5, .minor = 11, .patch = 0 },
333 .max = .{ .major = 5, .minor = 11 },333 .max = .{ .major = 5, .minor = 11, .patch = 0 },
334 },334 },
335 },335 },
336336
337 .linux => return .{337 .linux => return .{
338 .linux = .{338 .linux = .{
339 .range = .{339 .range = .{
340 .min = .{ .major = 3, .minor = 16 },340 .min = .{ .major = 3, .minor = 16, .patch = 0 },
341 .max = .{ .major = 5, .minor = 10, .patch = 81 },341 .max = .{ .major = 5, .minor = 10, .patch = 81 },
342 },342 },
343 .glibc = .{ .major = 2, .minor = 19 },343 .glibc = .{ .major = 2, .minor = 19, .patch = 0 },
344 },344 },
345 },345 },
346346
lib/std/zig.zig+1-1
...@@ -108,7 +108,7 @@ pub const BinNameOptions = struct {...@@ -108,7 +108,7 @@ pub const BinNameOptions = struct {
108 target: std.Target,108 target: std.Target,
109 output_mode: std.builtin.OutputMode,109 output_mode: std.builtin.OutputMode,
110 link_mode: ?std.builtin.LinkMode = null,110 link_mode: ?std.builtin.LinkMode = null,
111 version: ?std.builtin.Version = null,111 version: ?std.SemanticVersion = null,
112};112};
113113
114/// Returns the standard file system basename of a binary generated by the Zig compiler.114/// Returns the standard file system basename of a binary generated by the Zig compiler.
lib/std/zig/CrossTarget.zig+52-13
...@@ -33,7 +33,7 @@ os_version_max: ?OsVersion = null,...@@ -33,7 +33,7 @@ os_version_max: ?OsVersion = null,
3333
34/// `null` means default when cross compiling, or native when os_tag is native.34/// `null` means default when cross compiling, or native when os_tag is native.
35/// If `isGnuLibC()` is `false`, this must be `null` and is ignored.35/// If `isGnuLibC()` is `false`, this must be `null` and is ignored.
36glibc_version: ?SemVer = null,36glibc_version: ?SemanticVersion = null,
3737
38/// `null` means the native C ABI, if `os_tag` is native, otherwise it means the default C ABI.38/// `null` means the native C ABI, if `os_tag` is native, otherwise it means the default C ABI.
39abi: ?Target.Abi = null,39abi: ?Target.Abi = null,
...@@ -61,11 +61,11 @@ pub const CpuModel = union(enum) {...@@ -61,11 +61,11 @@ pub const CpuModel = union(enum) {
6161
62pub const OsVersion = union(enum) {62pub const OsVersion = union(enum) {
63 none: void,63 none: void,
64 semver: SemVer,64 semver: SemanticVersion,
65 windows: Target.Os.WindowsVersion,65 windows: Target.Os.WindowsVersion,
66};66};
6767
68pub const SemVer = std.builtin.Version;68pub const SemanticVersion = std.SemanticVersion;
6969
70pub const DynamicLinker = Target.DynamicLinker;70pub const DynamicLinker = Target.DynamicLinker;
7171
...@@ -266,9 +266,8 @@ pub fn parse(args: ParseOptions) !CrossTarget {...@@ -266,9 +266,8 @@ pub fn parse(args: ParseOptions) !CrossTarget {
266 const abi_ver_text = abi_it.rest();266 const abi_ver_text = abi_it.rest();
267 if (abi_it.next() != null) {267 if (abi_it.next() != null) {
268 if (result.isGnuLibC()) {268 if (result.isGnuLibC()) {
269 result.glibc_version = SemVer.parse(abi_ver_text) catch |err| switch (err) {269 result.glibc_version = parseVersion(abi_ver_text) catch |err| switch (err) {
270 error.Overflow => return error.InvalidAbiVersion,270 error.Overflow => return error.InvalidAbiVersion,
271 error.InvalidCharacter => return error.InvalidAbiVersion,
272 error.InvalidVersion => return error.InvalidAbiVersion,271 error.InvalidVersion => return error.InvalidAbiVersion,
273 };272 };
274 } else {273 } else {
...@@ -353,6 +352,31 @@ pub fn parseCpuArch(args: ParseOptions) ?Target.Cpu.Arch {...@@ -353,6 +352,31 @@ pub fn parseCpuArch(args: ParseOptions) ?Target.Cpu.Arch {
353 }352 }
354}353}
355354
355/// Parses a version with an omitted patch component, such as "1.0",
356/// which SemanticVersion.parse is not capable of.
357fn parseVersion(ver: []const u8) !SemanticVersion {
358 const parseVersionComponent = struct {
359 fn parseVersionComponent(component: []const u8) !usize {
360 return std.fmt.parseUnsigned(usize, component, 10) catch |err| {
361 switch (err) {
362 error.InvalidCharacter => return error.InvalidVersion,
363 error.Overflow => return error.Overflow,
364 }
365 };
366 }
367 }.parseVersionComponent;
368 var version_components = mem.split(u8, ver, ".");
369 const major = version_components.first();
370 const minor = version_components.next() orelse return error.InvalidVersion;
371 const patch = version_components.next() orelse "0";
372 if (version_components.next() != null) return error.InvalidVersion;
373 return .{
374 .major = try parseVersionComponent(major),
375 .minor = try parseVersionComponent(minor),
376 .patch = try parseVersionComponent(patch),
377 };
378}
379
356/// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`.380/// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`.
357pub fn getCpu(self: CrossTarget) Target.Cpu {381pub fn getCpu(self: CrossTarget) Target.Cpu {
358 switch (self.cpu_model) {382 switch (self.cpu_model) {
...@@ -534,6 +558,16 @@ pub fn isNative(self: CrossTarget) bool {...@@ -534,6 +558,16 @@ pub fn isNative(self: CrossTarget) bool {
534 return self.isNativeCpu() and self.isNativeOs() and self.isNativeAbi();558 return self.isNativeCpu() and self.isNativeOs() and self.isNativeAbi();
535}559}
536560
561/// Formats a version with the patch component omitted if it is zero,
562/// unlike SemanticVersion.format which formats all its version components regardless.
563fn formatVersion(version: SemanticVersion, writer: anytype) !void {
564 if (version.patch == 0) {
565 try writer.print("{d}.{d}", .{ version.major, version.minor });
566 } else {
567 try writer.print("{d}.{d}.{d}", .{ version.major, version.minor, version.patch });
568 }
569}
570
537pub fn zigTriple(self: CrossTarget, allocator: mem.Allocator) error{OutOfMemory}![]u8 {571pub fn zigTriple(self: CrossTarget, allocator: mem.Allocator) error{OutOfMemory}![]u8 {
538 if (self.isNative()) {572 if (self.isNative()) {
539 return allocator.dupe(u8, "native");573 return allocator.dupe(u8, "native");
...@@ -552,20 +586,27 @@ pub fn zigTriple(self: CrossTarget, allocator: mem.Allocator) error{OutOfMemory}...@@ -552,20 +586,27 @@ pub fn zigTriple(self: CrossTarget, allocator: mem.Allocator) error{OutOfMemory}
552 if (self.os_version_min != null or self.os_version_max != null) {586 if (self.os_version_min != null or self.os_version_max != null) {
553 switch (self.getOsVersionMin()) {587 switch (self.getOsVersionMin()) {
554 .none => {},588 .none => {},
555 .semver => |v| try result.writer().print(".{}", .{v}),589 .semver => |v| {
590 try result.writer().writeAll(".");
591 try formatVersion(v, result.writer());
592 },
556 .windows => |v| try result.writer().print("{s}", .{v}),593 .windows => |v| try result.writer().print("{s}", .{v}),
557 }594 }
558 }595 }
559 if (self.os_version_max) |max| {596 if (self.os_version_max) |max| {
560 switch (max) {597 switch (max) {
561 .none => {},598 .none => {},
562 .semver => |v| try result.writer().print("...{}", .{v}),599 .semver => |v| {
600 try result.writer().writeAll("...");
601 try formatVersion(v, result.writer());
602 },
563 .windows => |v| try result.writer().print("..{s}", .{v}),603 .windows => |v| try result.writer().print("..{s}", .{v}),
564 }604 }
565 }605 }
566606
567 if (self.glibc_version) |v| {607 if (self.glibc_version) |v| {
568 try result.writer().print("-{s}.{}", .{ @tagName(self.getAbi()), v });608 try result.writer().print("-{s}.", .{@tagName(self.getAbi())});
609 try formatVersion(v, result.writer());
569 } else if (self.abi) |abi| {610 } else if (self.abi) |abi| {
570 try result.writer().print("-{s}", .{@tagName(abi)});611 try result.writer().print("-{s}", .{@tagName(abi)});
571 }612 }
...@@ -630,7 +671,7 @@ pub fn isGnuLibC(self: CrossTarget) bool {...@@ -630,7 +671,7 @@ pub fn isGnuLibC(self: CrossTarget) bool {
630671
631pub fn setGnuLibCVersion(self: *CrossTarget, major: u32, minor: u32, patch: u32) void {672pub fn setGnuLibCVersion(self: *CrossTarget, major: u32, minor: u32, patch: u32) void {
632 assert(self.isGnuLibC());673 assert(self.isGnuLibC());
633 self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };674 self.glibc_version = SemanticVersion{ .major = major, .minor = minor, .patch = patch };
634}675}
635676
636pub fn getObjectFormat(self: CrossTarget) Target.ObjectFormat {677pub fn getObjectFormat(self: CrossTarget) Target.ObjectFormat {
...@@ -709,17 +750,15 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -709,17 +750,15 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
709 var range_it = mem.splitSequence(u8, version_text, "...");750 var range_it = mem.splitSequence(u8, version_text, "...");
710751
711 const min_text = range_it.next().?;752 const min_text = range_it.next().?;
712 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {753 const min_ver = parseVersion(min_text) catch |err| switch (err) {
713 error.Overflow => return error.InvalidOperatingSystemVersion,754 error.Overflow => return error.InvalidOperatingSystemVersion,
714 error.InvalidCharacter => return error.InvalidOperatingSystemVersion,
715 error.InvalidVersion => return error.InvalidOperatingSystemVersion,755 error.InvalidVersion => return error.InvalidOperatingSystemVersion,
716 };756 };
717 result.os_version_min = .{ .semver = min_ver };757 result.os_version_min = .{ .semver = min_ver };
718758
719 const max_text = range_it.next() orelse return;759 const max_text = range_it.next() orelse return;
720 const max_ver = SemVer.parse(max_text) catch |err| switch (err) {760 const max_ver = parseVersion(max_text) catch |err| switch (err) {
721 error.Overflow => return error.InvalidOperatingSystemVersion,761 error.Overflow => return error.InvalidOperatingSystemVersion,
722 error.InvalidCharacter => return error.InvalidOperatingSystemVersion,
723 error.InvalidVersion => return error.InvalidOperatingSystemVersion,762 error.InvalidVersion => return error.InvalidOperatingSystemVersion,
724 };763 };
725 result.os_version_max = .{ .semver = max_ver };764 result.os_version_max = .{ .semver = max_ver };
lib/std/zig/system/NativeTargetInfo.zig+9-13
...@@ -43,24 +43,22 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {...@@ -43,24 +43,22 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
43 const release = mem.sliceTo(&uts.release, 0);43 const release = mem.sliceTo(&uts.release, 0);
44 // The release field sometimes has a weird format,44 // The release field sometimes has a weird format,
45 // `Version.parse` will attempt to find some meaningful interpretation.45 // `Version.parse` will attempt to find some meaningful interpretation.
46 if (std.builtin.Version.parse(release)) |ver| {46 if (std.SemanticVersion.parse(release)) |ver| {
47 os.version_range.linux.range.min = ver;47 os.version_range.linux.range.min = ver;
48 os.version_range.linux.range.max = ver;48 os.version_range.linux.range.max = ver;
49 } else |err| switch (err) {49 } else |err| switch (err) {
50 error.Overflow => {},50 error.Overflow => {},
51 error.InvalidCharacter => {},
52 error.InvalidVersion => {},51 error.InvalidVersion => {},
53 }52 }
54 },53 },
55 .solaris => {54 .solaris => {
56 const uts = std.os.uname();55 const uts = std.os.uname();
57 const release = mem.sliceTo(&uts.release, 0);56 const release = mem.sliceTo(&uts.release, 0);
58 if (std.builtin.Version.parse(release)) |ver| {57 if (std.SemanticVersion.parse(release)) |ver| {
59 os.version_range.semver.min = ver;58 os.version_range.semver.min = ver;
60 os.version_range.semver.max = ver;59 os.version_range.semver.max = ver;
61 } else |err| switch (err) {60 } else |err| switch (err) {
62 error.Overflow => {},61 error.Overflow => {},
63 error.InvalidCharacter => {},
64 error.InvalidVersion => {},62 error.InvalidVersion => {},
65 }63 }
66 },64 },
...@@ -144,7 +142,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {...@@ -144,7 +142,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
144 error.Unexpected => return error.OSVersionDetectionFail,142 error.Unexpected => return error.OSVersionDetectionFail,
145 };143 };
146144
147 if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| {145 if (std.SemanticVersion.parse(buf[0 .. len - 1])) |ver| {
148 os.version_range.semver.min = ver;146 os.version_range.semver.min = ver;
149 os.version_range.semver.max = ver;147 os.version_range.semver.max = ver;
150 } else |_| {148 } else |_| {
...@@ -390,7 +388,7 @@ fn detectAbiAndDynamicLinker(...@@ -390,7 +388,7 @@ fn detectAbiAndDynamicLinker(
390 };388 };
391}389}
392390
393fn glibcVerFromRPath(rpath: []const u8) !std.builtin.Version {391fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
394 var dir = fs.cwd().openDir(rpath, .{}) catch |err| switch (err) {392 var dir = fs.cwd().openDir(rpath, .{}) catch |err| switch (err) {
395 error.NameTooLong => unreachable,393 error.NameTooLong => unreachable,
396 error.InvalidUtf8 => unreachable,394 error.InvalidUtf8 => unreachable,
...@@ -471,7 +469,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.builtin.Version {...@@ -471,7 +469,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.builtin.Version {
471 };469 };
472}470}
473471
474fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {472fn glibcVerFromSoFile(file: fs.File) !std.SemanticVersion {
475 var hdr_buf: [@sizeOf(elf.Elf64_Ehdr)]u8 align(@alignOf(elf.Elf64_Ehdr)) = undefined;473 var hdr_buf: [@sizeOf(elf.Elf64_Ehdr)]u8 align(@alignOf(elf.Elf64_Ehdr)) = undefined;
476 _ = try preadMin(file, &hdr_buf, 0, hdr_buf.len);474 _ = try preadMin(file, &hdr_buf, 0, hdr_buf.len);
477 const hdr32 = @ptrCast(*elf.Elf32_Ehdr, &hdr_buf);475 const hdr32 = @ptrCast(*elf.Elf32_Ehdr, &hdr_buf);
...@@ -557,13 +555,12 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {...@@ -557,13 +555,12 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {
557 const dynstr_bytes = buf[0..dynstr_size];555 const dynstr_bytes = buf[0..dynstr_size];
558 _ = try preadMin(file, dynstr_bytes, dynstr.offset, dynstr_bytes.len);556 _ = try preadMin(file, dynstr_bytes, dynstr.offset, dynstr_bytes.len);
559 var it = mem.splitScalar(u8, dynstr_bytes, 0);557 var it = mem.splitScalar(u8, dynstr_bytes, 0);
560 var max_ver: std.builtin.Version = .{ .major = 2, .minor = 2, .patch = 5 };558 var max_ver: std.SemanticVersion = .{ .major = 2, .minor = 2, .patch = 5 };
561 while (it.next()) |s| {559 while (it.next()) |s| {
562 if (mem.startsWith(u8, s, "GLIBC_2.")) {560 if (mem.startsWith(u8, s, "GLIBC_2.")) {
563 const chopped = s["GLIBC_".len..];561 const chopped = s["GLIBC_".len..];
564 const ver = std.builtin.Version.parse(chopped) catch |err| switch (err) {562 const ver = std.SemanticVersion.parse(chopped) catch |err| switch (err) {
565 error.Overflow => return error.InvalidGnuLibCVersion,563 error.Overflow => return error.InvalidGnuLibCVersion,
566 error.InvalidCharacter => return error.InvalidGnuLibCVersion,
567 error.InvalidVersion => return error.InvalidGnuLibCVersion,564 error.InvalidVersion => return error.InvalidGnuLibCVersion,
568 };565 };
569 switch (ver.order(max_ver)) {566 switch (ver.order(max_ver)) {
...@@ -575,7 +572,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {...@@ -575,7 +572,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {
575 return max_ver;572 return max_ver;
576}573}
577574
578fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.builtin.Version {575fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.SemanticVersion {
579 // example: "libc-2.3.4.so"576 // example: "libc-2.3.4.so"
580 // example: "libc-2.27.so"577 // example: "libc-2.27.so"
581 // example: "ld-2.33.so"578 // example: "ld-2.33.so"
...@@ -585,9 +582,8 @@ fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.builtin....@@ -585,9 +582,8 @@ fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.builtin.
585 }582 }
586 // chop off "libc-" and ".so"583 // chop off "libc-" and ".so"
587 const link_name_chopped = link_name[prefix.len .. link_name.len - suffix.len];584 const link_name_chopped = link_name[prefix.len .. link_name.len - suffix.len];
588 return std.builtin.Version.parse(link_name_chopped) catch |err| switch (err) {585 return std.SemanticVersion.parse(link_name_chopped) catch |err| switch (err) {
589 error.Overflow => return error.InvalidGnuLibCVersion,586 error.Overflow => return error.InvalidGnuLibCVersion,
590 error.InvalidCharacter => return error.InvalidGnuLibCVersion,
591 error.InvalidVersion => return error.InvalidGnuLibCVersion,587 error.InvalidVersion => return error.InvalidGnuLibCVersion,
592 };588 };
593}589}
lib/std/zig/system/darwin.zig+2-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const mem = std.mem;2const mem = std.mem;
3const Allocator = mem.Allocator;3const Allocator = mem.Allocator;
4const Target = std.Target;4const Target = std.Target;
5const Version = std.builtin.Version;5const Version = std.SemanticVersion;
66
7pub const macos = @import("darwin/macos.zig");7pub const macos = @import("darwin/macos.zig");
88
...@@ -69,6 +69,7 @@ pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK {...@@ -69,6 +69,7 @@ pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK {
69 const version = Version.parse(raw_version) catch Version{69 const version = Version.parse(raw_version) catch Version{
70 .major = 0,70 .major = 0,
71 .minor = 0,71 .minor = 0,
72 .patch = 0,
72 };73 };
73 break :version version;74 break :version version;
74 };75 };
lib/std/zig/system/darwin/macos.zig+28-19
...@@ -74,20 +74,39 @@ pub fn detect(target_os: *Target.Os) !void {...@@ -74,20 +74,39 @@ pub fn detect(target_os: *Target.Os) !void {
74 return error.OSVersionDetectionFail;74 return error.OSVersionDetectionFail;
75}75}
7676
77fn parseSystemVersion(buf: []const u8) !std.builtin.Version {77fn parseSystemVersion(buf: []const u8) !std.SemanticVersion {
78 var svt = SystemVersionTokenizer{ .bytes = buf };78 var svt = SystemVersionTokenizer{ .bytes = buf };
79 try svt.skipUntilTag(.start, "dict");79 try svt.skipUntilTag(.start, "dict");
80 while (true) {80 while (true) {
81 try svt.skipUntilTag(.start, "key");81 try svt.skipUntilTag(.start, "key");
82 const content = try svt.expectContent();82 const content = try svt.expectContent();
83 try svt.skipUntilTag(.end, "key");83 try svt.skipUntilTag(.end, "key");
84 if (std.mem.eql(u8, content, "ProductVersion")) break;84 if (mem.eql(u8, content, "ProductVersion")) break;
85 }85 }
86 try svt.skipUntilTag(.start, "string");86 try svt.skipUntilTag(.start, "string");
87 const ver = try svt.expectContent();87 const ver = try svt.expectContent();
88 try svt.skipUntilTag(.end, "string");88 try svt.skipUntilTag(.end, "string");
8989
90 return std.builtin.Version.parse(ver);90 const parseVersionComponent = struct {
91 fn parseVersionComponent(component: []const u8) !usize {
92 return std.fmt.parseUnsigned(usize, component, 10) catch |err| {
93 switch (err) {
94 error.InvalidCharacter => return error.InvalidVersion,
95 error.Overflow => return error.Overflow,
96 }
97 };
98 }
99 }.parseVersionComponent;
100 var version_components = mem.split(u8, ver, ".");
101 const major = version_components.first();
102 const minor = version_components.next() orelse return error.InvalidVersion;
103 const patch = version_components.next() orelse "0";
104 if (version_components.next() != null) return error.InvalidVersion;
105 return .{
106 .major = try parseVersionComponent(major),
107 .minor = try parseVersionComponent(minor),
108 .patch = try parseVersionComponent(patch),
109 };
91}110}
92111
93const SystemVersionTokenizer = struct {112const SystemVersionTokenizer = struct {
...@@ -246,7 +265,7 @@ const SystemVersionTokenizer = struct {...@@ -246,7 +265,7 @@ const SystemVersionTokenizer = struct {
246 while (try self.next()) |tok| {265 while (try self.next()) |tok| {
247 switch (tok) {266 switch (tok) {
248 .tag => |tag| {267 .tag => |tag| {
249 if (tag.kind == kind and std.mem.eql(u8, tag.name, name)) return;268 if (tag.kind == kind and mem.eql(u8, tag.name, name)) return;
250 },269 },
251 else => {},270 else => {},
252 }271 }
...@@ -297,7 +316,7 @@ test "detect" {...@@ -297,7 +316,7 @@ test "detect" {
297 \\</dict>316 \\</dict>
298 \\</plist>317 \\</plist>
299 ,318 ,
300 .{ .major = 10, .minor = 3 },319 .{ .major = 10, .minor = 3, .patch = 0 },
301 },320 },
302 .{321 .{
303 \\<?xml version="1.0" encoding="UTF-8"?>322 \\<?xml version="1.0" encoding="UTF-8"?>
...@@ -361,7 +380,7 @@ test "detect" {...@@ -361,7 +380,7 @@ test "detect" {
361 \\</dict>380 \\</dict>
362 \\</plist>381 \\</plist>
363 ,382 ,
364 .{ .major = 11, .minor = 0 },383 .{ .major = 11, .minor = 0, .patch = 0 },
365 },384 },
366 .{385 .{
367 \\<?xml version="1.0" encoding="UTF-8"?>386 \\<?xml version="1.0" encoding="UTF-8"?>
...@@ -383,27 +402,17 @@ test "detect" {...@@ -383,27 +402,17 @@ test "detect" {
383 \\</dict>402 \\</dict>
384 \\</plist>403 \\</plist>
385 ,404 ,
386 .{ .major = 11, .minor = 1 },405 .{ .major = 11, .minor = 1, .patch = 0 },
387 },406 },
388 };407 };
389408
390 inline for (cases) |case| {409 inline for (cases) |case| {
391 const ver0 = try parseSystemVersion(case[0]);410 const ver0 = try parseSystemVersion(case[0]);
392 const ver1: std.builtin.Version = case[1];411 const ver1: std.SemanticVersion = case[1];
393 try testVersionEquality(ver1, ver0);412 try testing.expectEqual(@as(std.math.Order, .eq), ver0.order(ver1));
394 }413 }
395}414}
396415
397fn testVersionEquality(expected: std.builtin.Version, got: std.builtin.Version) !void {
398 var b_expected: [64]u8 = undefined;
399 const s_expected: []const u8 = try std.fmt.bufPrint(b_expected[0..], "{}", .{expected});
400
401 var b_got: [64]u8 = undefined;
402 const s_got: []const u8 = try std.fmt.bufPrint(b_got[0..], "{}", .{got});
403
404 try testing.expectEqualStrings(s_expected, s_got);
405}
406
407pub fn detectNativeCpuAndFeatures() ?Target.Cpu {416pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
408 var cpu_family: std.c.CPUFAMILY = undefined;417 var cpu_family: std.c.CPUFAMILY = undefined;
409 var len: usize = @sizeOf(std.c.CPUFAMILY);418 var len: usize = @sizeOf(std.c.CPUFAMILY);
src/Compilation.zig+2-2
...@@ -615,8 +615,8 @@ pub const InitOptions = struct {...@@ -615,8 +615,8 @@ pub const InitOptions = struct {
615 stack_size_override: ?u64 = null,615 stack_size_override: ?u64 = null,
616 image_base_override: ?u64 = null,616 image_base_override: ?u64 = null,
617 self_exe_path: ?[]const u8 = null,617 self_exe_path: ?[]const u8 = null,
618 version: ?std.builtin.Version = null,618 version: ?std.SemanticVersion = null,
619 compatibility_version: ?std.builtin.Version = null,619 compatibility_version: ?std.SemanticVersion = null,
620 libc_installation: ?*const LibCInstallation = null,620 libc_installation: ?*const LibCInstallation = null,
621 machine_code_model: std.builtin.CodeModel = .default,621 machine_code_model: std.builtin.CodeModel = .default,
622 clang_preprocessor_mode: ClangPreprocessorMode = .no,622 clang_preprocessor_mode: ClangPreprocessorMode = .no,
src/codegen/spirv/spec.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1//! This file is auto-generated by tools/gen_spirv_spec.zig.1//! This file is auto-generated by tools/gen_spirv_spec.zig.
22
3const Version = @import("std").builtin.Version;3const Version = @import("std").SemanticVersion;
44
5pub const Word = u32;5pub const Word = u32;
6pub const IdResult = struct {6pub const IdResult = struct {
src/glibc.zig+2-2
...@@ -5,7 +5,7 @@ const log = std.log;...@@ -5,7 +5,7 @@ const log = std.log;
5const fs = std.fs;5const fs = std.fs;
6const path = fs.path;6const path = fs.path;
7const assert = std.debug.assert;7const assert = std.debug.assert;
8const Version = std.builtin.Version;8const Version = std.SemanticVersion;
99
10const target_util = @import("target.zig");10const target_util = @import("target.zig");
11const Compilation = @import("Compilation.zig");11const Compilation = @import("Compilation.zig");
...@@ -172,7 +172,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -172,7 +172,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
172172
173 const target = comp.getTarget();173 const target = comp.getTarget();
174 const target_ver = target.os.version_range.linux.glibc;174 const target_ver = target.os.version_range.linux.glibc;
175 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33 }) != .gt;175 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;
176176
177 // In all cases in this function, we add the C compiler flags to177 // In all cases in this function, we add the C compiler flags to
178 // cache_exempt_flags rather than extra_flags, because these arguments178 // cache_exempt_flags rather than extra_flags, because these arguments
src/link.zig+2-2
...@@ -197,8 +197,8 @@ pub const Options = struct {...@@ -197,8 +197,8 @@ pub const Options = struct {
197 /// __real_symbol.197 /// __real_symbol.
198 symbol_wrap_set: std.StringArrayHashMapUnmanaged(void),198 symbol_wrap_set: std.StringArrayHashMapUnmanaged(void),
199199
200 version: ?std.builtin.Version,200 version: ?std.SemanticVersion,
201 compatibility_version: ?std.builtin.Version,201 compatibility_version: ?std.SemanticVersion,
202 libc_installation: ?*const LibCInstallation,202 libc_installation: ?*const LibCInstallation,
203203
204 dwarf_format: ?std.dwarf.Format,204 dwarf_format: ?std.dwarf.Format,
src/link/Elf.zig+1-1
...@@ -3414,7 +3414,7 @@ const CsuObjects = struct {...@@ -3414,7 +3414,7 @@ const CsuObjects = struct {
3414 if (result.crtn) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });3414 if (result.crtn) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });
34153415
3416 var gccv: []const u8 = undefined;3416 var gccv: []const u8 = undefined;
3417 if (link_options.target.os.version_range.semver.isAtLeast(.{ .major = 5, .minor = 4 }) orelse true) {3417 if (link_options.target.os.version_range.semver.isAtLeast(.{ .major = 5, .minor = 4, .patch = 0 }) orelse true) {
3418 gccv = "gcc80";3418 gccv = "gcc80";
3419 } else {3419 } else {
3420 gccv = "gcc54";3420 gccv = "gcc54";
src/link/MachO/load_commands.zig+6-6
...@@ -204,12 +204,12 @@ pub fn writeDylibIdLC(gpa: Allocator, options: *const link.Options, lc_writer: a...@@ -204,12 +204,12 @@ pub fn writeDylibIdLC(gpa: Allocator, options: *const link.Options, lc_writer: a
204 const emit = options.emit.?;204 const emit = options.emit.?;
205 const install_name = options.install_name orelse try emit.directory.join(gpa, &.{emit.sub_path});205 const install_name = options.install_name orelse try emit.directory.join(gpa, &.{emit.sub_path});
206 defer if (options.install_name == null) gpa.free(install_name);206 defer if (options.install_name == null) gpa.free(install_name);
207 const curr = options.version orelse std.builtin.Version{207 const curr = options.version orelse std.SemanticVersion{
208 .major = 1,208 .major = 1,
209 .minor = 0,209 .minor = 0,
210 .patch = 0,210 .patch = 0,
211 };211 };
212 const compat = options.compatibility_version orelse std.builtin.Version{212 const compat = options.compatibility_version orelse std.SemanticVersion{
213 .major = 1,213 .major = 1,
214 .minor = 0,214 .minor = 0,
215 .patch = 0,215 .patch = 0,
...@@ -217,8 +217,8 @@ pub fn writeDylibIdLC(gpa: Allocator, options: *const link.Options, lc_writer: a...@@ -217,8 +217,8 @@ pub fn writeDylibIdLC(gpa: Allocator, options: *const link.Options, lc_writer: a
217 try writeDylibLC(.{217 try writeDylibLC(.{
218 .cmd = .ID_DYLIB,218 .cmd = .ID_DYLIB,
219 .name = install_name,219 .name = install_name,
220 .current_version = curr.major << 16 | curr.minor << 8 | curr.patch,220 .current_version = @intCast(u32, curr.major << 16 | curr.minor << 8 | curr.patch),
221 .compatibility_version = compat.major << 16 | compat.minor << 8 | compat.patch,221 .compatibility_version = @intCast(u32, compat.major << 16 | compat.minor << 8 | compat.patch),
222 }, lc_writer);222 }, lc_writer);
223}223}
224224
...@@ -275,12 +275,12 @@ pub fn writeBuildVersionLC(options: *const link.Options, lc_writer: anytype) !vo...@@ -275,12 +275,12 @@ pub fn writeBuildVersionLC(options: *const link.Options, lc_writer: anytype) !vo
275 const cmdsize = @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version);275 const cmdsize = @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version);
276 const platform_version = blk: {276 const platform_version = blk: {
277 const ver = options.target.os.version_range.semver.min;277 const ver = options.target.os.version_range.semver.min;
278 const platform_version = ver.major << 16 | ver.minor << 8;278 const platform_version = @intCast(u32, ver.major << 16 | ver.minor << 8);
279 break :blk platform_version;279 break :blk platform_version;
280 };280 };
281 const sdk_version = if (options.native_darwin_sdk) |sdk| blk: {281 const sdk_version = if (options.native_darwin_sdk) |sdk| blk: {
282 const ver = sdk.version;282 const ver = sdk.version;
283 const sdk_version = ver.major << 16 | ver.minor << 8;283 const sdk_version = @intCast(u32, ver.major << 16 | ver.minor << 8);
284 break :blk sdk_version;284 break :blk sdk_version;
285 } else platform_version;285 } else platform_version;
286 const is_simulator_abi = options.target.abi == .simulator;286 const is_simulator_abi = options.target.abi == .simulator;
src/main.zig+6-7
...@@ -724,9 +724,9 @@ fn buildOutputType(...@@ -724,9 +724,9 @@ fn buildOutputType(
724 var dll_export_fns: ?bool = null;724 var dll_export_fns: ?bool = null;
725 var single_threaded: ?bool = null;725 var single_threaded: ?bool = null;
726 var root_src_file: ?[]const u8 = null;726 var root_src_file: ?[]const u8 = null;
727 var version: std.builtin.Version = .{ .major = 0, .minor = 0, .patch = 0 };727 var version: std.SemanticVersion = .{ .major = 0, .minor = 0, .patch = 0 };
728 var have_version = false;728 var have_version = false;
729 var compatibility_version: ?std.builtin.Version = null;729 var compatibility_version: ?std.SemanticVersion = null;
730 var strip: ?bool = null;730 var strip: ?bool = null;
731 var formatted_panics: ?bool = null;731 var formatted_panics: ?bool = null;
732 var function_sections = false;732 var function_sections = false;
...@@ -1121,7 +1121,7 @@ fn buildOutputType(...@@ -1121,7 +1121,7 @@ fn buildOutputType(
1121 try cssan.addIncludePath(.iframework, arg, args_iter.nextOrFatal(), false);1121 try cssan.addIncludePath(.iframework, arg, args_iter.nextOrFatal(), false);
1122 } else if (mem.eql(u8, arg, "--version")) {1122 } else if (mem.eql(u8, arg, "--version")) {
1123 const next_arg = args_iter.nextOrFatal();1123 const next_arg = args_iter.nextOrFatal();
1124 version = std.builtin.Version.parse(next_arg) catch |err| {1124 version = std.SemanticVersion.parse(next_arg) catch |err| {
1125 fatal("unable to parse --version '{s}': {s}", .{ next_arg, @errorName(err) });1125 fatal("unable to parse --version '{s}': {s}", .{ next_arg, @errorName(err) });
1126 };1126 };
1127 have_version = true;1127 have_version = true;
...@@ -2152,12 +2152,12 @@ fn buildOutputType(...@@ -2152,12 +2152,12 @@ fn buildOutputType(
2152 try system_libs.put(linker_args_it.nextOrFatal(), .{ .weak = true });2152 try system_libs.put(linker_args_it.nextOrFatal(), .{ .weak = true });
2153 } else if (mem.eql(u8, arg, "-compatibility_version")) {2153 } else if (mem.eql(u8, arg, "-compatibility_version")) {
2154 const compat_version = linker_args_it.nextOrFatal();2154 const compat_version = linker_args_it.nextOrFatal();
2155 compatibility_version = std.builtin.Version.parse(compat_version) catch |err| {2155 compatibility_version = std.SemanticVersion.parse(compat_version) catch |err| {
2156 fatal("unable to parse -compatibility_version '{s}': {s}", .{ compat_version, @errorName(err) });2156 fatal("unable to parse -compatibility_version '{s}': {s}", .{ compat_version, @errorName(err) });
2157 };2157 };
2158 } else if (mem.eql(u8, arg, "-current_version")) {2158 } else if (mem.eql(u8, arg, "-current_version")) {
2159 const curr_version = linker_args_it.nextOrFatal();2159 const curr_version = linker_args_it.nextOrFatal();
2160 version = std.builtin.Version.parse(curr_version) catch |err| {2160 version = std.SemanticVersion.parse(curr_version) catch |err| {
2161 fatal("unable to parse -current_version '{s}': {s}", .{ curr_version, @errorName(err) });2161 fatal("unable to parse -current_version '{s}': {s}", .{ curr_version, @errorName(err) });
2162 };2162 };
2163 have_version = true;2163 have_version = true;
...@@ -2207,10 +2207,9 @@ fn buildOutputType(...@@ -2207,10 +2207,9 @@ fn buildOutputType(
2207 } else if (mem.startsWith(u8, arg, "/version:")) {2207 } else if (mem.startsWith(u8, arg, "/version:")) {
2208 var split_it = mem.splitBackwardsScalar(u8, arg, ':');2208 var split_it = mem.splitBackwardsScalar(u8, arg, ':');
2209 const version_arg = split_it.first();2209 const version_arg = split_it.first();
2210 version = std.builtin.Version.parse(version_arg) catch |err| {2210 version = std.SemanticVersion.parse(version_arg) catch |err| {
2211 fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });2211 fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });
2212 };2212 };
2213
2214 have_version = true;2213 have_version = true;
2215 } else {2214 } else {
2216 fatal("unsupported linker arg: {s}", .{arg});2215 fatal("unsupported linker arg: {s}", .{arg});
src/target.zig+7-7
...@@ -6,7 +6,7 @@ pub const ArchOsAbi = struct {...@@ -6,7 +6,7 @@ pub const ArchOsAbi = struct {
6 arch: std.Target.Cpu.Arch,6 arch: std.Target.Cpu.Arch,
7 os: std.Target.Os.Tag,7 os: std.Target.Os.Tag,
8 abi: std.Target.Abi,8 abi: std.Target.Abi,
9 os_ver: ?std.builtin.Version = null,9 os_ver: ?std.SemanticVersion = null,
10};10};
1111
12pub const available_libcs = [_]ArchOsAbi{12pub const available_libcs = [_]ArchOsAbi{
...@@ -16,9 +16,9 @@ pub const available_libcs = [_]ArchOsAbi{...@@ -16,9 +16,9 @@ pub const available_libcs = [_]ArchOsAbi{
16 .{ .arch = .aarch64, .os = .linux, .abi = .gnu },16 .{ .arch = .aarch64, .os = .linux, .abi = .gnu },
17 .{ .arch = .aarch64, .os = .linux, .abi = .musl },17 .{ .arch = .aarch64, .os = .linux, .abi = .musl },
18 .{ .arch = .aarch64, .os = .windows, .abi = .gnu },18 .{ .arch = .aarch64, .os = .windows, .abi = .gnu },
19 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0 } },19 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
20 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0 } },20 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
21 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0 } },21 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
22 .{ .arch = .armeb, .os = .linux, .abi = .gnueabi },22 .{ .arch = .armeb, .os = .linux, .abi = .gnueabi },
23 .{ .arch = .armeb, .os = .linux, .abi = .gnueabihf },23 .{ .arch = .armeb, .os = .linux, .abi = .gnueabihf },
24 .{ .arch = .armeb, .os = .linux, .abi = .musleabi },24 .{ .arch = .armeb, .os = .linux, .abi = .musleabi },
...@@ -71,9 +71,9 @@ pub const available_libcs = [_]ArchOsAbi{...@@ -71,9 +71,9 @@ pub const available_libcs = [_]ArchOsAbi{
71 .{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },71 .{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },
72 .{ .arch = .x86_64, .os = .linux, .abi = .musl },72 .{ .arch = .x86_64, .os = .linux, .abi = .musl },
73 .{ .arch = .x86_64, .os = .windows, .abi = .gnu },73 .{ .arch = .x86_64, .os = .windows, .abi = .gnu },
74 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0 } },74 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
75 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0 } },75 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
76 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0 } },76 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
77};77};
7878
79pub fn libCGenericName(target: std.Target) [:0]const u8 {79pub fn libCGenericName(target: std.Target) [:0]const u8 {
test/link/macho/dylib/build.zig+1-1
...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1717
18 const dylib = b.addSharedLibrary(.{18 const dylib = b.addSharedLibrary(.{
19 .name = "a",19 .name = "a",
20 .version = .{ .major = 1, .minor = 0 },20 .version = .{ .major = 1, .minor = 0, .patch = 0 },
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
test/link/macho/needed_library/build.zig+1-1
...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1717
18 const dylib = b.addSharedLibrary(.{18 const dylib = b.addSharedLibrary(.{
19 .name = "a",19 .name = "a",
20 .version = .{ .major = 1, .minor = 0 },20 .version = .{ .major = 1, .minor = 0, .patch = 0 },
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
test/link/macho/search_strategy/build.zig+1-1
...@@ -61,7 +61,7 @@ fn createScenario(...@@ -61,7 +61,7 @@ fn createScenario(
6161
62 const dylib = b.addSharedLibrary(.{62 const dylib = b.addSharedLibrary(.{
63 .name = name,63 .name = name,
64 .version = .{ .major = 1, .minor = 0 },64 .version = .{ .major = 1, .minor = 0, .patch = 0 },
65 .optimize = optimize,65 .optimize = optimize,
66 .target = target,66 .target = target,
67 });67 });
test/link/macho/tls/build.zig+1-1
...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1717
18 const lib = b.addSharedLibrary(.{18 const lib = b.addSharedLibrary(.{
19 .name = "a",19 .name = "a",
20 .version = .{ .major = 1, .minor = 0 },20 .version = .{ .major = 1, .minor = 0, .patch = 0 },
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
test/link/macho/uuid/build.zig+1-1
...@@ -62,7 +62,7 @@ fn simpleDylib(...@@ -62,7 +62,7 @@ fn simpleDylib(
62) *std.Build.Step.Compile {62) *std.Build.Step.Compile {
63 const dylib = b.addSharedLibrary(.{63 const dylib = b.addSharedLibrary(.{
64 .name = "test",64 .name = "test",
65 .version = .{ .major = 1, .minor = 0 },65 .version = .{ .major = 1, .minor = 0, .patch = 0 },
66 .optimize = optimize,66 .optimize = optimize,
67 .target = target,67 .target = target,
68 });68 });
test/standalone/load_dynamic_library/build.zig+1-1
...@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {...@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
13 const lib = b.addSharedLibrary(.{13 const lib = b.addSharedLibrary(.{
14 .name = "add",14 .name = "add",
15 .root_source_file = .{ .path = "add.zig" },15 .root_source_file = .{ .path = "add.zig" },
16 .version = .{ .major = 1, .minor = 0 },16 .version = .{ .major = 1, .minor = 0, .patch = 0 },
17 .optimize = optimize,17 .optimize = optimize,
18 .target = target,18 .target = target,
19 });19 });
test/standalone/shared_library/build.zig+1-1
...@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {...@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
9 const lib = b.addSharedLibrary(.{9 const lib = b.addSharedLibrary(.{
10 .name = "mathtest",10 .name = "mathtest",
11 .root_source_file = .{ .path = "mathtest.zig" },11 .root_source_file = .{ .path = "mathtest.zig" },
12 .version = .{ .major = 1, .minor = 0 },12 .version = .{ .major = 1, .minor = 0, .patch = 0 },
13 .target = target,13 .target = target,
14 .optimize = optimize,14 .optimize = optimize,
15 });15 });
tools/gen_spirv_spec.zig+1-1
...@@ -76,7 +76,7 @@ fn render(writer: anytype, allocator: Allocator, registry: g.CoreRegistry) !void...@@ -76,7 +76,7 @@ fn render(writer: anytype, allocator: Allocator, registry: g.CoreRegistry) !void
76 try writer.writeAll(76 try writer.writeAll(
77 \\//! This file is auto-generated by tools/gen_spirv_spec.zig.77 \\//! This file is auto-generated by tools/gen_spirv_spec.zig.
78 \\78 \\
79 \\const Version = @import("std").builtin.Version;79 \\const Version = @import("std").SemanticVersion;
80 \\80 \\
81 \\pub const Word = u32;81 \\pub const Word = u32;
82 \\pub const IdResult = struct{82 \\pub const IdResult = struct{