runtime: restore native process-entry caller tail - #2314
Conversation
There was a problem hiding this comment.
Review summary
This is a clean, well-motivated change: extracting emitRuntimeMainBody cleanly shares the init/main call sequence between the native runtime.main wrapper and the inline non-native path, and TestGenMainModuleExecutable pins the call ordering so the non-native path's behavior is verified. The cross-check of the same module under gc (go run) before LLGo in TestCallerAcceptanceLogicalRuntimeTail directly validates the gc-compatibility goal, and the removed xfail.yaml entries are consistent with the new capability.
No security or performance concerns were found: the extra runtime.main frame runs exactly once at startup (not a hot path), and the append(funcInfo, ...) is safe today because cfg.funcInfo is a fresh single-owner slice from collectFuncInfo.
Findings below are maintainability/accuracy observations, not blockers. See inline comments for the concrete diff-line findings.
Additional (no reliable inline location)
internal/build/main_module.go:267-273(defineEntryFunctiondoc comment) — The doc comment is now stale for the native path. It states the entry "runs initialization hooks (Python, runtime, package init), calls main.main, finalizes Python ... and returns 0", but for native executables with PCLN enabled those steps now run inside the generatedruntime.mainframe (defineRuntimeMainFunction→emitRuntimeMainBody), not directly in the entry. The comment also omits theruntime.initstub and abi-types init thatemitRuntimeMainBodyactually calls. Consider a sentence describing the two-path structure (inline vs. wrapped inruntime.main).
|
Addressed the additional doc-comment review in 21ff1e0. defineEntryFunction now describes the wrapped native-PCLN path versus the inline path and lists the runtime stub/package, ABI-type, package, main, and Python-finalization stages. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
Compared with |
818a125 to
91f21d3
Compare
91f21d3 to
d776b53
Compare
Summary
runtime.mainframe for native executables and map the required Cmainentry to the logical Go nameruntime.goexit;Callersynthesis;inline_caller.goandfixedbugs/issue29919.goxfails.The actual native symbols remain
main.main -> @runtime.main -> @main. Funcinfo presents the final C ABI entry asruntime.goexit, so Go stack inspection observes the gc-compatible logical tailmain.main -> runtime.main -> runtime.goexit.Generated LLVM IR shape
Previously, the C ABI entry directly ran the complete startup sequence:
The native PCLN path now separates the C entry from the Go startup driver:
Package and ABI initialization calls omitted above remain in their previous order.
noinlineanddisable-tail-callsensure LLVM cannot remove the requiredruntime.mainframe.The generated funcinfo mappings are:
The linker-facing symbol is still the required C
main; this PR does not generate a separate physical@runtime.goexitfunction.Runtime impact
main.main, Python initialization/finalization, argc/argv handling, and local-context ordering are unchanged.main.main, then returns once when startup execution finishes.runtime.Caller,runtime.CallersFrames, and panic tracebacks now see the Go-compatible process-entry tail, including during imported-package initialization.Calleror per-traceback synthesis.Validation
go test ./internal/build -run TestGenMainModule -count=1go test -vet=off ./test/go -run TestCallerAcceptanceLogicalRuntimeTail -count=1 -timeout=20minline_caller.gowithout xfail on macOS/arm64fixedbugs/issue29919.gowithout xfail on macOS/arm64go test ./test/goroot -run "TestRepositoryExpectationsAreSeparated|TestXFailMatch" -count=1