[depends on #2336] runtime: add the native Windows runtime core - #2338
[depends on #2336] runtime: add the native Windows runtime core#2338cpunion wants to merge 77 commits into
Conversation
There was a problem hiding this comment.
Review: Windows runtime & toolchain support
This is a large, well-structured PR adding Windows support across the compiler and runtime. The platform split via build tags (_windows/_unix/_default) is consistent, new C shims validate pointers and manage matched free-on-error paths, the syscall ASM bridge is bounds-guarded from the Go side, and the meta parser adds solid hardening for mmap'd file-controlled input. Test coverage (goarch parsing, COFF COMDAT, setjmp ABI, cache fingerprints, lock release) is strong.
Findings below are inline. Highlights:
- Perf (P1):
llgo_nanotimequeriesQueryPerformanceFrequencyon every call; the frequency is fixed for the lifetime of the system and should be cached once. - Correctness (P2): the process-global fault-traceback buffer is not thread-safe if concurrent recoverable faults are possible.
- Docs (P2): the
MutexAttrcomment misdescribes where unsupported attributes are rejected.
No high-severity or blocking issues found. Nice work.
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
Compared with |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
e3525d1 to
4932830
Compare
|
@fennoai The full stack is now rebased onto current |
Re-review completeI re-reviewed the current head ( Findings are posted as a non-blocking PR review with 3 inline comments plus a couple of minor items in the review body. Most substantive point is the CONTEXT stack alignment (P2). No blocking correctness issues found. |
There was a problem hiding this comment.
Re-review: native Windows runtime core (head 493283007d53)
I re-reviewed the current head across code quality, performance, security/memory-safety, and documentation accuracy, focusing on the substantive additions you called out — the generic //go:cgo_import_dynamic pointer lowering (internal/build/cgo_pragmas.go) and the Win64 SEH virtual unwinding (runtime/internal/lib/runtime/unwind_windows_seh_llgo.go + fault_context_windows_*).
Overall this is solid, defensively-written systems code: the CONTEXT records carry compile-time size/offset assertions, build tags are complementary and mutually exclusive, the syscall bridge is //go:nosplit and allocation-free, the sync primitives map straight to SRW/CONDITION_VARIABLE, and the expensive per-frame RtlVirtualUnwind/VirtualQuery work is correctly confined to the fault/traceback cold path. The dynamic-import alias parsing validates the %argc suffix and flows names into LLVM symbol creation rather than a shell, so there's no injection surface there.
A few points worth addressing are left as inline comments. The most substantive is the CONTEXT stack alignment (P2). No blocking correctness issues were found.
Minor items (no reliable single inline anchor)
internal/build/cgo_pragmas.go— unusedgoosparameter.goCgoLinkArgs(goos string, files []*ast.File)never usesgoos; it collects ldflags regardless of GOOS. Either drop the parameter or gate on it, for parity with the siblinglowerWindowsCgoImportPointers/buildGoCgoAliasObjectswhich do gate on GOOS.internal/build/cgo_pragmas.go(buildGoCgoAliasObjects) — temp object cleanup / droppedCloseerror. Afteros.CreateTemp(..., "cgoimportalias-*.o"), theobjFile.Close()error is discarded andobjPathis only removed on the explicitCompilefailure path. Considerdefer-removingobjPathuntil success is confirmed, matching the correctly-handled.stemp block just above it.
Verified as intentional / no action needed
TypeInfoWindowsArm64embedding*TypeInfoArm64with no overrides is a deliberate distinct-type guard (documented).- FLS lifecycle in
thread_windows.ccorrectly mirrors pthreadsetspecificsemantics; no leak/double-free. - MSVC aggregate ABI register-size classification (1/2/4/8, indirect fallback) matches the Microsoft x64/x86 rules.
- CONTEXT layout offsets and libffi
DefaultAbivalues are correct for their targets.
|
The two review-body cleanup items are also addressed in 551e881: goCgoLinkArgs no longer carries the unused GOOS parameter, and the Darwin alias object now checks Close and remains under deferred cleanup until successful ownership transfer to the package archive builder. |
|
@fennoai All findings from the re-review are fixed at head |
Final confirmation — all prior findings fixed at
|
551e881 to
bba7124
Compare
|
@fennoai Please do a focused confirmation review of the rebased current head The 36 runtime commits were rebased from the previously approved All 42 applicable GitHub checks now pass (one normal release skip), including Windows AMD64 and |
Rebase confirmation —
|
Implements the native Windows runtime core described in #2325.
Depends on #2336 for the MSVC C ABI and COFF linker foundation. The runtime work is layered on the official-source reuse from #2331 rather than restoring superseded alternate runtime patches.
What this adds
//go:cgo_import_dynamicpointer aliases generically so the official standard-library syscall sources receive their imported DLL entry pointsCONTEXTstorage, instead of treating the Win64 frame pointer as a linked Go frameScope
This PR supplies the runtime core used by later Windows standard-library and process support.
syscall.NewCallbackremains explicitly unsupported and is not implemented here.Validation
After rebasing the stack onto #2336 head
e4c6ea7c1, the contribution head isbba71242f.On macOS ARM64 with Go 1.26.5 and LLVM 19:
./internal/buildpassgo test -count=1 ./internal/env ./internal/crosscompile ./internal/cabi ./ssapasses (internal/cabi: 141.025 seconds;ssa: 179.184 seconds)runtime, the internal runtime, libffi, synchronization, and thread packages compile and pass their host-side Go testsOn a native Windows 11 ARM64 VM with Go 1.26.5, MSVC Build Tools, and LLVM 19.1.7, building directly from the macOS source worktree over the Parallels UNC share:
internal/cabi: 175.828 seconds)llgo (devel) windows/arm64)main.windowsNilFaultfunction and source path in the tracebackGitHub CI completed all 42 applicable checks successfully (with the normal release job skipped), including native Windows AMD64, Ubuntu, macOS, and
codecov/patchat 98.20%.