Skip to content

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

@alexrp

Description

@alexrp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsos-linuxLinuxstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions