Merge pull request #497 from usertam/patch/compile-both-arm64-arm64e

Compile for arm64 on darwin again
This commit is contained in:
Wolfgang Hommel
2025-06-03 21:48:40 +02:00
committed by GitHub
2 changed files with 9 additions and 31 deletions

View File

@@ -33,23 +33,4 @@ distclean:
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C test distclean
macarm64:
$(MAKE) $(SELECTOR) -C src clean
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C src all
# $(MAKE) $(SELECTOR) -C test all
# $(MAKE) $(SELECTOR) -C test distclean
$(MAKE) $(SELECTOR) -C src install
$(MAKE) $(SELECTOR) -C man install
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/share/doc/faketime/"
$(INSTALL) -m0644 README "${DESTDIR}${PREFIX}/share/doc/faketime/README"
$(INSTALL) -m0644 NEWS "${DESTDIR}${PREFIX}/share/doc/faketime/NEWS"
macarm64full:
$(MAKE) $(SELECTOR) -C src clean
$(MAKE) $(SELECTOR) -C src distclean
$(MAKE) $(SELECTOR) -C src all
$(MAKE) $(SELECTOR) -C test all
# $(MAKE) $(SELECTOR) -C test distclean
.PHONY: all test install uninstall clean distclean

View File

@@ -58,19 +58,16 @@ 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
# ARM64 MacOS (M1/M2/M3/Apple Silicon/etc) processors require a target set as their current version, or they
# will receive the following error:
# dyld[6675]: terminating because inserted dylib '/usr/local/lib/faketime/libfaketime.1.dylib' could not be loaded: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/faketime/libfaketime.1.dylib' (no such file), '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e'))
# dyld[6675]: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/faketime/libfaketime.1.dylib' (no such file), '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e'))
# Outputs `arm64` on ARM64
OS := $(shell uname -m)
# Outputs a number, eg 14.4 for MacOS Sonoma 14.4
MACOS_PRODUCT_VERSION := $(shell sw_vers --productVersion | cut -d. -f1,2)
# 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.
# Check if arm64 is in OS, if so, add the target
ifeq ($(OS),arm64)
CFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
LIB_LDFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
# 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