debug: establish Go DWARF foundation with stock LLDB support#2141
Merged
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cpunion
marked this pull request as ready for review
July 21, 2026 19:58
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
cpunion
marked this pull request as draft
July 21, 2026 20:15
cpunion
force-pushed
the
codex/dwarf-debug-v2
branch
from
July 21, 2026 21:30
9b33fe3 to
3e06813
Compare
This was referenced Jul 21, 2026
cpunion
force-pushed
the
codex/dwarf-debug-v2
branch
from
July 22, 2026 06:20
e1080f3 to
e1b508c
Compare
cpunion
marked this pull request as ready for review
July 22, 2026 08:04
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
43 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LLGo's existing DWARF path has no standards-based contract. Metadata construction is spread across the compiler, several Go source types are encoded incorrectly, recursive named types cannot be completed safely, and source variables and lexical scopes are not represented consistently.
The result may be malformed or misleading DWARF even when a binary builds successfully. Debugger-only checks do not detect those format and type-system errors. Conversely, valid Go DWARF marked DW_LANG_Go is not sufficient for current LLDB: Apple/LLVM LLDB has no Go language plugin and hides otherwise valid frame variables.
Foundation design
This PR establishes a Go DWARF foundation with clear ownership:
LLVM builder ownership remains independent from Go semantic lowering, while frontend source-variable bookkeeping stays in cl.
LLDB compatibility contract
Compile units temporarily use DW_LANG_C so stock LLDB uses its complete C frame-variable path. The emitted type layouts and attributes remain the Go-oriented DWARF validated by the standard tests.
LLGo identity does not depend on the language field:
Native DW_LANG_Go support is intentionally a separate LLDB language-extension project described in #2154. LLGo should switch the language field only after that extension passes its cross-platform acceptance matrix.
Standards coverage
TestStandardDWARF builds and executes a multi-file Go fixture at O0, O1, O2, O3, Os, and Oz, then:
The macOS LLDB suite runs at O0 because it asserts exact source-variable values and lifetimes. It now passes 198 checks covering parameters, locals, lexical scopes, standard complex values, globals, pointers, aggregates, marker detection, and non-LLGo rejection. Optimized builds legitimately eliminate or merge some locals, so the six optimization levels are validated structurally rather than compared against O0 variable availability.
The requested optimization level still configures LLVM target-machine code generation. Existing main behavior disables LLGo's IR pass pipeline and optimized C ABI mode whenever DWARF is enabled; this PR intentionally does not change that policy. Decoupling those transformations is covered by #2143.
Fixes #2116.
Verification
Local macOS, Go 1.26.5 / LLVM 19:
The resource-limited full cl package run reached its 15-minute command timeout in the existing _testrt fixture without an assertion failure; CI runs that suite in shards.
Ubuntu arm64 container, Go 1.26.5 / LLVM 19.1.7, limited to 2 CPUs, 15 GiB memory, and 512 PIDs:
CI keeps both the standards matrix and the existing LLDB integration suite.
Out of scope
Each area below remains independent from this foundation:
DWARF remains opt-in for linked builds through -ldflags=-w=false in this PR.