Skip to content

[Fix] zig: the Windows target builds again (timespec, socket and nap) - #1193

Closed
cshintov wants to merge 1 commit into
ashhart:mainfrom
cshintov:fix/zig-windows-timespec
Closed

cshintov wants to merge 1 commit into
ashhart:mainfrom
cshintov:fix/zig-windows-timespec

Conversation

@cshintov

Copy link
Copy Markdown
Contributor

What this changes

zig-windows fails on current main (e658ac9) with three compile errors, all the same theme: Zig 0.17.0's std.c.timespec is void on Windows and its CRT has no nanosleep, so a POSIX-only construct is instantiated for x86_64-windows.

This carries the three remaining sites. digest_key.zig and speech.zig were fixed in 1.1.2 (61270ca, 476e16d) and #1129 was closed as superseded; these three were not.

Error on Windows Fix
cuda/roce.zig:456 — expected type 'void', found 'comptime_int' on the proxy's 20 us nap literal the nap becomes napTimespec(), which returns null where std.c.timespec is void; the spin loop skips the sleep there
tests/cuda/exl3_tp2_tests.zig:344 — expected integer or vector, found '*anyopaque' on @intCast(socket()) serve/receive return before the fd cast on Windows: socket() hands back SOCKET (usize) there, and this test is a CUDA NCCL run that never executes on Windows
tests/cuda/flashnext_rank_tests.zig:48 — same timespec literal for the injected 0.6 s delay the delay moves behind the same Windows guard

No POSIX behaviour change: off Windows napTimespec() returns the identical 20 us timespec and the proxy makes the identical nanosleep call.

Receipt

  • Before: on e658ac9, zig build -Dtarget=x86_64-windows → 3 compile errors in tf-cuda-test, Build Summary: 18/21 steps succeeded (1 failed).
  • After (this branch): same command → exit 0, tensorfold.exe, tf-cuda-test.exe, tf-qwen35-cuda.exe, tf-qwen35-learn.exe, tf-tp-watch-check.exe all produced.
  • zig build test -Dtarget=x86_64-windows → zero compile errors; the run steps refuse with "host cannot execute windows binaries", as expected off Windows.
  • zig build -Dtarget=x86_64-linux → clean.
  • Host zig build test on macOS → 102 failures before this branch and 102 after, all xcrun: unable to find utility "metal" (this machine has no Metal toolchain). No non-Metal errors either way.

Caveat: nothing here was executed on Windows. Compile-correctness is proven; runtime behaviour of the guarded paths is not, and the CI zig-windows job is where that gets checked.

Zig 0.17.0's std.c.timespec is void on Windows and its CRT has no nanosleep,
so three call sites fail to compile for x86_64-windows on current main:

- cuda/roce.zig:456 builds a timespec literal for the proxy's 20 us nap.
- tests/cuda/exl3_tp2_tests.zig:344 casts socket()'s result to a fd.
- tests/cuda/flashnext_rank_tests.zig:48 builds a 0.6 s timespec delay.

The nap becomes a helper that returns null where the timespec is void; the
socket test helpers return before the fd cast on Windows (socket() returns
SOCKET there, and the test is a CUDA NCCL run); the rank test's delay moves
behind the same guard. No POSIX behaviour change: the nap helper returns the
same 20 us timespec and the same nanosleep call off Windows.
@cshintov

Copy link
Copy Markdown
Contributor Author

On the zig-windows failure on this PR: it is not this branch's code. It is a pre-existing breakage on main (d1018b31 → e658ac9), which I confirmed by reproducing it on an unmodified main clone.

zig build -Dtarget=x86_64-windows on main fails with three compile errors, all the same cause: Zig 0.17.0's std.c.timespec is void on Windows and its CRT has no nanosleep, so a POSIX-only construct is instantiated for the Windows target.

  • cuda/roce.zig:456 — the proxy's 20 us nap builds a timespec literal
  • tests/cuda/exl3_tp2_tests.zig:344 — @intCast(socket()), where Windows returns SOCKET (usize)
  • tests/cuda/flashnext_rank_tests.zig:48 — the injected 0.6 s delay builds a timespec literal

None of these files are touched by this PR (git diff --name-only d1018b31...69c412d has no overlap). Every branch's No GPU run fails the same job, so it is not specific to this branch.

#1193 carries the three fixes against main, and its zig-windows job passes (8m58s). digest_key.zig and speech.zig were already fixed in 1.1.2, so those are not part of it.

Once #1193 lands, rebasing this branch onto the new main should turn zig-windows green here with no change to this PR's own files.

ashhart added a commit that referenced this pull request Oct 22, 2026
… request

The helper switched over @typeof(std.c.timespec), which is type, so it returned
null on every host and turned the RoCE proxy's 20 us nap off on POSIX too. The nap
now lives in roce_nap.zig, inspects the timespec type itself and is absent only on
Windows. Two CPU tests cover the POSIX request and its single sleeper call, and an
absent request that calls nothing. roce.zig stays under 600 lines and the rank
test's delay keeps a one-line comment.
@ashhart

ashhart commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thank you, @cshintov. This is on main now. Your commit landed as you wrote it (193e955), recorded under your GitHub noreply address so your personal address stays out of the public history. One maintainer commit follows, e67ece3. Your nap helper switched over @TypeOf(std.c.timespec), which is type, so it returned null on every host and the RoCE proxy stopped napping on Linux too. The fix-up moves the nap into roce_nap.zig, keeps it on POSIX, leaves it out only on Windows, and adds two CPU tests for both cases. It also keeps roce.zig under our 600-line limit. It ships in the next release.

  • Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 22, 2026
@cshintov

Copy link
Copy Markdown
Contributor Author

On the zig job failure: it is pre-existing on main, not this branch.

main at 1705bf5 (2026-10-23T09:41Z, run 39933664536) fails its own no-gpu run, and its zig-windows job fails with the same set this PR's zig job fails:

  • FAIL kernel-contract: unknown image name: for GLM_GLUE, contract_control, glm_glu, unknown_image, and the empty name
  • FAIL CPU reference comparison: non-finite error at element N (got nan/-nan/inf/-inf, reference 0e0, tolerance 1e0)
  • FAIL no-op projection: non-finite error at element 0 (got -nan, ...)

Those lines come from zig/tests/cuda/contract_tests.zig and zig/tests/cuda/quant_ref_host_tests.zig. Both files are byte-identical between this PR's base e658ac9 and current main 1705bf5 (git diff e658ac9..1705bf5 over those paths is empty), and this PR touches neither. The diff is three files: zig/src/cuda/roce.zig, zig/tests/cuda/exl3_tp2_tests.zig, zig/tests/cuda/flashnext_rank_tests.zig.

The two runs use different seeds (0xc2e0b03 here, 0x703ea712 on main), so this is not one flaky seed. It looks like numeric reference drift in the CPU/kernel-contract tests on the Linux runner, independent of the Windows build.

What this PR does fix is the Windows compile: zig-windows passes here (8m58s) and main at e658ac9 could not compile it at all. Worth noting main at 1705bf5 also fails zig-windows, but on tests rather than compilation (3227/3290 tests passed, 1 failed), so the compile fix and the test failures are separate problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants