kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

Windows Self-Host (current state and roadmap)

This roadmap tracks bringing kit up as a self-hosted Windows toolchain: cross-compiling the kit binary into a PE/COFF kit.exe and running kit cc (AOT) and kit run (JIT) natively on Windows. The hosted target profile, sysroot mechanics, and VM are described in ../WINDOWS.md; the ABI work is in [windows-abi context]; this document tracks the self-host goal, the baseline already in tree, and the genuinely-open follow-ups.

Targets are PE/COFF, 64-bit only: aarch64-windows (the reference, and what runs natively on the Apple-silicon ARM64 Win11 VM) and x86_64-windows (runs via the in-box x64 emulator on the same VM). The hosted profile is mingw-w64 UCRT via llvm-mingw (not MSVC): kit advertises __MINGW32__/__MINGW64__, never _MSC_VER.

Baseline (done — context, not planned work)

Cross-build + native cc + native JIT all work on aarch64-windows, verified on the VM.

The items below are what is not yet done. The concrete open bugs/blockers are collected first; the numbered sections are the larger roadmap items.

Open bugs / blockers

Concrete defects surfaced during bring-up, each blocking a roadmap item below.

2. x86_64-windows parity

aarch64-windows is the reference. x64 codegen now shares the large-frame stack-probe gate (§Baseline) via abi_stack_probe_interval, and the cross-link now succeeds end to end.

What landed (this cycle):

VM verification status (Prism, Win11 25H2 ARM64):

3. A committed "compile-on-VM" test lane

test/toy/vm.sh windows today cross-compiles the toy cases on the host and only executes on the VM, so it cannot catch self-host compile bugs (the §Baseline stack-probe crash, for one, was invisible to it). The native self-host path (kit.exe compiling on the VM) has been exercised ad hoc. Generalize it into a committed lane (e.g. test/toy/vm.sh windows --native or a new harness) that ships the case sources + a <bindir>/support/rt + the mingw sysroot to the VM, compiles with kit.exe there, runs, and compares .expected. Gotchas to bake in:

4. Distribution + default sysroot

5. Windows 3-stage bootstrap

The self-host milestone: use the cross-built kit.exe on the VM to compile kit's own sources into a stage-2 kit.exe, then stage-3, and assert stage-2 == stage-3 byte-for-byte (cf. BOOTSTRAP.md, and the native-bootstrap analogs scripts/{linux,freebsd}_bootstrap.sh). Unblocked now that the large-frame stack-probe crash and the __FILE__ malformed UCN bug are fixed — kit.exe compiles + links + runs the full Toy AOT corpus (166/166) on the VM, and now compiles the rt tree on the VM cleanly (the on-demand kit cc rt build succeeds). The malformed UCN bug turned out to be a host-path stringization defect, not a self-compile codegen defect, so it does not threaten stage-2==stage-3 identity. Next: confirm kit.exe can compile the full libkit/driver source set on the VM, then add a scripts/windows_bootstrap.sh to drive the VM-side stages and the stage-2==stage-3 byte-identity check.

6. Debugger fault-guard / SEH on Windows

driver/env/windows.c's driver_run_with_crash_guard is a no-op on Windows (the POSIX path uses sigaction + sigsetjmp); a crashing kit run program takes down kit.exe instead of reporting on_crash. The dbg guarded_copy also relies on the VEH backstop rather than __try (kit's C frontend has no SEH). A proper vectored-exception-handler port would give kit run/kit dbg fault isolation on Windows.

Operational notes