feat(platform): add full Windows x86_64 PE32+ cross-compilation support#446
Draft
Guikingone wants to merge 1 commit into
Draft
feat(platform): add full Windows x86_64 PE32+ cross-compilation support#446Guikingone wants to merge 1 commit into
Guikingone wants to merge 1 commit into
Conversation
Guikingone
marked this pull request as draft
July 1, 2026 10:12
Guikingone
force-pushed
the
feat/windows-pe
branch
2 times, most recently
from
July 1, 2026 15:43
1a6888e to
4b7fd88
Compare
Guikingone
force-pushed
the
feat/windows-pe
branch
2 times, most recently
from
July 2, 2026 17:30
aa5e6be to
2ac8b78
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 08:54
2ac8b78 to
5ec3017
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 09:25
5ec3017 to
c8aa4df
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 10:20
c8aa4df to
2d7dcca
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 11:20
2d7dcca to
85541c3
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 14:33
c60d605 to
b8483f1
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 16:16
c7c3d92 to
719394b
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 20:19
719394b to
0240020
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 6, 2026 21:28
0240020 to
c0f1476
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 6, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
2 times, most recently
from
July 7, 2026 07:11
a1b7fa8 to
b0d4620
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 7, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64. # Conflicts: # CHANGELOG.md # CLAUDE.md # docs/internals/builtins/math/mt_rand.md # docs/internals/builtins/math/rand.md # docs/internals/builtins/math/random_int.md # src/codegen/abi/mod.rs # src/codegen/builtins/arrays/call_user_func_array.rs # src/codegen/builtins/system/exit.rs # src/codegen/callable_dispatch.rs # src/codegen/prescan.rs # src/codegen/runtime_callable_invoker.rs # src/codegen_support/abi/bootstrap.rs # src/codegen_support/platform/windows_transform.rs # src/codegen_support/runtime/arrays/random_bytes.rs # src/codegen_support/runtime/emitters.rs # src/pipeline.rs
Guikingone
force-pushed
the
feat/windows-pe
branch
2 times, most recently
from
July 8, 2026 07:58
d2bb042 to
d31d8bf
Compare
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 10, 2026 14:50
a092225 to
740160c
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 10, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
2 times, most recently
from
July 10, 2026 16:54
735ae01 to
d1e9c08
Compare
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Jul 10, 2026
…es builtin Reconstruct PR illegalstudio#446's feature set on top of current main. Windows x86_64 PE target: - Platform::Windows with the MSx64 ABI (rcx/rdx/r8/r9, 32-byte shadow, 16-byte alignment) and ~40 Win32 shim wrappers converting SysV->MSx64 (WriteFile/ReadFile, sockets, file/dir ops, VirtualAlloc/Heap, BCryptGenRandom, ...). - Syscall->shim transform wired into the pipeline + runtime cache (Windows-only) so PE binaries contain no raw Linux syscalls; unmapped syscalls route to __rt_unsupported_syscall instead of a silent trap. - Entry wrapper (MSx64->SysV), MinGW-w64 assembler/linker, kernel32/msvcrt/winmm/ ws2_32/bcrypt/shlwapi link set. --target windows-x86_64 (alias x86_64-pc-windows-gnu); .exe / .dll outputs. CI windows-pe-cross-compile job (MinGW + Wine) wired into the gate. Fix the implicit end-of-main exit code on Windows: emit_exit and emit_exit_with_result_reg now load the code into edi and call the __rt_sys_exit (ExitProcess) shim directly, identical to an explicit exit($n), instead of returning through the MinGW CRT. The CRT's exit() reaches the same rdi-consuming shim, so the old return path left rdi holding leftover data and exited with a garbage nonzero code. random_bytes(int $length): string: - Cryptographically secure random byte string on every supported target (arc4random_buf / getrandom / BCryptGenRandom), fatal on entropy failure or a constant length below 1. - Expressed as a single-source registry home file (src/builtins/math/random_bytes.rs) instead of the legacy hand-maintained tables; excluded from the legacy runtime-callable wrapper as an EIR-only builtin. Builtin docs + registry JSON regenerated. Callable-invoker ABI on Windows x86_64: - The descriptor-based runtime callable invoker read its descriptor from a hardcoded rdi, but on Windows the caller passes it in the MSx64 first arg (rcx); read it from int_arg_reg_name(target, 0) instead. - The invoker clone helpers passed arguments to the __rt_array_clone_shallow / __rt_array_to_mixed / __rt_hash_clone_shallow / __rt_hash_to_mixed / __rt_array_new runtime helpers via int_arg_reg_name, which returns the target user-call ABI (rcx/rdx on Windows); those helpers use the System V AMD64 ABI on every x86_64 target and read rdi/rsi. Add runtime_int_arg_reg_name (SysV on all x86_64, platform ABI on AArch64) and route the four helper call sites through it. No-op on Linux and AArch64.
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 10, 2026 17:41
d1e9c08 to
6cb893a
Compare
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 23, 2026 17:42
24c5d66 to
1db31d8
Compare
Guikingone
force-pushed
the
feat/windows-pe
branch
8 times, most recently
from
July 24, 2026 07:19
d3c8bd9 to
bbab487
Compare
Guikingone
force-pushed
the
feat/windows-pe
branch
from
July 24, 2026 07:21
bbab487 to
51714e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #379.
Summary
This pull request adds an experimental
windows-x86_64backend that producesstandalone PE32+ executables and brings the compiler, runtime, bridge crates,
Magician/eval, TLS, and web mode onto native Windows validation paths.
The implementation uses the GNU/MinGW Windows ABI. The accepted
x86_64-pc-windows-msvcspelling is a CLI compatibility alias only; it does notclaim MSVC ABI output. The branch is rebased on the current
mainand remainsone squashed commit. Windows stays experimental until every strict gate below
is green on the same revision.
What is included
Target, PE/COFF, and toolchain support
windows-x86_64/x86_64-pc-windows-gnutarget selection.GNU Windows ABI.
argc/argv, process exit, exceptions,callbacks, fibers, refcounted values, unwind records, and loader mitigations.
running under Rust's native MSVC host toolchain.
and the PE load-configuration directory can be emitted as one validated unit.
Windows ABI and runtime
and Microsoft x64 ABI imports, including shadow space, integer/floating
register classes, stack arguments, variadics, callbacks, and indirect calls.
metadata, directory iteration, streams, processes, clocks, entropy, sockets,
DNS, synchronization, and console/file I/O.
realpath/stat/lstat/fstatmetadata, readonly/link/executable modes, reparse-point probing, dangling
symlinks,
tempnam,tmpfile, loopbacksocketpair,stream_isatty, andstream timeout behavior.
tempnam()contract for prefix basenames, Windows pathseparators, the 63-byte prefix limit, and the
falsefailure sentinel.chown()/chgrp()visible with Windows failure semantics whileomitting
lchown()/lchgrp()exactly as php-src does withoutHAVE_LCHOWN.Direct calls, namespace fallback, user redeclarations, first-class callables,
dynamic dispatch, Reflection, eval,
function_exists(), andis_callable()all use the same target-aware catalog.
fopenbase-mode and suffix surface, Windowstemporary-file deletion, complete 64-bit Winsock handles, and the correct
close order for filters, TLS sessions, stream state, CRT descriptors, and
sockets.
ordinary I/O and zlib, bzip2, iconv, and user-filter paths;
fseek()andrewind()use the same handle mapping.__FILE__,__DIR__, closure names, and EIR source metadata.the runtime can negotiate; Windows omits Unix-domain transports and all
targets omit unavailable SSLv2/SSLv3 aliases.
longresults before 64-bit consumers and derivesPHP_EOL,DIRECTORY_SEPARATOR, andPATH_SEPARATORfrom the target.Processes, shell behavior, eval, and web
proc_open()descriptor inheritance and sparsedescriptor behavior,
proc_close(),proc_terminate(), andproc_get_status(). Windows reportscached: false, while Unix preservesPHP's post-exit cached transition.
order, ignores the keys like php-src, and preserves raw numeric environment
entries while skipping empty converted values.
correctly through CRT
argvconstruction.randomness, time, string, callable, and target-specific builtin behavior.
--webas a PE program with exported ABI validation, HTTPsuccess/error responses, Ctrl-C shutdown, watchdog termination, and clean
--max-requestsexit.TLS and stream contexts
paths.
and enterprise trust anchors remain visible; other targets retain the
deterministic bundled root set.
ElephcTlsClientOptionsstructure(options layout ABI v1) shared by HTTPS connects and STARTTLS attachment.
verify_peer,verify_peer_name, andallow_self_signed, pluspeer_name, additivecafile/capath, and combinablelocal_cert/local_pk.local_pkas optional when the key is present inlocal_cert, andignores
local_pkwithout a client certificate, matching php-src.allow_self_signedto a valid depth-zero genuinely self-signedleaf. It never accepts an arbitrary untrusted leaf, never bypasses hostname
validation, and always verifies TLS 1.2/1.3 handshake signatures.
0and"0"arefalse; any other non-zero integer is true).
enforces supported TLS 1.2/1.3 client masks, and reuses the source TLS
configuration/session cache when
session_streamis provided.zero-byte TLS read as clean EOF, and rejects oversized, truncated, or
unrewindable response streams with balanced handle cleanup.
Rust, preserving retryable
WouldBlock/TimedOutresults without markingstreams as EOF.
Final php-src audit
The implementation was audited against the current official php-src Windows,
stream, TLS, process, shell, and filesystem paths:
win32/ioutil.cwin32/sockets.cwin32/build/config.w32.h.inmain/streams/xp_socket.cmain/streams/plain_wrapper.cmain/php_open_temporary_file.cext/standard/streamsfuncs.cext/standard/filestat.cext/standard/proc_open.cext/standard/exec.cext/openssl/xp_ssl.cThe last comparison found and closed the remaining gaps around native Windows
trust roots, TLS policy independence and true self-signed handling, client key
fallback, STARTTLS crypto-method/session propagation, complete HTTPS I/O,
target-aware
lchown/lchgrpvisibility, namespace and callable resolution,tempnam()failure/prefix semantics,proc_open()command/environmentmarshalling,
proc_get_status().cached, shell escaping, stream-filter registerpreservation, Windows stream seeking, and target-path normalization.
CI and acceptance gates
Cross-compilation gate
Windows PE Cross-Compile Testsand the independentWindows PE LLVM/LLD Testsrun on Ubuntu with MinGW-w64 and Wine. Together they:binaries.
Native bridge gate
Windows Native PE & Bridge Testsruns on Windows Server 2025. It:windows_peintegration module; andStrict native codegen gate
The runnable
ci-profile codegen inventory is split into 16 deterministicpartitions and executed directly on Windows Server 2025. There is no allowlist
or known-failure exemption: each runnable fixture must appear exactly once and
every shard must succeed. The aggregate Windows gates are required by the
top-level
Build & Testjob.Validation
Focused local validation performed during development includes:
regressions;
cargo fmt --all -- --check, Cargo metadata validation,assembly-comment validation,
git diff --check, ancestry, squash, andunmerged-file checks.
The complete supported-target and native-Windows matrices remain CI-owned.
Promotion criteria
Windows can move into the first-class supported-target matrix only when one
revision satisfies all of the following:
green;
reduced semantics that the project claims to support.
Until then, documentation and diagnostics deliberately label the target
experimental.