Skip to content

v2: fix self-host chain#27374

Merged
medvednikov merged 1 commit into
masterfrom
codex/v2-cold-cgen-profile
Jun 7, 2026
Merged

v2: fix self-host chain#27374
medvednikov merged 1 commit into
masterfrom
codex/v2-cold-cgen-profile

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Summary

Fix the V2 self-host chain so v -o v2 v2.v && ./v2 -o v3 v2.v && ./v3 -o v4 v2.v completes reliably from cmd/v2.

The fix keeps flat-mode preregistration from decoding every function body up front, avoids unsafe mutation during generated str() function worklist iteration, avoids materializing the full expression-type list during cleanc alias collection, and prevents duplicate .vh inputs when cached headers are already present.

Root Cause

The second-generation V2 compiler could corrupt or exhaust runtime state while rebuilding itself:

  • flat preregistration decoded full function bodies when only signatures were needed
  • generated str() function discovery iterated a map that can be extended by recursive generation
  • cleanc alias collection allocated a large temporary array of expression types
  • cached .vh files could be appended twice in the flat/cached path

Validation

  • ../../v -o v2 v2.v && ./v2 -o v3 v2.v && ./v3 -o v4 v2.v from cmd/v2
  • isolated detached worktree at the PR commit with freshly built ./v, same self-host chain
  • ./vnew -silent test vlib/v2/ast/ vlib/v2/types/checker_flat_test.v vlib/v2/builder/target_os_test.v vlib/v2/transformer/generated_fns_parts_from_flat_test.v
  • git diff --check

@medvednikov medvednikov merged commit c1d891e into master Jun 7, 2026
76 of 83 checks passed
dy-tea pushed a commit to wenxuanjun/v that referenced this pull request Jun 19, 2026
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