cpu: convert a console EXE with one command or report the first refusal #865
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/872"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by rm-NoobInCoding on 2026-11-23T15:11:51Z.
What this adds
tools/exe_aot.pyconverts one PE32+ x64 EXE into a recompiled Windows EXE with one command. If it can't, it stops and reports the stage that refused. The stages run in order:cl /O2 /MT(/NOIMPLIB /NOEXP, so the provenance export leaves no .lib/.exp)Each run writes
report.jsonwith the input SHA-256, header facts, the import list, the profile and either the generated paths or the refusal. Stale<stem>_aot.*outputs are removed first, so a refusal never leaves an EXE from an earlier run.The only profile is
console-stdio, the existingtools/cpu_stdio_exe_aot.pywith itsgetchar/putchar/fflushbindings. New profiles are one entry inPROFILES. The only change to the existing translator is that its startup-wrapper exception (cpu_exe_io.dll!finish_exe) becomes a namedSTARTUP_ONLYconstant, so the driver applies the same rule. Behavior is unchanged.This does not widen what the lifter can translate. A passing conversion only means the program fits
console-stdio.Test
cpu_exe_aot_convert(tests/cpu/exe_aot_check.py) runs the tool as a subprocess at test time oncpu_crc_lineandcpu_crc_castagnoli:cpu_stdio_exe_aot.translate(..., entry_export="native_entry")byte for bytecpu_exe_io.dllCBF43926\r\nandE3069283\r\nrespectively,00000000\r\n, and no output with exit 1)Negative controls must each exit 1, name the expected stage and leave no
_aotEXE:cpu_exe_original(fixture trace imports)cpu_exe_io.dll!emit_trace,cpu_exe_io.dll!read_selector,cpu_import_provider.dll!mix_argscpu_crc_linefrom the PE entry (no--entry-export)cpu_exe_io.dll!finish_execpu_exe_io.dll.execpu_crc_linewithxor esi, esipatched tocpuidunsupported instruction at RVA 0x103b: cpuid; the earlier successful EXE in the same directory is removed--cxxThe stale-output check found a real issue during development: without
/NOIMPLIB /NOEXPthe linker left.lib/.expbehind after a later refusal.Results
Commit
bdbb574, Windows 11 Pro build 26300, MSVC 19.51 (Visual Studio 18 Community), Python 3.14.4,devpreset.Passed.
148/148 passed, including
cpu_native_crc_lineand the archive tests that usecpu_stdio_exe_aot.py. Hardware tests were not run.tests/docs_links_check.pyandtests/bidi_controls_check.pypass. Docs: new section indocs/experiments.md#converting-an-exe-with-one-commandand a README experiment row.Refs #870
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:38:07Z.
Review fix at
9fa011c: on the previous head, giving the converter a source-built text fixture namedreport.jsoninside the output directory returned a header refusal but overwrote the input with its report. The converter now checks all output paths for input aliases before changing files. The focused fixture checks direct and hard-linked collisions and requires that the input bytes stay unchanged. It still verifies that an ordinary translation refusal clears the earlier generated EXE.ctest --preset release --no-tests=error -R '^cpu_exe_aot_convert$'passed with the original CRC runs and the new controls. Windows CI is rerunning.