Files
psxrecomp/runtime/include/autocompile.h
T
Matthew Stanley 5972164b50 sljit: wire the non-dev production trigger (real toolchain probe + auto-live)
Root-cause class: a toolchain-less machine never self-improved via sljit on the
normal play path. Two blocks: (1) `auto` resolved to gcc on EVERY machine because
the discriminator was autocompile_configured() — "is a command STRING set" — and
the shipped game.toml always carries overlay_autocompile_cmd; (2) live sljit mode
was reachable only via a hand-set env var (dead public setter, no policy).

Fix:
- autocompile.c: autocompile_toolchain_available() probes PATH for a real C
  compiler (gcc/cc/clang). main.cpp passes
  `autocompile_configured() && autocompile_toolchain_available()` to
  code_provider_init, so `auto` picks gcc only when one is actually reachable,
  else sljit.
- overlay_loader.c: overlay_loader_apply_live_policy() (called from main.cpp
  AFTER backend resolution) defaults live ON when the resolved backend is sljit
  — so a toolchain-less box runs VALIDATED shards live (self-improves on the
  normal path); PSX_OVERLAY_SLJIT_LIVE still overrides. The env-only block in
  overlay_loader_init is removed (the policy fn subsumes it).

Runtime-only (no regen). Refs SLJIT.md §11 Phase C.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:12:27 -07:00

46 lines
1.8 KiB
C

/* autocompile.h — background overlay compile for variant-capture automation
* (step 2.8). Spawns the configured compile command (compile_overlays.py
* invocation from game.toml [runtime] overlay_autocompile_cmd) after an
* automatic capture, collects its output into an in-memory ring (no log
* files — CLAUDE.md §3; read it via the autocompile_status TCP command),
* and on success has the emu thread rescan the overlay-DLL cache so the new
* variant goes native in-session, without a restart. */
#ifndef PSXRECOMP_AUTOCOMPILE_H
#define PSXRECOMP_AUTOCOMPILE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Store the command line + working directory. Empty cmd disables. */
void autocompile_configure(const char *cmd, const char *cwd);
int autocompile_configured(void);
/* Probe whether a C compiler is actually reachable on PATH (gcc/cc/clang) — the
* REAL "developer machine" signal, distinct from autocompile_configured() which
* only reports that a command STRING is set (the shipped game.toml always sets
* one). overlay_backend_resolve uses this so `auto` picks gcc only when the
* toolchain can really build a shard, else sljit (toolchain-less production).
* Memoized; safe to call repeatedly. */
int autocompile_toolchain_available(void);
/* 1 while a compile process is running. */
int autocompile_busy(void);
/* Kick a compile if configured and idle. Returns 1 if started. */
int autocompile_request(void);
/* Emu-thread tick: applies a finished compile (cache rescan on success).
* Must be called from the same thread that owns the overlay loader. */
void autocompile_poll_main(void);
/* JSON status blob for the debug server: state, run/fail counters, last
* exit code, and the output tail. Returns bytes written. */
int autocompile_status_json(char *out, int cap);
#ifdef __cplusplus
}
#endif
#endif /* PSXRECOMP_AUTOCOMPILE_H */