Repository navigation
Compiler debug info: every function names its own file and line; stage2-debug-lines gate - #1351
Merged
Merged
Conversation
This was referenced Sep 22, 2026
added 3 commits
September 22, 2026 19:01
…eclaring file
Parser.parse_interpolated_expr_attempt built its sub-parser with file id 0.
Parser.init_with_pool stamps the shared pool's current file id, and nothing
restored it, so every node after the first `{expr}` in an imported module was
attributed to the root (file 0). ComptimeTransform's derive and comptime
expansion loops appended nodes under whatever file the deep clone stamped
last. AstPool.file feeds D39's interface-file node runs and Codegen's DWARF
file (next commit).
… file debug_enter_function named the root's DIFile for every function and measured every span against the root's text (di_source), so every function of every imported module read as main.w:<line of some other file> in lldb. For with-stage2, Sema.check_mutation_against_views read main.w:1. The function's file now comes from AstPool.file(fn_node): a cached DIFile per file id, with its canonical path (absolute, WITH_FILE_PREFIX_MAP, D50), and lines from Sema.source_location_for_file_id. The OS entry wrapper gets its own line-0 subprogram, so an inlined user main keeps its lines. CCodegen's #line directives had the same root-only defect and now follow the body's declaration file.
…ies the binary's name run_debug_lines_check_action reads with-stage2's DWARF with the SDK's llvm-dwarfdump. For each anchor (Sema.check_mutation_against_views in src/SemaCheck.w, Lexer.skip_whitespace in src/Lexer.w), DW_AT_decl_file must be /with-src/<source>, DW_AT_decl_line must be the line of the declaration, and the line table at low_pc must name the file. Before this, the compiler's debug info named main.w for every module and nothing failed. The stage build ran dsymutil on the .tmp link output and moved the bundle, so its DWARF file was named with-stage2.tmp. The build now renames it.
Contributor
Author
ehartford
force-pushed
the
fix-stage-debug-info
branch
from
September 22, 2026 23:26
01a3cad to
2d3daf5
Compare
ehartford
marked this pull request as ready for review
September 22, 2026 23:26
ehartford
added a commit
that referenced
this pull request
Oct 2, 2026
…ical_block (#1356) (#1961) The #1351 workaround for #1349 (`let (a, b) = if c: f() else: (1, 0)` rejected by the then-pinned seed) is retired: seed.lock has been bumped past 1f4636d (#1355), and the pinned seed builds stage1 with the natural spelling (`src/main build :dev` rc=0). Co-authored-by: Eric Hartford <[email protected]>
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.
The compiler's own binaries had no usable debug info. Every function in every module was attributed to
main.w. The fix is in three commits.Root cause (exact lines)
debug_enter_function/debug_set_location/debug_push_lexical_block(main at 5fd93bc): every DISubprogram, lexical block and location usedself.di_file(the root's DIFile) andself.di_source.offset_to_location(span)(the root's text). Spans are byte offsets into the file a node was parsed from, so an imported module's function got the root's file and a line computed against the wrong text.parse_interpolated_expr_attempt:Parser.init_with_pool(..., 0, ...). The f-string sub-parser stamped the shared pool's current file id to 0 and never restored it, so every node after the first{expr}in any imported module hadAstPool.file == 0. Fixing (1) alone still left 5255 subprograms inmain.w. The same class was in ComptimeTransform's derive and comptime-expansion loops, whose appended nodes took whatever file the deep clone stamped last. For example,BuilderError.debug_strwas attributed to the last-parsed user file.run_with_compiler_build_action: dsymutil ran on the.tmplink output, so the dSYM's DWARF file was namedwith-stage2.tmp.CCodegen's
#linedirectives had the same root-only defect as (1). They now follow the body's declaration file.Before (main, out/stage/bin/with-stage2)
After (this branch, stage2 built by the fixed stage1)
Two-module user program:
helper at Helper.w:9:24(it wasapp.w), a function after an f-string readsHelper.w:9, andbr set -f app.w -l 5stops in the inlined usermain, which used to have no line.Regression gate
stage2-debug-lines(a dependency of:fixpoint) runs the SDK's llvm-dwarfdump on with-stage2 for two anchors (Sema.check_mutation_against_views,Lexer.skip_whitespace). It requiresDW_AT_decl_file == /with-src/<source>,DW_AT_decl_lineequal to the declaration's line in the source, and the line-table row atlow_pcto name that file. On Windows (CodeView) it prints an explicit skip.Determinism
:fixpoint-compare:stage2 == stage3 over all 16 units of the compiler. DIFile paths go throughcodegen_canonical_module_path(absolute, then WITH_FILE_PREFIX_MAP). Module names are recorded relative to the working directory, and DWARF would have resolved them against the root's directory, which gave/with-src/out/gen/src/.... An rt object built by the new compiler now reads/with-src/rt. The ones stage2 links today areout/bootstrap-libobjects from the pinned seed, and they still carry the checkout path until the seed moves.Not in this change
frame variablestill reports "no variable information". Monomorphized and closure bodies get no subprogram. Filed as Codegen debug info: no DWARF variables anywhere; generic (mono) and closure functions get no subprogram #1348.let (a, b) = if c: f() else: (1, 0)is rejected. It was worked around here and filed as Sema:let (a, b) = if c: f() else: (1, 0)rejected — "tuple pattern requires tuple subject" #1349.Iterate-tier evidence only (
:dev,:stage2,:stage2-debug-lines,:fixpoint-compare). The full battery has not been run yet.