Cross-compiling to windows causes .isAtLeast(.win10_rs4) to return null

I’m trying to cross-compile from Linux (NixOS) to Windows 10. The program is a server using a Unix socket. Everything compiles fine, but when running on Wine or Windows 10, I get the error error.AddressFamilyUnsupported , which is caused by the fact that this check ends up being false.

pub const has_unix_sockets = switch (native_os) {
    .windows => builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false,
    .wasi => false,
    else => true,
};

Is there a way to force the minimum version of Windows to be the supported one?
Zig version 0.16 and the build command is zig build -Dtarget=x86_64-windows

1 Like

You can set the minimum version like so:

-Dtarget=x86_64-windows.win10_rs4

This will give you the range win10_rs4...win11_kr. You can also specify the range explicitly:

-Dtarget=x86_64-windows.win10_rs4...win10_cu

The available versions are here. The default is set here. Might make sense to update the default minimum version to .win10_rs4.

4 Likes