feat(windows): a Windows target for ludicc, and the compiler builds itself there

--target <triple> (default: the host, from OS=Windows_NT) selects the Windows
runtime. emit_win.ludic defines the POSIX names the backend already calls over
the UCRT and Win32 in IR, so rename replaces an existing file, ftell is 64-bit,
and fopen is binary. Known folders follow %APPDATA% / %LOCALAPPDATA% / %TEMP%,
and the driver speaks cmd.exe, writes .exe outputs and finds LLVM's clang.

Verified: macOS three-stage fixpoint, ludic-dev test 135/135, and on Windows
the Mac-emitted Windows IR and the Windows-built compiler's IR are identical
through two generations.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-13 01:59:41 +03:00
parent 572e09b2b1
commit 5801005fca
15 changed files with 23292 additions and 21806 deletions

View file

@ -91,13 +91,15 @@ function emit_mime_ns(meth: pointer, e: Node) -> Val {
# emit_fs_prelude — the Fs/Path/Mime runtime, emitted once per program that uses
# any of the three namespaces (g_uses_fsrt). Pure libc + byte IR.
function emit_fs_prelude() -> void {
emith("declare i32 @access(ptr, i32)\n")
emith("declare i32 @mkdir(ptr, i32)\n")
emith("declare i32 @remove(ptr)\n")
emith("declare i32 @rename(ptr, ptr)\n")
emith("declare ptr @opendir(ptr)\n")
emith("declare ptr @readdir(ptr)\n")
emith("declare i32 @closedir(ptr)\n")
if not g_target_win { # defined by emit_win_prelude on Windows
emith("declare i32 @access(ptr, i32)\n")
emith("declare i32 @mkdir(ptr, i32)\n")
emith("declare i32 @rename(ptr, ptr)\n")
emith("declare ptr @opendir(ptr)\n")
emith("declare ptr @readdir(ptr)\n")
emith("declare i32 @closedir(ptr)\n")
}
emit_fs_common()
emit_fs_path()
emit_fs_io()