Skip to content

win32/arm64: add native Windows ARM64 support - #2

Open
bold84 wants to merge 10 commits into
oven-sh:mobfrom
bold84:win_arm64_reviewable_oven
Open

win32/arm64: add native Windows ARM64 support#2
bold84 wants to merge 10 commits into
oven-sh:mobfrom
bold84:win_arm64_reviewable_oven

Conversation

@bold84

@bold84 bold84 commented Apr 7, 2026

Copy link
Copy Markdown

Summary

  • add native Windows ARM64 target support across configure, build, PE, CRT, and runtime paths
  • add hosted Windows ARM64 -run support, including argv, wargv, env, wenv, stdin, exit, nested -run, backtrace, and libtcc regression coverage
  • add GNU-style ARM64 extended inline asm support, plus ARM64 encoding and error regression tests
  • import grischka's Windows helper files and test hooks (tests/msvcrt_start.c, tests/test-win32.bat, win32/lib/winex.c)

Notes

  • this is the cleaned win_arm64_reviewable series, rebased onto oven-sh/mob to keep the review diff focused on the Windows ARM64 work
  • the branch keeps the currently validated functionality and test coverage rather than reducing scope to minimize diff size

Validation

  • win32\build-tcc.bat -t arm64 -c clang
  • .\tcc -B. ..\win32\test_arm64.c -o test_arm64.exe && .\test_arm64.exe
  • Set-Content test_rstdin.txt 'arm64 stdin'; .\tcc -B. -rstdin test_rstdin.txt -run ..\win32\test_rstdin.c
  • .\tcc -B. ..\tests\tests2\49_bracket_evaluation.c -o test49.exe && .\test49.exe
  • .\tcc -B. -run ..\win32\test_run_argv.c alpha "two words" beta
  • clang -O0 -I.. ..\win32\test_run_arg_cleanup.c -o test_run_arg_cleanup.exe && .\test_run_arg_cleanup.exe alpha beta gamma
  • make test -k
  • make -C tests test2 test3
  • tests\test-win32.bat -p ..\.. -c clang -t arm64

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown

Caution

Review failed

Failed to post review comments

Walkthrough

This pull request adds comprehensive ARM64/AArch64 assembler and code-generation support for Windows PE targets, alongside extensive Windows ARM64 runtime, startup, and test infrastructure. It replaces the ARM64 dummy assembler with a functional backend supporting inline assembly, instruction encoding, and relocation handling, while extending build configuration, CI testing, and test coverage.

Changes

Cohort / File(s) Summary
Workflow and Build Configuration
.github/workflows/build.yml, Makefile, configure, lib/Makefile
Enhanced CI/build system with expanded Windows test targets (MSYS2/CLANG64, ARM64), new test suite targets (tests2 subsets), and refactored native/cross-compilation target detection for ARM64 on Windows.
ARM64 Assembler and Token Definitions
arm64-asm.c, arm64-tok.h
Replaced dummy ARM64 assembler with full functional implementation: instruction dispatch, operand parsing (registers, immediates, addresses, condition codes), instruction encoders, constraint allocation, and inline-asm support for loads/stores, branches, moves, arithmetic, and system instructions.
ARM64 Code Generation and Relocation
arm64-gen.c, arm64-link.c
Refactored instruction encoding with ARM64 macro constants, PE-specific symbol materialization and relocation handling (ADRP/ADD), stack adjustment via __chkstk, vararg/PCS handling improvements, HFA struct support, and extended relocation types (CONDBR19, TSTBR14).
Runtime Support and Exception Handling
lib/bcheck.c, lib/bt-dll.c, lib/bt-exe.c, lib/libtcc1.c, libtcc.c, tcc.c, tccrun.c
Added Windows ARM64-specific runtime features: environment variable retrieval, backtrace formatting/symbolization, process-scoped DLL tracking, run-argv offset tracking, exception context restoration from jump buffer, and I/O flushing.
Compiler Infrastructure and Type System
tccasm.c, tccgen.c, tccpp.c, tccpe.c, tcctok.h, include/tccdefs.h, tcc.h, tcc-doc.texi
Extended assembler comment handling for ARM64, typedef-derived alignment tracking in struct fields, ARM64 operand modifiers, new MinGW setjmp/longjmp tokens, ARM64-specific va_list definition for Windows, PE export parsing for ARM64 images, unwind metadata refactoring, and symbol attribute/state structure extensions.
Windows Headers and Platform Definitions
win32/include/_mingw.h, win32/include/setjmp.h, win32/include/stdlib.h, win32/include/winapi/winnt.h
Added ARM64 architecture detection and macro definitions, ARM64 _JUMP_BUFFER and CONTEXT structures, __mingw_setjmp/__mingw_longjmp declarations, _get_environ/_get_wenviron CRT exports, ARM64 PE machine ID, and DLL characteristics constants.
Windows Startup and Runtime Libraries
win32/lib/chkstk.S, win32/lib/crt1.c, win32/lib/runmain-arm64.S, win32/lib/runrt.c, win32/lib/wincrt1.c, win32/lib/winex.c
Implemented ARM64-specific stack-probing (__chkstk), process-exit handler registration (__tcc_run_on_exit/atexit), Windows -run argument/environment handling with thread-local state, destructor invocation, and global CRT symbol definitions for ARM64.
Windows Build and Test Scripts
win32/build-tcc.bat, tests/test-win32.bat
Enhanced batch-based build system with MSYS2 clang64 support, dynamic compiler/architecture selection, ARM64 library compilation with runrt.o, assembly helper builds, and test harness initialization.
Test Infrastructure
tests/Makefile, tests/pp/Makefile, tests/libtcc_test_mt.c, tests/asm/test-*.c, tests/msvcrt_start.c, tests/tcctest.c
Added ARM64 inline-assembly test suite, reference output selection logic based on architecture/toolchain/UCRT, Windows sleep API declaration, MSVCRT dynamic-link test harness, and adjusted compile-time guards for platform-specific tests.
Test Reference Outputs
tests/test.ref.win32-arm64, tests/test.ref.win32-x86_64-ucrt, tests/tests2/138_arm64_encoding.*, tests/tests2/139_arm64_errors.*, tests/tests2/73_arm64.*, win32/test_*.ref
Golden-output files for ARM64 encoding/error testing, HFA struct argument passing, and Windows command-line/environment argument handling validation.
Windows Test Programs
win32/test_*.c
Comprehensive suite of ARM64-specific test programs: basic arithmetic, inline assembly, backtrace validation, libtcc runtime context preservation, PE field alignment, stdin/stdout I/O, argument/environment variable handling, and exit-handler cleanup.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'win32/arm64: add native Windows ARM64 support' clearly and specifically identifies the main change—adding Windows ARM64 target support—and is directly related to the large changeset covering configure, build, PE, CRT, runtime, inline-asm, and test additions.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, covering native Windows ARM64 support, hosted -run functionality, inline-asm support, test coverage, and imports from helper files—all topics present in the file summaries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jcompagner

jcompagner commented May 17, 2026

Copy link
Copy Markdown

is this (or something like this) planning to be merged into tinycc?
Because we now get very nice development machines (Asus Zenbook A16) where i now work on but this kind of arm64 is not supported is a pity to have

does the original tinycc not already kind of support this now?
TinyCC@30afb50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants