Skip to content

windows: stage native Windows support on latest main - #172

Closed
cpunion wants to merge 342 commits into
mainfrom
codex/windows-review-fixes-20260823
Closed

cpunion wants to merge 342 commits into
mainfrom
codex/windows-review-fixes-20260823

Conversation

@cpunion

@cpunion cpunion commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Purpose

This draft is the complete native-Windows integration snapshot rebased onto xgo-dev/llgo main at daef162f1a64c460d0f3681c562f645612a388e8. It supersedes the closed #169 and is retained only as a validation/reference branch while the implementation is reconstructed into reviewable PRs. It is not intended to be merged as one PR.

Related proposal: xgo-dev#2325.

The new PRs will use the final integrated behavior rather than blindly cherry-picking historical commits. In particular, commits that mix concerns or revise an earlier approach will not be picked whole. Each PR will be reconstructed from the smallest coherent final file/function/hunk set so that superseded implementations and unrelated changes do not leak across review boundaries.

Planned dependency order

  1. windows: scope LLVM 19 host flags to the binding package xgo-dev/llvm#49: keep Windows LLVM 19 host flags package-local (existing external prerequisite).
  2. LLGo target and portable host-tool foundation: MSVC triples, typed architecture features/cache inputs, Windows-safe metadata mapping, file locking, paths, and tool discovery.
  3. PE/COFF and MSVC compiler/build layer: COMDAT and imports, MSVC C ABI, Plan 9 assembly consumption, linker/archive handling, and executable/C archive/C shared build modes.
  4. Two branches can then proceed from the compiler/build layer:
    • hosted runtime substrate: Win32 threads, TLS/FLS, synchronization, stdio/OS primitives, lifecycle, and BDWGC registration;
    • Windows-host cross-compilation and embedded tooling: target/host separation, response files, native archive extraction, SDK/sysroot inputs, and ESP/WASI tooling.
  5. Runtime execution ABI: SyscallN, FFI and callbacks, foreign-thread entry, faults, SEH/unwind, PC metadata, traceback, and profiling.
  6. Windows standard-library integration: files/processes, signals, testing hooks, IOCP/networking, users, and OS behavior. The required goplus/lib Windows CRT/WinSock and pthread/synchronization changes will be upstreamed as their own prerequisite PRs before this layer.
  7. Final validation: shared Linux/macOS/Windows CI matrices, stdlib coverage, GOROOT, demos, build cache, benchmarks, and release qualification.

Generic receiver-metadata and concurrent-output-parser fixes, if still needed, will be independent non-blocking PRs. Linux poller changes, macOS timing/xfail changes, generic converthash, broad timing relaxations, and the old large-aggregate lowering are excluded from the Windows series unless independently justified and tested.

Only the foundation prerequisite is advanced for review first. Later layers will not be submitted until their direct base has been reviewed and merged.

Rebase notes

  • Replayed the integration history onto the latest upstream main and resolved the ESP download/file-lock and historical Plan 9 dependency overlaps.
  • Kept the released github.com/xgo-dev/plan9asm v0.5.0; no temporary plan9asm replacement remains.
  • Removed the old generic large-aggregate lowering from this snapshot because it regressed the latest main static-initialization contract and is not required by the first Windows milestone.
  • Retained the existing temporary cpunion/lib and cpunion/llvm replacements only in this integration snapshot. Reviewable LLGo PRs must consume upstreamed/released dependencies at the appropriate layer.

Validation

  • go test ./internal/xtool/llvm ./internal/goarch ./internal/meta ./internal/crosscompile ./internal/cabi ./internal/build
  • go test ./cl -run '^TestStaticGlobalInitSkipsLargeByteSlice$' -count=1
  • go test ./cl -run '^TestRunAndTestFromTestrt/any$' -count=1 -timeout=3m -v
  • The first full go test ./cl exposed the stale large-aggregate interaction; after removing it, a 20-minute run reached only six LTO output mismatches caused by the local LLVM 19 warning that RISC-V +zcm/+zcz are unrecognized. The targeted LTO command produces the same warnings and failures on a clean checkout of the exact main base commit, so they are not introduced by this branch.
  • Fresh CI and three-platform GOROOT validation are required for the rebased head. The earlier all-green CI and GOROOT run remain evidence for the pre-rebase integration snapshot only.

@cpunion cpunion added the windows Windows platform support label Aug 23, 2026
@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

LLGo baseline benchmarks

cf155a435101 | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Build vs base Run vs base
Linux cprintf 19592 B 0 B / +0.0% 362.596 ms -12.05 ms / -3.2% (better) 1.307 ms +7.935 us / +0.6% (worse)
Linux cprintf-lto 19424 B 0 B / +0.0% 358.651 ms +5.696 ms / +1.6% (worse) 1.301 ms +7.503 us / +0.6% (worse)
Linux fmtprintf 1871960 B 0 B / +0.0% 3.013 s -10.59 ms / -0.4% (better) 3.292 ms -219.4 us / -6.2% (better)
Linux fmtprintf-lto 1784488 B 0 B / +0.0% 14.840 s -101.3 ms / -0.7% (better) 3.271 ms +64.58 us / +2.0% (worse)
Linux println 69192 B 0 B / +0.0% 353.034 ms -8.51 ms / -2.4% (better) 1.632 ms -33.44 us / -2.0% (better)
Linux println-lto 62912 B 0 B / +0.0% 579.845 ms +9.738 ms / +1.7% (worse) 1.674 ms -3.628 us / -0.2% (better)
macOS cprintf 84672 B 0 B / +0.0% 546.870 ms -106.8 ms / -16.3% (better) 4.474 ms -820.4 us / -15.5% (better)
macOS cprintf-lto 100912 B 0 B / +0.0% 552.090 ms +32.49 ms / +6.3% (worse) 3.930 ms -525.2 us / -11.8% (better)
macOS fmtprintf 1909424 B 0 B / +0.0% 2.433 s -1.339 s / -35.5% (better) 11.759 ms -2.365 ms / -16.7% (better)
macOS fmtprintf-lto 1626272 B 0 B / +0.0% 19.760 s -7.046 s / -26.3% (better) 5.854 ms -4.801 ms / -45.1% (better)
macOS println 121360 B 0 B / +0.0% 512.853 ms -162.3 ms / -24.0% (better) 5.152 ms -456.4 us / -8.1% (better)
macOS println-lto 128528 B 0 B / +0.0% 604.681 ms -415.1 ms / -40.7% (better) 4.334 ms -2.801 ms / -39.3% (better)
Windows cprintf 119808 B 0 B / +0.0% 798.840 ms -65.37 ms / -7.6% (better) 3.345 ms -106.4 us / -3.1% (better)
Windows cprintf-lto 119296 B 0 B / +0.0% 834.330 ms -45.45 ms / -5.2% (better) 3.360 ms -749.2 us / -18.2% (better)
Windows fmtprintf 1827328 B +6144 B / +0.3% (worse) 5.400 s +134 ms / +2.5% (worse) 8.662 ms +266.1 us / +3.2% (worse)
Windows fmtprintf-lto 1926144 B +5120 B / +0.3% (worse) 17.122 s +349.4 ms / +2.1% (worse) 8.446 ms -572.5 us / -6.3% (better)
Windows println 202240 B +3584 B / +1.8% (worse) 839.672 ms -38.95 ms / -4.4% (better) 6.767 ms -1.238 ms / -15.5% (better)
Windows println-lto 200704 B +3584 B / +1.8% (worse) 1.042 s -71.77 ms / -6.4% (better) 6.734 ms -1.202 ms / -15.1% (better)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 13.140 ns/op -0.23 ns/op / -1.7% (better)
Linux BenchmarkMergeCompilerFlags 154.900 ns/op +2.6 ns/op / +1.7% (worse)
Linux BenchmarkMergeLinkerFlags 96.090 ns/op +0.05 ns/op / +0.1% (worse)
Linux BenchmarkChannelBuffered 34.930 ns/op +0.02 ns/op / +0.1% (worse)
Linux BenchmarkChannelHandoff 28261 ns/op +786 ns/op / +2.9% (worse)
Linux BenchmarkDefer 45.150 ns/op +0.04 ns/op / +0.1% (worse)
Linux BenchmarkDirectCall 1.557 ns/op 0 ns/op / +0.0%
Linux BenchmarkGlobalRead 1.557 ns/op -0.002 ns/op / -0.1% (better)
Linux BenchmarkGlobalWrite 2.488 ns/op 0 ns/op / +0.0%
Linux BenchmarkGoroutine 41122 ns/op +8057 ns/op / +24.4% (worse)
Linux BenchmarkInterfaceCall 7.789 ns/op +0.001 ns/op / +0.01284% (worse)
Linux BenchmarkRuntimeGetG 2.495 ns/op +0.004 ns/op / +0.2% (worse)
macOS BenchmarkLookupPCRandom 11.410 ns/op -2.99 ns/op / -20.8% (better)
macOS BenchmarkMergeCompilerFlags 105 ns/op -60.5 ns/op / -36.6% (better)
macOS BenchmarkMergeLinkerFlags 70.540 ns/op -30.26 ns/op / -30.0% (better)
macOS BenchmarkChannelBuffered 22.530 ns/op -2.9 ns/op / -11.4% (better)
macOS BenchmarkChannelHandoff 6941 ns/op -1116 ns/op / -13.9% (better)
macOS BenchmarkDefer 31.220 ns/op +2.71 ns/op / +9.5% (worse)
macOS BenchmarkDirectCall 1.087 ns/op +0.023 ns/op / +2.2% (worse)
macOS BenchmarkGlobalRead 1.090 ns/op -0.374 ns/op / -25.5% (better)
macOS BenchmarkGlobalWrite 1.229 ns/op +0.047 ns/op / +4.0% (worse)
macOS BenchmarkGoroutine 28098 ns/op -23258 ns/op / -45.3% (better)
macOS BenchmarkInterfaceCall 5.148 ns/op +0.262 ns/op / +5.4% (worse)
macOS BenchmarkRuntimeGetG 2.048 ns/op -0.249 ns/op / -10.8% (better)
Windows BenchmarkLookupPCRandom 15.970 ns/op -0.05 ns/op / -0.3% (better)
Windows BenchmarkMergeCompilerFlags 603.200 ns/op -20.2 ns/op / -3.2% (better)
Windows BenchmarkMergeLinkerFlags 523.200 ns/op -4.1 ns/op / -0.8% (better)
Windows BenchmarkChannelBuffered 33.640 ns/op -0.12 ns/op / -0.4% (better)
Windows BenchmarkChannelHandoff 789.200 ns/op -81.3 ns/op / -9.3% (better)
Windows BenchmarkDefer 53.350 ns/op -0.66 ns/op / -1.2% (better)
Windows BenchmarkDirectCall 1.550 ns/op +0.001 ns/op / +0.1% (worse)
Windows BenchmarkGlobalRead 1.548 ns/op -0.015 ns/op / -1.0% (better)
Windows BenchmarkGlobalWrite 2.469 ns/op -0.006 ns/op / -0.2% (better)
Windows BenchmarkGoroutine 89582 ns/op -7125 ns/op / -7.4% (better)
Windows BenchmarkInterfaceCall 9.037 ns/op -0.045 ns/op / -0.5% (better)
Windows BenchmarkRuntimeGetG 1.863 ns/op -0.312 ns/op / -14.3% (better)

Compared with 7e11371113c8 measured in the same runner job.

@cpunion cpunion changed the title windows: align hosted runtime semantics after integration audit windows: align hosted runtime semantics (depends on #169) Aug 23, 2026
cpunion added 26 commits August 24, 2026 10:18
This reverts commit 1fcff48b9481b74ca2b5fcfbf6cf2678f4c96833.
This reverts commit 405a5d6998c4c07069b0d4a89999a08aacde3a7f.
@cpunion
cpunion force-pushed the codex/windows-review-fixes-20260823 branch from cf155a4 to 730c1ea Compare August 24, 2026 02:29
@cpunion cpunion changed the title windows: align hosted runtime semantics (depends on #169) windows: stage native Windows support on latest main Aug 24, 2026
@cpunion
cpunion changed the base branch from codex/windows-proposal-integration-20260818 to main August 24, 2026 02:29
@cpunion cpunion closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

windows Windows platform support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant