[simulator/macos] Add universal binary support for x86_64 and ARM64

Build universal macOS simulator binaries that work on both Intel and Apple Silicon Macs by default. The build system now:
- Defaults to building for both x86_64 and ARM64 architectures
- Uses lipo to create universal binaries
- Allows single-architecture builds via ARCHS=arm64 or ARCHS=x86_64
- Conditionally includes the appropriate assembly files for each architecture
This commit is contained in:
Martin
2025-09-22 11:51:29 +02:00
committed by Yaya-Cout
parent 696747a9a0
commit 59db12e78e
3 changed files with 42 additions and 2 deletions

View File

@@ -5,7 +5,9 @@ APPLE_PLATFORM = macos
APPLE_PLATFORM_MIN_VERSION = 10.10
EPSILON_TELEMETRY ?= 0
ARCHS = x86_64
# Build universal binary for both x86_64 and ARM64 by default
# Can be overridden with ARCHS=arm64 or ARCHS=x86_64 for single architecture builds
ARCHS ?= x86_64 arm64
ifdef ARCH
BUILD_DIR := $(BUILD_DIR)/$(ARCH)

View File

@@ -11,13 +11,30 @@ ion_src += $(addprefix ion/src/simulator/shared/, \
dummy/keyboard_callback.cpp \
dummy/window_callback.cpp \
clipboard_helper.cpp \
collect_registers_x86_64.s \
collect_registers.cpp \
haptics.cpp \
journal.cpp \
store_script.cpp \
)
# Include architecture-specific assembly files
# When building for a specific architecture (via ARCH variable)
ifdef ARCH
ifeq ($(ARCH),arm64)
ion_src += ion/src/simulator/shared/collect_registers_arm64.s
else
ion_src += ion/src/simulator/shared/collect_registers_x86_64.s
endif
else
# When building universal binary, include both
ifneq ($(filter arm64,$(ARCHS)),)
ion_src += ion/src/simulator/shared/collect_registers_arm64.s
endif
ifneq ($(filter x86_64,$(ARCHS)),)
ion_src += ion/src/simulator/shared/collect_registers_x86_64.s
endif
endif
ifeq ($(EPSILON_TELEMETRY),1)
ion_src += ion/src/simulator/shared/dummy/telemetry_init.cpp
ion_src += ion/src/shared/telemetry_console.cpp

View File

@@ -0,0 +1,21 @@
.text
.global _collect_registers
_collect_registers:
// Save callee-saved registers to the buffer pointed by x0
// ARM64 callee-saved registers: x19-x28, x29 (fp), x30 (lr), sp
stp x19, x20, [x0, #0]
stp x21, x22, [x0, #16]
stp x23, x24, [x0, #32]
stp x25, x26, [x0, #48]
stp x27, x28, [x0, #64]
stp x29, x30, [x0, #80]
// Save stack pointer
mov x1, sp
str x1, [x0, #96]
// Return current stack pointer
mov x0, sp
ret