build: add macOS (Apple Silicon) build support

macOS compiles the existing POSIX/Linux code paths (KYTY_PLATFORM_LINUX)
targeting x86_64 under Rosetta 2. Adds an APPLE branch to the build:
selects Apple's ld64 linker, unsets the Ninja response-file forcing (Apple
ar has no @file support), derives the target arch from CMAKE_OSX_ARCHITECTURES
for cpuinfo/ffmpeg, and re-signs the binary post-build with JIT entitlements
(required to execute written trampolines and Rosetta-translated guest code).

All changes are guarded by if(APPLE); Windows and Linux configuration is
unchanged.

(cherry picked from commit 13be13b7573b9a687cf87531a81e4497ed3de1d5)
This commit is contained in:
Abdullah K.
2026-07-23 04:32:24 +05:00
committed by nmzik
parent e42f6c3892
commit 7921269878
5 changed files with 65 additions and 9 deletions
+9 -1
View File
@@ -68,7 +68,15 @@ set(KYTY_WARNINGS_ARE_ERRORS OFF)
set(KYTY_C_FLAGS "")
set(KYTY_CPP_FLAGS "")
SET(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "")
# Apple's /usr/bin/ar does not understand @response-file syntax, and macOS has a
# large ARG_MAX so response files aren't needed. Note: the Ninja generator forces a
# response file whenever CMAKE_NINJA_FORCE_RESPONSE_FILE is *defined* (it tests
# definedness, not the value), so on Apple it must be fully unset, not set to 0.
if(APPLE)
unset(CMAKE_NINJA_FORCE_RESPONSE_FILE CACHE)
else()
SET(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "")
endif()
if(KYTY_CLANG_CL)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")