From 264e8efad74ea3418b20e603271cbd66f0a2034d Mon Sep 17 00:00:00 2001 From: usertam Date: Sun, 1 Jun 2025 22:50:46 +0800 Subject: [PATCH] Makefile.OSX: compile a fat library of both arm64e and arm64 --- src/Makefile.OSX | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Makefile.OSX b/src/Makefile.OSX index 4743437..9bdf922 100644 --- a/src/Makefile.OSX +++ b/src/Makefile.OSX @@ -58,6 +58,18 @@ PREFIX ?= /usr/local CFLAGS += -DFAKE_SLEEP -DFAKE_INTERNAL_CALLS -DPREFIX='"'${PREFIX}'"' $(FAKETIME_COMPILE_CFLAGS) -DMACOS_DYLD_INTERPOSE -DFAKE_SETTIME LIB_LDFLAGS += -dynamiclib -current_version 0.9.11 -compatibility_version 0.7 +# From macOS 13 onwards, system binaries are compiled against the new arm64e ABI on Apple Silicon. +# These arm64e binaries enforce Pointer Authentication Code (PAC), and will refuse to run with +# "unprotected" arm64 libraries. Meanwhile, older platforms might not recognize the new arm64e ABI. + +# Therefore, we now compile for two ABIs at the same time, producing a fat library of arm64e and arm64, +# so in the end the OS gets to pick which architecture it wants at runtime. +ARCH := $(shell uname -m) + +ifeq ($(ARCH),arm64) + CFLAGS += -arch arm64e -arch arm64 +endif + SONAME = 1 LIBS = libfaketime.${SONAME}.dylib BINS = faketime