Files
psxrecomp/runtime/codegen_hash_sources.cmake
T
Matthew Stanley 8f654965b5 Overlay: loud shard-compile failures, --check preflight, compile-surface cg tag
Re-land of the shard-observability suite from 6da8c02 (stale branch), merged
against current master (keeps master's overlay_ext() platform suffixes,
recompiler_patch hash sources, and the unconditional v12 rfe forwarder).

- compile_overlays.py: ShardStats tallies every shard outcome — per-shard
  "SHARD FAIL [class]" lines, a SHARD BUILD SUMMARY, a machine-readable
  "PSX_SHARD_RESULT ok=N failed=M skipped=K" line, and a non-zero exit when
  any shard that should have built failed (previously a run that built zero
  shards exited 0, indistinguishable from a clean run).
- New --check preflight: build every shard into a throwaway dir and report
  pass/fail — answers "would this game's shards compile against the current
  recompiler + headers?" without a runtime.
- Retain audit-failed interior-fragment C (<phys>_<interior>_fragment_FAILED.c)
  for triage, plus a persistent doomed-interior memo (interior_fail_memo.txt)
  keyed (phys,interior,region_crc) so autocompile stops re-walking
  data-as-code fragments every cycle (~90x off the V8 fragment pass).
- Extract DISPATCH_PREAMBLE to runtime/include/overlay_dispatch_preamble.c.inc
  (single source of truth for the shard link contract, loaded by
  load_dispatch_preamble(); missing file is a hard error).
- codegen_hash_sources.cmake: fold the shard COMPILE surface (overlay_api.h,
  cpu_state.h, the .inc) into the cg tag so header/ABI/link-contract drift
  reshards same-tree instead of silently breaking every new shard compile.
- autocompile.c: parse PSX_SHARD_RESULT from the child-output tail, expose
  shard_ok/shard_fail/shard_skipped/shard_fail_total over autocompile_status;
  ALWAYS rescan on completion so shards that did build load even when the
  run also reported failures.

Live proof on the stale branch: Tomba's first autocompile surfaced 9 shard
link failures (undefined psx_rfe_mark_escape — since fixed by v12) and V8
surfaced 91 benign data-as-code fragment failures, all previously silent.

Codegen hash changes => every title reshards once on next build (expected;
loader rejects/regenerates stale shards).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 22:10:47 -07:00

47 lines
2.9 KiB
CMake

# codegen_hash_sources.cmake — the CANONICAL list of recompiler codegen sources
# folded into the overlay cache tag hash (hash_codegen.cmake).
#
# Included from BOTH:
# - runtime/runtime.cmake (bakes the hash into the runtime's cg tag)
# - recompiler/CMakeLists.txt (bakes the SAME hash into psxrecomp-game,
# exposed via `--codegen-hash`)
# so the two hash computations can never drift by list divergence. Any file
# added to the emitter pipeline must be added HERE, once.
#
# Input: PSXRECOMP_CODEGEN_HASH_ROOT — the psxrecomp repo root.
# Output: PSXRECOMP_CODEGEN_HASH_SRCS — absolute paths to hash.
# NOTE: include the emitter .cpp translation units, not just their headers. A
# change confined to full_function_emitter.cpp (e.g. the 2026-07-03 Class-A
# shell-window overlay-dispatch fix) alters both generated dispatch and overlay
# code but left the hash unchanged when only the .h files were listed — a stale
# overlay-cache hazard (same class as the "ws emission not in cg hash" gap).
set(PSXRECOMP_CODEGEN_HASH_SRCS
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/code_generator.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/mips_decoder.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/control_flow.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/basic_block.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_analysis.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/recompiler_patch.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/recompiler_patch.h
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/full_function_emitter.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/full_function_emitter.h
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/strict_translator.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/strict_translator.h
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_discovery.cpp
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_discovery.h
# --- Shard COMPILE surface -------------------------------------------------
# The cg tag must invalidate on anything a shard compiles/links against, not
# just what the emitter WRITES. A change to the overlay ABI header, the
# CPUState layout, or the dispatch-shim link contract leaves the emitter
# sources untouched — so without these the tag stayed put, existing DLLs kept
# loading, and every NEW shard silently failed to compile against the moved-on
# runtime (the recurring "header change broke the shards" class). Folding the
# compile surface in makes such a change reshard SAME-TREE instead of breaking
# silently. overlay_api.h transitively pulls stdint; cpu_state.h is its only
# project include; the .inc is the shim every shard links against.
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/overlay_api.h
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/cpu_state.h
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/overlay_dispatch_preamble.c.inc)