Skip to content

cl,goflags: implement maymorestack debug hook - #2260

Open
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-maymorestack-20260801
Open

cl,goflags: implement maymorestack debug hook#2260
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-maymorestack-20260801

Conversation

@cpunion

@cpunion cpunion commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • parse the supported unpatterned and all= forms of -gcflags=-d=maymorestack=<hook> in internal/goflags
  • carry the hook through typed build configuration and the per-package frontend cl.Options, without process-wide compiler state
  • instrument ordinary function entries while excluding synthetic and //go:nosplit functions
  • preserve Go package scope: unpatterned flags affect command-line roots, while all= affects dependencies too
  • include the effective per-package hook in archive cache fingerprints
  • remove the six Darwin/Linux xfails for Go 1.24, 1.25, and 1.26

Root cause

The runner already forwarded -gcflags, but LLGo did not translate the maymorestack debug option into frontend behavior. The old local prototype predated internal/goflags and used process-wide state plus repeated command wiring. This version reuses the current Go-compatible flag path and the frontend option isolation added on current main.

The official exact-count test also guards package scope: applying an unpatterned flag to dependencies would produce more than the expected 128 calls. Unit coverage adds the separate -d spelling, comma-separated debug options, last-list clearing, all= scope, //go:nosplit, cache isolation, and consecutive compilation isolation.

Validation

  • go test ./internal/goflags -count=1
  • go test -race ./internal/goflags -run "MayMoreStack|FrontendGCFlag" -count=1
  • focused cl and internal/build maymorestack tests
  • go test ./cmd/internal/flags ./cmd/internal/build ./cmd/internal/run ./cmd/internal/test ./cmd/internal/install -count=1
  • project integration TestMayMoreStackGCFlag
  • official test/maymorestack.go with an empty xfail set on Go 1.24.11, 1.25.7, and 1.26.5
  • git diff --check upstream/main...HEAD

No CI timing/configuration, wasm, DWARF, PCLN, pthread, TLS, or unrelated runtime behavior is changed.

@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: maymorestack debug hook

Solid, well-scoped implementation. The -d=maymorestack= flag parsing, all= vs. command-line package scoping, fingerprint/manifest integration, and eligibility logic (skip synthetic / //go:nosplit / self-recursion) all track Go's real maymorestack semantics, and test coverage is thorough (cl internal, build-scope, fingerprint, goflags matrix, and an end-to-end goroot-style test). Removing the maymorestack.go xfail entries is well-supported by the new tests. Findings below are minor; the two worth addressing before merge are the nosplit-match brittleness and the doc-comment attachment.

Findings not tied to a diff line:

  • doc/design/pclntab-packaging.md:92 — the design doc states the -gcflags frontend subset is "(-lang, -N, and -l)". This PR adds -d=maymorestack= as a fourth frontend-interpreted gcflag mapped to typed Config fields, so that enumeration is now out of date and should include it. (File is outside the PR diff, so noted here.)

Inline comments cover the remaining findings.

Comment thread cl/compile.go Outdated
Comment thread cl/compile.go Outdated
Comment thread internal/build/build.go
Comment thread internal/goflags/gcflags.go
@cpunion

cpunion commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all current review findings in 4ed2c1fa3:

  • fast-return before syntax scanning when maymorestack is disabled
  • directive-parser-based //go:nosplit detection, with a trailing-space counterexample
  • corrected MayMoreStackAll field documentation
  • updated the frontend gcflags design-doc list
  • removed the local variable shadowing

Focused validation passes:

  • go test ./cl -run ^TestMayMoreStack -count=1
  • go test ./internal/directive ./internal/goflags -count=1
  • go test ./internal/build -run ^(TestMayMoreStackHookPackageScope|TestManifestBuilder_MayMoreStack)$ -count=1

A separate full ./internal/build attempt reached its existing 10-minute package timeout in TestStandardDWARF/Oz; the focused changed-path tests above completed successfully.

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/compile.go 85.71% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

4ed2c1fa3723 | workflow run | long-term charts

Program measurements

Platform Workload File size vs main Build vs main Run vs main
Linux cprintf 18544 B new 353.314 ms new 1.367 ms new
Linux fmtprintf 2217608 B new 3.323 s new 2.710 ms new
Linux println 71504 B new 347.879 ms new 1.715 ms new
macOS cprintf 84672 B new 398.096 ms new 2.955 ms new
macOS fmtprintf 2361520 B new 2.937 s new 20.373 ms new
macOS println 125712 B new 347.819 ms new 3.811 ms new
Core language and compiler benchmarks
Platform Benchmark ns/op vs main
Linux BenchmarkLookupPCRandom 12.280 ns/op new
Linux BenchmarkMergeCompilerFlags 144.600 ns/op new
Linux BenchmarkMergeLinkerFlags 93.760 ns/op new
Linux BenchmarkChannelBuffered 36.310 ns/op new
Linux BenchmarkChannelHandoff 23949 ns/op new
Linux BenchmarkDefer 42.720 ns/op new
Linux BenchmarkDirectCall 1.757 ns/op new
Linux BenchmarkGlobalRead 1.761 ns/op new
Linux BenchmarkGlobalWrite 2.806 ns/op new
Linux BenchmarkGoroutine 30788 ns/op new
Linux BenchmarkInterfaceCall 8.801 ns/op new
Linux BenchmarkRuntimeGetG 1.759 ns/op new
macOS BenchmarkLookupPCRandom 11.490 ns/op new
macOS BenchmarkMergeCompilerFlags 105.600 ns/op new
macOS BenchmarkMergeLinkerFlags 78.450 ns/op new
macOS BenchmarkChannelBuffered 22.330 ns/op new
macOS BenchmarkChannelHandoff 6943 ns/op new
macOS BenchmarkDefer 27.770 ns/op new
macOS BenchmarkDirectCall 1.017 ns/op new
macOS BenchmarkGlobalRead 1.028 ns/op new
macOS BenchmarkGlobalWrite 1.017 ns/op new
macOS BenchmarkGoroutine 23946 ns/op new
macOS BenchmarkInterfaceCall 4.406 ns/op new
macOS BenchmarkRuntimeGetG 2.038 ns/op new

No main baseline exists yet; all metrics are marked new.

Warning

  • The rendered benchmark data could not be pushed.

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.

1 participant