cli: stage the overlay toolchain beside every built product

No setup package ever staged one, so overlay_cache = true alone left every
streamed overlay on the interpreter. rebuild now stages the pinned Python,
tcc, this pin's recompiler, headers and the build's codegen hash beside the
normal and diagnostic products, and writes compiler.txt naming the compiler
the wizard already has; the runtime treats that as a gcc-tier compiler, so a
player with nothing on PATH gets -O2 shards. Verified on the NCII kit: gcc
tier reported and four shards built with no compiler on PATH.

(cherry picked from commit 03865e10f6ee198d58c47c74526df5db46bb35a9)
This commit is contained in:
Alexandros Mandravillis
2026-09-16 17:44:36 +03:00
parent 193a60b805
commit c10bad2ebb
3 changed files with 84 additions and 6 deletions
+20 -3
View File
@@ -13530,6 +13530,20 @@ int main(int argc, char** argv) {
const char *tk_tcc = "tcc";
#endif
const bool tk_present = std::filesystem::exists(tk_py);
/* Wave-5 F2: the CLI names the compiler it already has (the wizard's pack on
* Windows, the native cc on POSIX) in overlay_toolchain/compiler.txt, so a player
* with nothing on PATH still gets optimised shards instead of tcc's. */
std::string tk_compiler;
{
std::ifstream cf(tk_dir / "compiler.txt");
std::string line;
if (cf.is_open() && std::getline(cf, line)) {
while (!line.empty() && (line.back() == '\r' || line.back() == '\n' || line.back() == ' '))
line.pop_back();
std::error_code cec;
if (!line.empty() && std::filesystem::exists(line, cec)) tk_compiler = line;
}
}
auto build_toolchain_cmd = [&](const char *compiler) {
auto cmd_quote = [](const std::string& s) {
return std::string("\"") + s + "\"";
@@ -13546,12 +13560,14 @@ int main(int argc, char** argv) {
" --out-dir " + cmd_quote((tk_xd / "cache").string()) +
(g_psx_cps_mode ? " --cps" : "") +
" --compiler " + compiler;
if (std::string(compiler) == "gcc" && !tk_compiler.empty())
c += " --gcc " + cmd_quote(tk_compiler);
if (std::string(compiler) == "tcc")
c += " --tcc " + cmd_quote((tk_dir / "tcc" / tk_tcc).string());
return c;
};
int gcc_avail = (deferred_has_overlay_ac || tk_present)
&& autocompile_toolchain_available();
&& (autocompile_toolchain_available() || !tk_compiler.empty());
OverlayBackend eff = overlay_backend_resolve(cfg_backend, gcc_avail);
std::string built_tcc_cmd;
std::string built_gcc_cmd;
@@ -13579,8 +13595,9 @@ int main(int argc, char** argv) {
built_gcc_cmd = build_toolchain_cmd("gcc");
ac_cmd = &built_gcc_cmd;
std::fprintf(stdout,
"psxrecomp: gcc tier using bundled toolchain (%s) with gcc from PATH\n",
tk_dir.string().c_str());
"psxrecomp: gcc tier using bundled toolchain (%s) with %s\n",
tk_dir.string().c_str(),
tk_compiler.empty() ? "gcc from PATH" : tk_compiler.c_str());
}
}
if (const char *e = std::getenv("PSX_OVERLAY_AUTOCOMPILE_CMD")) {