Skip to content

Commit 45d29c8

Browse files
authored
Merge pull request #497 from usertam/patch/compile-both-arm64-arm64e
Compile for arm64 on darwin again
2 parents 6714b98 + 264e8ef commit 45d29c8

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

Makefile

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,4 @@ distclean:
3333
$(MAKE) $(SELECTOR) -C src distclean
3434
$(MAKE) $(SELECTOR) -C test distclean
3535

36-
macarm64:
37-
$(MAKE) $(SELECTOR) -C src clean
38-
$(MAKE) $(SELECTOR) -C src distclean
39-
$(MAKE) $(SELECTOR) -C src all
40-
# $(MAKE) $(SELECTOR) -C test all
41-
# $(MAKE) $(SELECTOR) -C test distclean
42-
$(MAKE) $(SELECTOR) -C src install
43-
$(MAKE) $(SELECTOR) -C man install
44-
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/share/doc/faketime/"
45-
$(INSTALL) -m0644 README "${DESTDIR}${PREFIX}/share/doc/faketime/README"
46-
$(INSTALL) -m0644 NEWS "${DESTDIR}${PREFIX}/share/doc/faketime/NEWS"
47-
48-
macarm64full:
49-
$(MAKE) $(SELECTOR) -C src clean
50-
$(MAKE) $(SELECTOR) -C src distclean
51-
$(MAKE) $(SELECTOR) -C src all
52-
$(MAKE) $(SELECTOR) -C test all
53-
# $(MAKE) $(SELECTOR) -C test distclean
54-
5536
.PHONY: all test install uninstall clean distclean

src/Makefile.OSX

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,16 @@ PREFIX ?= /usr/local
5858
CFLAGS += -DFAKE_SLEEP -DFAKE_INTERNAL_CALLS -DPREFIX='"'${PREFIX}'"' $(FAKETIME_COMPILE_CFLAGS) -DMACOS_DYLD_INTERPOSE -DFAKE_SETTIME
5959
LIB_LDFLAGS += -dynamiclib -current_version 0.9.11 -compatibility_version 0.7
6060

61-
# ARM64 MacOS (M1/M2/M3/Apple Silicon/etc) processors require a target set as their current version, or they
62-
# will receive the following error:
63-
# 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'))
64-
# 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'))
65-
# Outputs `arm64` on ARM64
66-
OS := $(shell uname -m)
67-
# Outputs a number, eg 14.4 for MacOS Sonoma 14.4
68-
MACOS_PRODUCT_VERSION := $(shell sw_vers --productVersion | cut -d. -f1,2)
61+
# From macOS 13 onwards, system binaries are compiled against the new arm64e ABI on Apple Silicon.
62+
# These arm64e binaries enforce Pointer Authentication Code (PAC), and will refuse to run with
63+
# "unprotected" arm64 libraries. Meanwhile, older platforms might not recognize the new arm64e ABI.
6964

70-
# Check if arm64 is in OS, if so, add the target
71-
ifeq ($(OS),arm64)
72-
CFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
73-
LIB_LDFLAGS += -target arm64e-apple-macos$(MACOS_PRODUCT_VERSION)
65+
# Therefore, we now compile for two ABIs at the same time, producing a fat library of arm64e and arm64,
66+
# so in the end the OS gets to pick which architecture it wants at runtime.
67+
ARCH := $(shell uname -m)
68+
69+
ifeq ($(ARCH),arm64)
70+
CFLAGS += -arch arm64e -arch arm64
7471
endif
7572

7673
SONAME = 1

0 commit comments

Comments
 (0)