Skip to content

[Based on #2143] fix(pclntab): preserve Darwin line sites with DWARF#2157

Draft
cpunion wants to merge 9 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-pcln-sites-v2
Draft

[Based on #2143] fix(pclntab): preserve Darwin line sites with DWARF#2157
cpunion wants to merge 9 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-pcln-sites-v2

Conversation

@cpunion

@cpunion cpunion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Based on #2143.

Problem

Darwin builds with DWARF currently disable every compiler-emitted funcinfo site record. That avoids an LLDB lexical-scope regression caused by inline assembly at function entry, but it also removes the final-PC anchors used to build precise runtime line tables. In larger binaries, runtime.Caller, runtime.CallersFrames, logging source prefixes, and panic locations can then fall back to an earlier address.

The two site classes have different debugger effects: function-entry and closure-stub address records alter the initial line-table row, while PC-line anchors are safe when the inline-assembly call itself has no debug location.

#2143 supplies the DWARF-safe optimized compilation pipeline. This PR is stacked on it so the explicit DWARF acceptance path is tested with the intended optimization behavior.

Changes

  • add ssa.Builder.InlineAsmNoDebug, which clears only the emitted call location and preserves the builder current location
  • emit PC-line anchors whenever funcinfo sites are enabled, including Darwin DWARF builds
  • split runtime site policy into PC-line records and entry/stub address records
  • suppress only entry/stub address records for embedded pclntab + Darwin + DWARF
  • retain address records for Darwin without DWARF, external pclntab, and ELF targets
  • add an explicit -ldflags=-w=false acceptance test for runtime.Caller, runtime.CallersFrames, and log.Lshortfile

This does not change pclntab mode selection, the default -w policy, runtime table format, or LLDB language behavior.

Fixes #2115.

Verification

  • macOS: explicit-DWARF runtime line-site acceptance test
  • macOS: current stacked head passed _lldb/runtest.sh, 198/198, plus the non-LLGo marker check
  • Ubuntu arm64 with Go 1.26.5: SSA debug-location tests, site-policy tests, and runtime line-site acceptance test
  • InlineAsmNoDebug, PC-line policy, address-site policy, and the funcinfo-site gate: 100% statement coverage in focused runs
  • git diff --check upstream/main...HEAD

Ubuntu validation was limited to 2 CPUs, 15 GiB memory, and 512 PIDs.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cpunion
cpunion force-pushed the codex/dwarf-pcln-sites-v2 branch from e38170d to d9bdbba Compare July 22, 2026 16:31
@cpunion cpunion changed the title fix(pclntab): preserve Darwin line sites with DWARF [Based on #2143] fix(pclntab): preserve Darwin line sites with DWARF Jul 22, 2026
@cpunion
cpunion force-pushed the codex/dwarf-pcln-sites-v2 branch from d9bdbba to a0b796a Compare July 23, 2026 05:08
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/static_init.go 87.50% 0 Missing and 1 partial ⚠️

📢 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.

pclntab: preserve precise statement PCs with Darwin DWARF

1 participant