Skip to content

AOT: localize cached-unit declaration types + call-site-lazy sprintf link; workflow skills (#15642, #15889) - #16965

Merged
PurHur merged 3 commits into
masterfrom
fix/15642-sprintf-cache
Jul 6, 2026
Merged

PurHur merged 3 commits into
masterfrom
fix/15642-sprintf-cache

Conversation

@PurHur

@PurHur PurHur commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Cache-machinery fixes

Hygiene

Spine sync 4181/4182 (3 new fleet DOM files) + honest sidecar refresh (d8ba2365). M5 fast green, AOT smoke green cache-on/off, unit sweep 119 fresh / 0 failed.

Skills (workflow documentation)

  • phpc-verify: PHP_COMPILER_LLVM_ASSERT=1 debugging recipe (segfault → PHP backtrace), gdb fallback, bundle-failure breadcrumbs, battery babysitter, gate-order note, the ->value vs loadValue() bug shape.
  • phpc-fix-loop: merge-race protocol (local resolution, --theirs on generated, spine uniq -d, push-verify, single-sequence merge), worktree-docker .git mount, vendor-patch shipping rules.
  • phpc-selfhost: spine-sync flags, duplicate-entry check, the honest deferral workflow.
  • NEW phpc-helper-cache: the split-compilation cache end-to-end (commands, fingerprints, debugging, sharp edges).
  • phpc-setup: committed cold-start caches, worktree/cwd traps.

🤖 Generated with Claude Code

anmichels and others added 3 commits July 6, 2026 18:48
…link; document workflows in skills (#15642, #15889).

Cache-machinery fixes (each independently load-bearing):

- HelperRuntimeCache::tryProvide rebuilds extern declaration types
  against the LOCAL context's named structs. LLVM re-suffixes named
  structs on bitcode parse (__string__ -> __string__.12) and suffixed
  declaration types fail module verify at every call site — a latent
  correctness bug for ANY consumer whose module defines the structs
  before binding (getStringFromType cannot stringify suffixed structs,
  so the fallback read struct names via LLVMGetStructName).
- StringFormat gains implementIfDeclared(): user-standalone builds
  skip ensureLinked at init (#13571), so printf()/sprintf()/
  number_format() died at link with undefined __compiler_sprintf
  (#15642). JitSprintf::format now links on first call-site lowering
  (builder insert-point saved/restored), and ensureJitHelperCompiled
  consults the helper cache first — with PHP_COMPILER_HELPER_RUNTIME_O=1
  the corpus binds as externs instead of a nested compile that OOMs a
  default-memory build. Remaining gap: cached units lack their init
  chains, so the sprintf unit crashes at runtime in user builds until
  per-unit llvm.global_ctors lands (epic #16075 step 4/5) — the link
  error is fixed, the runtime story is documented on #15642.
- PackArgvSerialize memcpy calls adapt to WHATEVER signature the module
  already declares (main-script i8* vs runtime void* ordering flip).

Spine sync to 4181/4182 (3 new fleet DOM files) + sidecar refresh
(stamp d8ba2365). M5 fast green, AOT smoke green cache-on and -off,
full unit sweep 119 fresh / 0 failed.

Skills: phpc-verify gains the LLVM-assert debugging recipe, battery
babysitter, and gate-order notes; phpc-fix-loop gains merge-race
protocol, worktree-docker and vendor-patch guidance; phpc-selfhost
gains spine-sync flags, dedup check, and the deferral workflow; new
phpc-helper-cache skill documents the split-compilation cache
end-to-end; phpc-setup documents the committed cold-start caches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@PurHur
PurHur merged commit 4bad85d into master Jul 6, 2026
1 check failed
@PurHur
PurHur deleted the fix/15642-sprintf-cache branch July 6, 2026 16:51
PurHur added a commit that referenced this pull request Jul 6, 2026
…16972)

Spine entry SHA drifted after #16964/#16965 require_once additions;
sync prelinked stamp/manifest and roadmap footnotes so ci-fast spine
gates pass without auto-heal.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Jul 6, 2026
…helper cache (#16075 step 4) (#16992)

* AOT: localize cached-unit declaration types + call-site-lazy sprintf link; document workflows in skills (#15642, #15889).

Cache-machinery fixes (each independently load-bearing):

- HelperRuntimeCache::tryProvide rebuilds extern declaration types
  against the LOCAL context's named structs. LLVM re-suffixes named
  structs on bitcode parse (__string__ -> __string__.12) and suffixed
  declaration types fail module verify at every call site — a latent
  correctness bug for ANY consumer whose module defines the structs
  before binding (getStringFromType cannot stringify suffixed structs,
  so the fallback read struct names via LLVMGetStructName).
- StringFormat gains implementIfDeclared(): user-standalone builds
  skip ensureLinked at init (#13571), so printf()/sprintf()/
  number_format() died at link with undefined __compiler_sprintf
  (#15642). JitSprintf::format now links on first call-site lowering
  (builder insert-point saved/restored), and ensureJitHelperCompiled
  consults the helper cache first — with PHP_COMPILER_HELPER_RUNTIME_O=1
  the corpus binds as externs instead of a nested compile that OOMs a
  default-memory build. Remaining gap: cached units lack their init
  chains, so the sprintf unit crashes at runtime in user builds until
  per-unit llvm.global_ctors lands (epic #16075 step 4/5) — the link
  error is fixed, the runtime story is documented on #15642.
- PackArgvSerialize memcpy calls adapt to WHATEVER signature the module
  already declares (main-script i8* vs runtime void* ordering flip).

Spine sync to 4181/4182 (3 new fleet DOM files) + sidecar refresh
(stamp d8ba2365). M5 fast green, AOT smoke green cache-on and -off,
full unit sweep 119 fresh / 0 failed.

Skills: phpc-verify gains the LLVM-assert debugging recipe, battery
babysitter, and gate-order notes; phpc-fix-loop gains merge-race
protocol, worktree-docker and vendor-patch guidance; phpc-selfhost
gains spine-sync flags, dedup check, and the deferral workflow; new
phpc-helper-cache skill documents the split-compilation cache
end-to-end; phpc-setup documents the committed cold-start caches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Merge follow-up: inventory regen.

* AOT: per-unit init chains + runtime-safety guards for the default-on helper cache (#16075 step 4, #15889, #15642).

The fleet flipped the helper cache default-on (#16948) while two
latent hazards were live; this lands the missing infrastructure and
contains the known-unsafe path:

- Unit emission suffixes __init__/__shutdown__/__header_pre_flush__
  per unit (PHP_COMPILER_INIT_SYMBOL_SUFFIX, recorded in the unit
  manifest). The colliding __init__ was -z muldefs-discarded and unit
  module state NEVER INITIALIZED — the root of the cached-unit runtime
  crash class. The consuming script's __init__ now calls each used
  unit's init explicitly (emitInInit at bind time).
- Unit __shutdown__ is deliberately NOT wired: muldefs unifies part of
  the unit's globals with the script's, and running both shutdowns
  double-frees (SIGABRT at exit — caught by the AOT smoke).
- Consumers skip units without an init symbol (pre-init-era manifests,
  including all previously committed prelinked units) and units marked
  runtime_safe=false. SprintfJitHelper is blocklisted: it constructs
  VM objects with class ids baked from the emitter process's registry,
  and the consuming script numbers classes differently — segfault in
  variablesFromPackedArgv (gdb data on #15642). Class-id unification
  is #16075 step 5.
- JitSprintf's call-site StringFormat link (from #16965) is gated OFF
  during unit emission: the emitter guards the cache, so the hook was
  dragging a full nested corpus compile into every sprintf-adjacent
  unit (user builds spun ~10 min in auto-warm; Opendir unit hit it
  hardest).
- prelinked/helper-runtime republished: 121 units with init symbols
  (34.8 MB).

Verified: AOT smoke green (was SIGABRT 134 with shutdown wiring / spin
before the gate), scalar+strlen differential AOT == VM with cache
default-on, M5 fast green, sprintf unit emits in seconds again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: PurHur <tedyyyyy@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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