Skip to content

Commit 656aca0

Browse files
committed
Add macOS aarch64 (Apple Silicon) build support
- Add __aarch64__ and __arm__ cases to the macOS architecture block in q_platform.h (the existing aarch64 support was only in the Linux block) - Normalize arm/arm64 to aarch64 in the Makefile since uname -p returns 'arm' on Apple Silicon - Only set HAVE_VM_COMPILED on architectures that have a bytecode compiler (x86, x86_64, ppc, ppc64) so aarch64 falls back to the interpreter - Add -arch arm64 optimization flag for darwin/aarch64
1 parent e8f5ed1 commit 656aca0

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ ifeq ($(COMPILE_ARCH),axp)
8080
COMPILE_ARCH=alpha
8181
endif
8282

83+
ifeq ($(COMPILE_ARCH),arm)
84+
COMPILE_ARCH=aarch64
85+
endif
86+
ifeq ($(COMPILE_ARCH),arm64)
87+
COMPILE_ARCH=aarch64
88+
endif
89+
8390
ifndef ARCH
8491
ARCH=$(COMPILE_ARCH)
8592
endif
@@ -458,7 +465,9 @@ else # ifeq Linux
458465
#############################################################################
459466

460467
ifeq ($(PLATFORM),darwin)
461-
HAVE_VM_COMPILED=true
468+
ifneq ($(findstring $(ARCH),x86 x86_64 ppc ppc64),)
469+
HAVE_VM_COMPILED=true
470+
endif
462471
LIBS = -framework Cocoa
463472
CLIENT_LIBS=
464473
RENDERER_LIBS=
@@ -482,6 +491,9 @@ ifeq ($(PLATFORM),darwin)
482491
ifeq ($(ARCH),x86_64)
483492
OPTIMIZEVM += -arch x86_64 -mfpmath=sse
484493
endif
494+
ifeq ($(ARCH),aarch64)
495+
OPTIMIZEVM += -arch arm64
496+
endif
485497

486498
# When compiling on OSX for OSX, we're not cross compiling as far as the
487499
# Makefile is concerned, as target architecture is specified as a compiler

code/qcommon/q_platform.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
161161
#define idx64 1
162162
#define ARCH_STRING "x86_64"
163163
#define Q3_LITTLE_ENDIAN
164+
#elif defined __aarch64__
165+
#define ARCH_STRING "aarch64"
166+
#define Q3_LITTLE_ENDIAN
167+
#elif defined __arm__
168+
#define ARCH_STRING "arm"
169+
#define Q3_LITTLE_ENDIAN
164170
#endif
165171

166172
#define DLL_EXT ".dylib"

0 commit comments

Comments
 (0)