Skip to content

[depends on #2338] os, runtime: enable native Windows filesystem and process exit - #2340

Open
cpunion wants to merge 84 commits into
xgo-dev:mainfrom
cpunion:llgo-agy-windows-stdlib-os-20260817
Open

[depends on #2338] os, runtime: enable native Windows filesystem and process exit#2340
cpunion wants to merge 84 commits into
xgo-dev:mainfrom
cpunion:llgo-agy-windows-stdlib-os-20260817

Conversation

@cpunion

@cpunion cpunion commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Depends on #2338.

Part of #2325.

Summary

  • reuse Go 1.26's native Windows os, syscall, filepath, and internal/poll implementations by supplying the remaining LLGo runtime boundary
  • implement syscall.Getpagesize through GetSystemInfo and syscall.Exit through ExitProcess
  • provide the complete internal/poll linkname surface while explicitly reporting ERROR_NOT_SUPPORTED until the scheduler-integrated IOCP stage lands
  • keep ordinary files on the standard library's blocking/event fallback and leave network polling explicitly unavailable rather than exposing a non-waking poll context
  • exercise arguments, PID/executable lookup, working directories, stat, temporary directories, blocking and overlapped/event-fallback file I/O, directory reads, environment updates, UTF-16 helpers, Unicode paths, and process exit status

Scope

This is the filesystem and process-exit stage of the Windows proposal. It depends only on the native runtime core in #2338 and is independent of the callback work in #2352.

The PR does not copy or replace the Windows standard library. The behavior remains in the pinned Go 1.26 sources; LLGo only supplies the runtime symbols those sources expect. Scheduler-integrated IOCP, sockets/networking, child-process creation, console handling, and broader GOROOT qualification remain separate stages.

Validation

On macOS ARM64 with Go 1.26.5 and LLVM 19:

  • the rebased six-commit series is patch-identical to the previously reviewed local branch according to git range-diff
  • gofmt and git diff --check pass
  • LLVM 19 parses the Windows runtime C bridge for i686, x86_64, and aarch64 MSVC triples
  • go test -count=1 ./internal/ffi ./internal/lib/runtime passes from the runtime module

On a native Windows 11 ARM64 VM with Go 1.26.5, MSVC Build Tools, and LLVM 19.1.7:

  • metadata, architecture, LLVM, build, cross-compilation, SSA, and complete C ABI tests pass (internal/cabi: 439.291 seconds from a cold build/cache directory)
  • the native ARM64 LLGo host compiler builds and reports llgo (devel) windows/arm64
  • runtime, fault traceback, standard-library OS, and FFI smoke programs pass
  • the standard-library smoke, including overlapped file read/write through the non-IOCP event fallback, passes 20/20 consecutive runs
  • the separate process-exit invocation returns the requested status 23
  • PE import inspection finds no msys-2.0.dll, cygwin1.dll, or libwinpthread dependency in the standard-library smoke or its libuv-1.dll dependency

GitHub CI and Codecov results will be recorded after the PR is opened.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Reviewed the full diff (base 7f954d6...head 4fd4c72) across four dimensions — code quality, performance, security, and documentation accuracy. This is a large, well-constructed PR adding Windows support to the llgo runtime and build pipeline (cabi MSVC, crosscompile, goarch config, Windows threads/sync/setjmp/TLS/fault handling, SEH unwinding, os/syscall shims, and smoke tests).

Overall: strong. No blocking issues. Build-tag/file-suffix partitioning (_windows_386/_amd64/_arm64 vs _default/_unix) is internally consistent and mutually exclusive; platformFaultCallers/platformCallers and the sync API are defined exactly once per build configuration; the mmap'd meta parser now bounds-validates untrusted file bytes; the variable-arity syscall bridge is bounded (windowsSyscallMaxArgs = 42) to match the fixed asm stack reservation; and C wrappers pair Heap allocations with frees on all error paths. Performance-sensitive paths (native SRW/CONDITION_VARIABLE-backed sync, cached QueryPerformanceFrequency, SEH unwinding only on panic/fault paths) look sound. The CI windows.yml is safe by construction (pull_request, permissions: contents: read, no untrusted ${{ }} interpolation into run: steps).

A few low-severity notes are inline below.

Comment thread runtime/internal/lib/reflect/value.go
Comment thread runtime/internal/clite/ffi/abi_windows_arm64.go
Comment thread runtime/internal/lib/runtime/fault_windows_llgo.go
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.19928% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/build/cgo_pragmas.go 84.31% 4 Missing and 4 partials ⚠️
internal/crosscompile/crosscompile.go 96.93% 2 Missing and 1 partial ⚠️
internal/build/build.go 96.82% 1 Missing and 1 partial ⚠️
ssa/eh.go 96.49% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

6f0dcc98d96e | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Build vs base Run vs base
Linux cprintf 19464 B +0.4% (worse) 338.715 ms +15.3% (worse) 1.102 ms +1.2% (worse)
Linux fmtprintf 1883936 B +0.2% (worse) 2.407 s +8.1% (worse) 3.002 ms +6.2% (worse)
Linux println 69624 B +1.1% (worse) 295.829 ms -26.8% (better) 1.361 ms +0.6% (worse)
macOS cprintf 84672 B +0.0% 398.310 ms -14.0% (better) 2.918 ms +18.5% (worse)
macOS fmtprintf 1892928 B +0.0% (worse) 2.721 s -21.3% (better) 13.490 ms -8.6% (better)
macOS println 121856 B +0.4% (worse) 386.823 ms +8.1% (worse) 4.053 ms +9.8% (worse)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 9.552 ns/op -0.1% (better)
Linux BenchmarkMergeCompilerFlags 112.600 ns/op +0.5% (worse)
Linux BenchmarkMergeLinkerFlags 72.940 ns/op -1.5% (better)
Linux BenchmarkChannelBuffered 28.170 ns/op +0.1% (worse)
Linux BenchmarkChannelHandoff 19482 ns/op +2.4% (worse)
Linux BenchmarkDefer 35.980 ns/op +1.5% (worse)
Linux BenchmarkDirectCall 1.368 ns/op +0.1% (worse)
Linux BenchmarkGlobalRead 1.652 ns/op +21.1% (worse)
Linux BenchmarkGlobalWrite 2.180 ns/op -0.1% (better)
Linux BenchmarkGoroutine 26033 ns/op -20.0% (better)
Linux BenchmarkInterfaceCall 6.831 ns/op -3.7% (better)
Linux BenchmarkRuntimeGetG 1.641 ns/op +20.2% (worse)
macOS BenchmarkLookupPCRandom 12.550 ns/op +3.3% (worse)
macOS BenchmarkMergeCompilerFlags 116 ns/op -37.4% (better)
macOS BenchmarkMergeLinkerFlags 77.830 ns/op -39.3% (better)
macOS BenchmarkChannelBuffered 25.690 ns/op -3.2% (better)
macOS BenchmarkChannelHandoff 8453 ns/op +51.1% (worse)
macOS BenchmarkDefer 46.780 ns/op +26.7% (worse)
macOS BenchmarkDirectCall 1.137 ns/op +2.8% (worse)
macOS BenchmarkGlobalRead 1.164 ns/op -0.8% (better)
macOS BenchmarkGlobalWrite 1.242 ns/op +11.4% (worse)
macOS BenchmarkGoroutine 55882 ns/op +110.4% (worse)
macOS BenchmarkInterfaceCall 6.291 ns/op -2.0% (better)
macOS BenchmarkRuntimeGetG 2.516 ns/op +1.9% (worse)

Compared with 0f480253029a measured in the same runner job.

@cpunion
cpunion force-pushed the llgo-agy-windows-stdlib-os-20260817 branch from 1b06e4a to 6f0dcc9 Compare August 18, 2026 00:37
@cpunion cpunion changed the title [depends on #2338] os, syscall: enhance Windows OS system integration and smoke tests [depends on #2338] os, runtime: enable native Windows filesystem and process exit Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants