Skip to content

runtime: preserve line directive caller filenames#1903

Draft
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-linedir-coverage
Draft

runtime: preserve line directive caller filenames#1903
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-linedir-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary

  • preserve adjusted call-site filenames, not only lines, in LLGo caller-frame metadata
  • normalize package-loader-expanded relative //line filenames back to Go runtime spelling (foo.go, c:/foo/bar.go) and map empty directive filenames to ??
  • add stable test/go coverage for runtime.Caller / FuncForPC.FileLine under absolute, Windows-style, relative, and empty filename line directives
  • remove only the verified darwin/arm64 xfails for fixedbugs/issue18149.go and fixedbugs/issue22662.go

Stack note

This branch includes the caller-frame metadata commit from PR #1884 because these fixedbugs exercise runtime.Caller; without that dependency, the current mainline placeholder returns ???:1. The second commit is the scoped line-directive/source-position fix.

Testing

  • Reproduced with xfail disabled before the scoped fix:
    • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot "$(go env GOROOT)" -dirs fixedbugs -case '^fixedbugs/(issue18149|issue22662)\\.go$' -xfail /tmp/llgo-no-xfail.yaml -run-timeout 30s
    • after the caller-frame baseline, LLGo reported the physical/package-relative files instead of the directive files
  • go test ./test/go -run 'TestRuntimeCaller' -count=1
  • go build -tags=dev -o /tmp/llgo-linedir-test ./cmd/llgo
  • LLGO_ROOT=$PWD /tmp/llgo-linedir-test test ./test/go/runtime_caller_test.go
  • go test ./cl -run 'TestEmitDo|TestExplicitDefer|Test.*Rewrite|TestOffsetOfHelpersAndSourceLineCache' -count=1
  • go test ./ssa -run 'TestFuncCall|TestSetBlockEx|TestClosureFuncPtrValue' -count=1
  • (cd runtime && go test ./internal/runtime -count=1)
  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot "$(go env GOROOT)" -llgo /tmp/llgo-linedir-test -dirs fixedbugs -case '^fixedbugs/(issue18149|issue22662)\\.go$' -xfail /tmp/llgo-no-xfail.yaml -run-timeout 30s
  • go test ./test/goroot -count=1 -run TestGoRootRunCases -args -goroot "$(go env GOROOT)" -llgo /tmp/llgo-linedir-test -dirs fixedbugs -case '^fixedbugs/(issue18149|issue22662)\\.go$' -run-timeout 30s

GOROOT CI is slow/disabled in this repo, so this PR relies on the targeted GOROOT runs above plus normal PR CI from the fork branch. I did not push any branch to xgo-dev/llgo; the head branch is on cpunion/llgo.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

CI follow-up for 82d126f:

  • Fixed the current regular PR CI failures by limiting caller-frame instrumentation to packages that actually use runtime caller metadata APIs (runtime.Caller, Callers, CallersFrames, FuncForPC) and disabling that instrumentation for std/runtime packages plus -target/wasm builds.
  • Removed a new strings import from the LLGo runtime alt package to avoid pulling errors/internal/reflectlite into minimal runtime-only demos.

Local verification:

  • go test ./ssa ./cl ./test/go ./test/goroot
  • LLGO_ROOT=$PWD /tmp/llgo-pr1903 test -timeout=20m -run 'TestRuntimeCaller|TestRuntimeCallers' ./test/go
  • go test ./test/goroot -run TestGoRootRunCases -goroot $(go env GOROOT) -dirs . -case '^(inline_caller|inline_callers)\.go$|^fixedbugs/(issue18149|issue22662)\.go$' -directive-mode=ci -progress=30s -timeout=30m
  • _demo/embed/targetsbuild: bash build.sh empty /tmp/llgo-targets-smoke.txt with xiao-esp32c3
  • _demo/go/runtime: LLGO_ROOT=$PWD /tmp/llgo-pr1903 run .
  • go run ./cmd/llgo test -timeout=20m ./test/std/crypto/rsa
  • go run ./cmd/llgo test -timeout=20m ./test/std/crypto/x509
  • git diff --check

This PR still stacks on the caller-frame/debugline work from #1884; this commit makes the stacked PR suitable for regular PR CI without pushing anything to xgo-dev.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 54.14013% with 72 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/instr.go 47.70% 51 Missing and 6 partials ⚠️
cl/compile.go 71.73% 11 Missing and 2 partials ⚠️
ssa/package.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants