Skip to content

relay: hostname resolution does not build on Windows #59

Description

@sepehr-safari

relay.dial resolves hostnames through libc getaddrinfo (src/relay.zig), which Zig 0.16 does not declare for Windows. Any Windows build of a dependent fails to compile:

error: root source file struct 'os.windows.ws2_32' has no member named 'addrinfo'

Reproduce with a cross-compile from any host:

zig build -Dtarget=x86_64-windows

Found by adding Linux and Windows builds to a dependent's CI. Linux builds and tests the whole stack cleanly; only Windows is affected.

Background

The direct getaddrinfo call was deliberate: it fixed dials hanging forever on macOS, where /etc/resolv.conf is empty and the standard library's own resolver fell back to a dead nameserver. That reasoning still holds for POSIX, so the fix is to keep this path there and give Windows its own.

Options

  1. Select the resolver at comptime: keep getaddrinfo on POSIX and use std.net's resolver (or GetAddrInfoW via ws2_32) on Windows.
  2. Declare the missing addrinfo bindings for Windows locally rather than relying on std.c.

The first keeps the macOS fix intact and confines the platform difference to one function.

No urgency from my side: Windows is a later target, and its CI job is reporting rather than blocking until this lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions