Skip to content

Windows: pin .wi fixtures to LF + define __std*p via __acrt_iob_func - #1029

Closed
ropoctl wants to merge 2 commits into
fix-darwin-stdio-globals-glibcfrom
fix-windows-bundle-pcre2-stdio
Closed

ropoctl wants to merge 2 commits into
fix-darwin-stdio-globals-glibcfrom
fix-windows-bundle-pcre2-stdio

Conversation

@ropoctl

@ropoctl ropoctl commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the two remaining Windows-only reds in the pcre2/bundle-interface red wave,
on both Windows lanes (x86_64 and aarch64). Stacked on #1016.

  • bundle-interface-tests — CRLF on an unpinned .wi fixture.
  • pcre2-wo-drift — the Darwin-migrated stdio globals __std{in,out,err}p
    have no producer on Windows.

Both are architecture-independent: they fail identically on windows-x86_64 and
windows-aarch64, and pass on Linux and macOS.

Rung D — pin .wi interface fixtures to LF

test/bundle_interface/*.wi fixtures are compared byte-for-byte against the
compiler's freshly-emitted interface. Under core.autocrlf=true (GitHub's
Windows runners' default) a native Windows checkout rewrites the checked-in
fixture's LF to CRLF, so every read line carries a trailing \r the emitted (LF)
interface never has — the byte-exact comparison then fails on every line and reds
bundle-interface-tests on Windows only.

The .wi fixtures were simply never covered by an eol=lf attribute, unlike
*.w and docs/with-abi.sha256 (#942). Fix: add *.wi text eol=lf to
.gitattributes. No .wi blob has CRLF today, so the pin is a no-op on
Linux/mac and only corrects the Windows checkout. Same class as #942.

Rung E — define __std{in,out,err}p on Windows backends

The pcre2test.w .wo corpus harness is migrated once from the host's
preprocessed C and checked in for every platform. It was migrated on Darwin,
whose <stdio.h> does #define stderr __stderrp (also __stdoutp / __stdinp),
so the checked-in harness references the bare symbols __stdinp / __stdoutp /
__stderrp (91 sites). Windows/UCRT has neither those symbols nor
stdin/stdout/stderr global variables — the FILE* streams come from
__acrt_iob_func(0/1/2) — so on Windows those three symbols had no producer
and the harness link failed. #1016 fixed the same class for glibc; this is its
Windows twin.

Fix mirrors the glibc analogue now in rt/linux_x86_64.w and the existing
__error / __open darwin-compat precedent:

  • rt/windows_x86_64.w, rt/windows_aarch64.w: declare
    extern fn __acrt_iob_func(index: u32), define pub var __stdinp / __stdoutp / __stderrp, and bind them to __acrt_iob_func(0/1/2) in rt_store_args, the
    guaranteed pre-main entry hook.
  • No src/FnAbi.w change: codegen_is_runtime_abi_symbol already whitelists
    the three names (added with the glibc fix in rt: define Darwin stdio globals (__std{in,out,err}p) on non-Darwin backends #1016) and
    codegen_is_runtime_source_file already matches rt/ and rt\ paths, so the
    pub var definitions keep their bare link names in module-object mode and
    satisfy the harness's bare references. docs/with-abi.sha256 is therefore
    unchanged and no bundle re-keys.

No platform gate, no skip: the Darwin-spelled globals now resolve on every target.

Verification

  • Rung D: git check-attr text eol -- test/bundle_interface/wi_demo.wi →
    text: set / eol: lf; no .wi blob contains CRLF.
  • Rung E: cross-emitted rt/windows_x86_64.w to a COFF object; nm shows
    __stdinp / __stdoutp / __stderrp as bare BSS symbols, __acrt_iob_func
    as an undefined UCRT import, and rt_store_args (the binder) defined. The
    edits are structurally identical for aarch64.
  • Host (Linux/mac) build/fixpoint are unaffected by construction: neither
    .gitattributes nor rt/windows_*.w is compiled into the host compiler.

test/bundle_interface/*.wi fixtures are compared byte-for-byte against the
compiler's freshly-emitted interface. Under core.autocrlf=true (GitHub's
Windows runners' default) a native Windows checkout rewrites the checked-in
fixture's LF to CRLF, so every read line carries a trailing "\r" the emitted
(LF) interface never has -- the byte-exact comparison then fails on every line
and reds bundle-interface-tests on Windows only, while it passes on Linux/mac.

Root cause: the .wi fixtures were never covered by an eol=lf attribute, unlike
*.w and docs/with-abi.sha256 (#942). Pin *.wi text eol=lf so the checked-out
fixture bytes match emitted output on every platform. No CRLF exists in any .wi
blob today, so the pin is a no-op on Linux/mac and only corrects the Windows
checkout.
The pcre2test.w .wo corpus harness is migrated once from the host's
preprocessed C and checked in for every platform. It was migrated on Darwin,
whose <stdio.h> does `#define stderr __stderrp` (also __stdoutp / __stdinp), so
the checked-in harness references the bare symbols __stdinp / __stdoutp /
__stderrp (91 sites). Windows/UCRT has neither those symbols nor
stdin/stdout/stderr global variables -- the FILE* streams come from
__acrt_iob_func(0/1/2) -- so on Windows those three symbols had no producer and
the pcre2-wo-drift lane failed to link the harness. Red on both Windows lanes
(x86_64 and aarch64), green on Darwin and (after the glibc fix) Linux.

Root cause: the Darwin-spelled stdio globals have no producer on Windows.

Fix mirrors the glibc analogue already in rt/linux_x86_64.w and the existing
__error / __open darwin-compat precedent: rt/windows_x86_64.w and
rt/windows_aarch64.w declare `extern fn __acrt_iob_func(index: u32)`, define
`pub var __stdinp / __stdoutp / __stderrp`, and bind them to
__acrt_iob_func(0/1/2) in rt_store_args, the guaranteed pre-main entry hook.

codegen_is_runtime_abi_symbol (src/FnAbi.w) already whitelists the three names
(added with the glibc fix) and codegen_is_runtime_source_file already matches
rt/ and rt\ paths, so the `pub var` definitions keep their bare link names in
module-object mode and satisfy the harness's bare references. No FnAbi.w change,
so docs/with-abi.sha256 is unchanged and no bundle re-keys.

Verified by cross-emitting rt/windows_x86_64.w to a COFF object: nm shows
__stdinp / __stdoutp / __stderrp as bare BSS symbols, __acrt_iob_func as an
undefined UCRT import, and rt_store_args (the binder) defined. No platform gate,
no skip.
@ropoctl
ropoctl force-pushed the fix-windows-bundle-pcre2-stdio branch from 1656cb7 to c8b0c36 Compare September 4, 2026 11:04
ehartford pushed a commit that referenced this pull request Sep 5, 2026
…dows stays at v0.15.1.8 (#1029)

v0.15.1.10 (release run 33924828956) is the v0.15.1.9 tree plus the
build-runner retry and the evaluator-friendly .wo action hash, built from
the v0.15.1.8 seeds; linux-aarch64 bootstrapped for the first time since
C3 (#1074 closed). Both Windows jobs failed in the pcre2 bundle build on
the Darwin stdio globals (#1029), so the Windows pins keep their v0.15.1.8
override and those lanes stay red until that lands. `with build
:seed-compat` is green against v0.15.1.10 (stage1 of the tree copy).
@ehartford

Copy link
Copy Markdown
Contributor

Landed in Rob's batch on main (commits 6b338ca/46d00a35: __std{in,out,err}p on non-Darwin and Windows backends; 130630e pins .wi fixtures to LF). Verified on the Linux lanes; the Windows pcre2-wo-build still fails, but on a different cause now visible via #1035: 'missing Windows LLVM linker metadata' (#1075), not the stdio globals. Closing the stdio-globals/CRLF part here; the remaining Windows red is tracked in #1075.

@ehartford

Copy link
Copy Markdown
Contributor

Landed on main via cherry-pick under new hashes: 80fa7fe (gitattributes: pin .wi interface fixtures to LF) and 72e7355 (rt: define Darwin stdio globals on Windows backends). Closing as merged-by-content; original SHAs differ because it was cherry-picked, not merged. Note: the Windows self-host lane is still red, but on a different, deeper cause now — #1081 (compiler invalid free panic building the pcre2 .wo bundle, native-Windows only), not the stdio globals or CRLF this PR fixed.

@ehartford ehartford closed this Sep 6, 2026
@ehartford
ehartford deleted the fix-windows-bundle-pcre2-stdio branch September 24, 2026 16:56
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