From ff5d3b4874a550e25d73a47a1967aa9bf65a02ff Mon Sep 17 00:00:00 2001 From: Benjamin Oldenburg Date: Sat, 4 Apr 2026 16:29:28 +0200 Subject: [PATCH] arm64-win32 support : configure & Makefiles from: https://github.com/bold84/tinycc Author: Benjamin Oldenburg 2026-04-04 16:29:28 Committer: Benjamin Oldenburg 2026-04-04 16:29:28 Branch: win_arm64_clean Commit: 8b5ab1bb0141e66887bfbc4051688a3e478701a2 Also here: https://repo.or.cz/tinycc.git/shortlog/refs/mob/mob_bold84/win_arm64_clean This and the followup commits on mob is selected parts of that original branch. So it is not everything. It is not, for example: - unrelated whitespace changes in many files - a "pin msvcrt.dll" feature in tccpe.c (why that) - a native getenv() replacement in tcc.c (why that) - larger changes to the win32/lib runtime and tccrun.c (not needed) - a very gcc specific detail for struct alignent in tccgen.c - a custom set/longjmp implementation/replacement (not needed) - lots of rather basic test files in the win32 folder - a 'tests/asm' folder with some files (one file renamed to 140_test...c) - a .docs folder with one file --- Makefile | 8 +++++--- configure | 6 +++++- lib/Makefile | 1 + tests/Makefile | 1 + tests/pp/Makefile | 1 + tests/tests2/Makefile | 16 ++++++++++++++++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d21f1cad..4491bd9d 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ ifdef CONFIG_WIN32 ifneq ($(CONFIG_debug),yes) LDFLAGS += -s endif - NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32) + NATIVE_TARGET = $(if $(findstring arm64,$(ARCH)),arm64-win32,$(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)) else CFG = -unx LIBS+=-lm @@ -113,6 +113,7 @@ DEF-arm64-osx = $(DEF-arm64) -DTCC_TARGET_MACHO DEF-arm64-FreeBSD = $(DEF-arm64) -DTARGETOS_FreeBSD DEF-arm64-NetBSD = $(DEF-arm64) -DTARGETOS_NetBSD DEF-arm64-OpenBSD = $(DEF-arm64) -DTARGETOS_OpenBSD +DEF-arm64-win32 = $(DEF-arm64) -DTCC_TARGET_PE DEF-riscv64 = -DTCC_TARGET_RISCV64 DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD @@ -130,7 +131,7 @@ TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info all: $(PROGS) $(TCCLIBS) $(TCCDOCS) # cross compiler targets to build -TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67 +TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm64-win32 arm-wince c67 TCC_X += riscv64 arm64-osx # TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi @@ -212,8 +213,9 @@ arm-fpa-ld_FILES = $(arm_FILES) arm-vfp_FILES = $(arm_FILES) arm-eabi_FILES = $(arm_FILES) arm-eabihf_FILES = $(arm_FILES) -arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c +arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c arm64-tok.h arm64-osx_FILES = $(arm64_FILES) tccmacho.c +arm64-win32_FILES = $(arm64_FILES) tccpe.c c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c riscv64_FILES = $(CORE_FILES) riscv64-gen.c riscv64-link.c riscv64-asm.c diff --git a/configure b/configure index c1abffc9..b0387747 100755 --- a/configure +++ b/configure @@ -266,7 +266,11 @@ default os_release "$(uname -r)" case $buildos in Windows_NT|MINGW*|MSYS*|CYGWIN*) buildos="WIN32" - test "$MSYSTEM" = "MINGW32" && cpu_sys=i386 + case "$MSYSTEM" in + MINGW32) cpu_sys=i386 ;; + MINGW64) cpu_sys=x86_64 ;; + CLANGARM64|MINGW_ARM64) cpu_sys=arm64 ;; + esac ;; Linux) if test "$(uname -o)" = "Android"; then diff --git a/lib/Makefile b/lib/Makefile index 9eddc526..98126ea4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -65,6 +65,7 @@ OBJ-i386-win32 = $(I386_O) chkstk.o $(WIN_O) OBJ-x86_64-win32 = $(X86_64_O) chkstk.o $(WIN_O) OBJ-arm64 = $(ARM64_O) $(LIN_O) OBJ-arm64-osx = $(ARM64_O) $(OSX_O) +OBJ-arm64-win32 = $(ARM64_O) chkstk.o $(WIN_O) OBJ-arm = $(ARM_O) $(LIN_O) OBJ-arm-fpa = $(OBJ-arm) OBJ-arm-fpa-ld = $(OBJ-arm) diff --git a/tests/Makefile b/tests/Makefile index 6e0f3bd6..410bbc8e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -309,6 +309,7 @@ CROSS-TGTS = \ arm-NetBSD \ arm-wince \ arm64 \ + arm64-win32 \ arm64-osx \ arm64-FreeBSD \ arm64-NetBSD \ diff --git a/tests/pp/Makefile b/tests/pp/Makefile index 7e989c99..7a5a6b5c 100644 --- a/tests/pp/Makefile +++ b/tests/pp/Makefile @@ -46,6 +46,7 @@ clean: rm -f *.output 02.test : DIFF_OPTS += -w +16.test : DIFF_OPTS += -B # 15.test : DIFF_OPTS += -I"^XXX:" # diff options: diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 0726e99d..b01009c1 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -48,6 +48,21 @@ ifeq (-$(CONFIG_WIN32)-,-yes-) SKIP += 117_builtins.test # win32 port doesn't define __builtins SKIP += 124_atomic_counter.test # No pthread support endif +ifneq (,$(filter arm% riscv%,$(ARCH))) + SKIP += 85_asm-outside-function.test + SKIP += 98_al_ax_extend.test + SKIP += 99_fastcall.test + SKIP += 127_asm_goto.test +endif +ifeq (,$(filter arm64 aarch64,$(ARCH))) + SKIP += 138_arm64_encoding.test + SKIP += 139_arm64_errors.test +endif +ifneq (,$(findstring win32,$(CROSS_TARGET))) + SKIP += 106_versym.test + SKIP += 114_bound_signal.test + SKIP += 124_atomic_counter.test +endif ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS))) SKIP += 106_versym.test # no pthread_condattr_setpshared SKIP += 114_bound_signal.test # libc problem signal/fork @@ -73,6 +88,7 @@ endif # These tests run several snippets from the same file one by one 60_errors_and_warnings.test : FLAGS += -dt +139_arm64_errors.test : FLAGS += -dt 96_nodata_wanted.test : FLAGS += -dt # Always generate certain .expects (don't put these in the GIT),