aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Target.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-12-13 08:02:15 +0100
committerAlex Rønne Petersen <alex@alexrp.com>2024-12-17 05:04:16 +0100
commit0ef01c552100a8559bec5d17e6778f1cb652d403 (patch)
treea4540fdee4b1fd8d046f85ead98cbb13273f362b /lib/std/Target.zig
parent424f9ba53289ab720c76ae06685168b1bf3f5a59 (diff)
downloadzig-0ef01c552100a8559bec5d17e6778f1cb652d403.tar.gz
zig-0ef01c552100a8559bec5d17e6778f1cb652d403.zip
std.Target: Incorporate the Abi tag in VersionRange.default().
This is necessary to pick out the correct minimum OS version from the std.zig.target.available_libcs list.
Diffstat (limited to 'lib/std/Target.zig')
-rw-r--r--lib/std/Target.zig24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/std/Target.zig b/lib/std/Target.zig
index 476d7a6f8d..95aef4a7c7 100644
--- a/lib/std/Target.zig
+++ b/lib/std/Target.zig
@@ -148,10 +148,10 @@ pub const Os = struct {
return (tag == .hurd or tag == .linux) and abi.isGnu();
}
- pub fn defaultVersionRange(tag: Tag, arch: Cpu.Arch) Os {
+ pub fn defaultVersionRange(tag: Tag, arch: Cpu.Arch, abi: Abi) Os {
return .{
.tag = tag,
- .version_range = VersionRange.default(tag, arch),
+ .version_range = .default(arch, tag, abi),
};
}
@@ -416,7 +416,7 @@ pub const Os = struct {
/// The default `VersionRange` represents the range that the Zig Standard Library
/// bases its abstractions on.
- pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange {
+ pub fn default(arch: Cpu.Arch, tag: Tag, abi: Abi) VersionRange {
return switch (tag) {
.freestanding,
.other,
@@ -475,16 +475,26 @@ pub const Os = struct {
.linux => .{
.linux = .{
.range = .{
- .min = .{ .major = 4, .minor = 19, .patch = 0 },
+ .min = blk: {
+ const default_min: std.SemanticVersion = .{ .major = 4, .minor = 19, .patch = 0 };
+
+ for (std.zig.target.available_libcs) |libc| {
+ if (libc.arch != arch or libc.os != tag or libc.abi != abi) continue;
+
+ if (libc.os_ver) |min| {
+ if (min.order(default_min) == .gt) break :blk min;
+ }
+ }
+
+ break :blk default_min;
+ },
.max = .{ .major = 6, .minor = 11, .patch = 5 },
},
.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.os != tag or libc.arch != arch or libc.abi != abi) continue;
if (libc.glibc_min) |min| {
if (min.order(default_min) == .gt) break :blk min;