Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's unclear which minimum Linux kernel version the Zig standard library actually supports #20423

Open
alexrp opened this issue Jun 26, 2024 · 0 comments
Labels
docs os-linux standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@alexrp
Copy link
Sponsor Contributor

alexrp commented Jun 26, 2024

zig/lib/std/Target.zig

Lines 369 to 370 in 3e9ab6a

/// The default `VersionRange` represents the range that the Zig Standard Library
/// bases its abstractions on.

zig/lib/std/Target.zig

Lines 486 to 494 in 3e9ab6a

.linux => .{
.linux = .{
.range = .{
.min = .{ .major = 4, .minor = 19, .patch = 0 },
.max = .{ .major = 6, .minor = 5, .patch = 7 },
},
.glibc = .{ .major = 2, .minor = 28, .patch = 0 },
},
},

Yet the release notes say Linux 3.16+.

Mainly bringing this up because I came across this code:

zig/lib/std/fs/File.zig

Lines 1020 to 1037 in 3e9ab6a

// NOSYS happens when `statx` is unsupported, which is the case on kernel versions before 4.11
// Here, we call `fstat` and fill `stx` with the data we need
.NOSYS => {
const st = try posix.fstat(self.handle);
stx.mode = @as(u16, @intCast(st.mode));
// Hacky conversion from timespec to statx_timestamp
stx.atime = std.mem.zeroes(l.statx_timestamp);
stx.atime.tv_sec = st.atim.tv_sec;
stx.atime.tv_nsec = @as(u32, @intCast(st.atim.tv_nsec)); // Guaranteed to succeed (tv_nsec is always below 10^9)
stx.mtime = std.mem.zeroes(l.statx_timestamp);
stx.mtime.tv_sec = st.mtim.tv_sec;
stx.mtime.tv_nsec = @as(u32, @intCast(st.mtim.tv_nsec));
stx.mask = l.STATX_BASIC_STATS | l.STATX_MTIME;
},

And:

man statx|grep 'was added'
       statx() was added in Linux 4.11; library support was added in glibc 2.28.
@mlugg mlugg added standard library This issue involves writing Zig code for the standard library. os-linux docs labels Jun 26, 2024
@Vexu Vexu added this to the 0.14.0 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs os-linux standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

3 participants