xref: /trunk/main/nss/nss_macosx.patch (revision 7b0e10cf231204097c52931dd9077938d539c487)
1diff -ur misc/nss-3.39/nspr/configure misc/build/nss-3.39/nspr/configure
2--- misc/nss-3.39/nspr/configure    2018-08-28 05:42:28.000000000 -0700
3+++ misc/build/nss-3.39/nspr/configure  2020-10-06 07:41:59.563345390 -0700
4@@ -6570,8 +6570,14 @@
5     AS='$(CC) -x assembler-with-cpp'
6     CFLAGS="$CFLAGS -Wall -fno-common"
7     case "${target_cpu}" in
8+        aarch64|arm64)
9+            CPU_ARCH=arm64
10+            ;;
11         arm*)
12-            CPU_ARCH=arm
13+            # On Apple Silicon the bundled config.guess reports the bare CPU
14+            # "arm"; the macOS arch name is "arm64" (plain "arm" makes ld pick
15+            # the nonexistent armv4t).  Treat any arm on Darwin as arm64.
16+            CPU_ARCH=arm64
17             ;;
18         i*86*|x86_64)
19             if test -n "$USE_64"; then
20diff -ur misc/nss-3.39/nss/coreconf/Darwin.mk misc/build/nss-3.39/nss/coreconf/Darwin.mk
21--- misc/nss-3.39/nss/coreconf/Darwin.mk    2018-08-31 05:55:53.000000000 -0700
22+++ misc/build/nss-3.39/nss/coreconf/Darwin.mk  2020-10-06 07:51:49.590356560 -0700
23@@ -32,7 +32,13 @@
24 endif
25 else
26 ifeq (arm,$(CPU_ARCH))
27-# Nothing set for arm currently.
28+# Apple Silicon: "uname -p" reports "arm", but NSS uses "aarch64" as its
29+# 64-bit ARM token.  freebl's Makefile selects the 64-bit HACL crypto
30+# (e.g. Hacl_Poly1305_64.c) only for CPU_ARCH=aarch64, which also matches the
31+# __aarch64__ macro the compiler defines and that chacha20poly1305.c keys on;
32+# leaving it as "arm" builds the 32-bit sources and the 64-bit symbol refs go
33+# unresolved.  No -arch flag needed -- the build is native arm64.
34+override CPU_ARCH = aarch64
35 else
36 OS_REL_CFLAGS  = -Dppc
37 CC              += -arch ppc
38diff -ur misc/nss-3.39/nss/lib/sqlite/config.mk misc/build/nss-3.39/nss/lib/sqlite/config.mk
39--- misc/nss-3.39/nss/lib/sqlite/config.mk  2018-08-31 05:55:53.000000000 -0700
40+++ misc/build/nss-3.39/nss/lib/sqlite/config.mk    2018-09-10 10:36:01.074375000 -0700
41@@ -35,9 +35,9 @@
42 # OSAtomicCompareAndSwapPtrBarrier, which is only available on Mac OS X 10.5
43 # (Darwin 9.0) and later. Define SQLITE_WITHOUT_ZONEMALLOC to disable
44 # that code for older versions of Mac OS X. See bug 820374.
45-DARWIN_VER_MAJOR := $(shell uname -r | cut -f1 -d.)
46-DARWIN_LT_9 := $(shell [ $(DARWIN_VER_MAJOR) -lt 9 ] && echo true)
47-ifeq ($(DARWIN_LT_9),true)
48+OSX_TARGET_MINOR := $(shell echo $(MACOSX_DEPLOYMENT_TARGET) | cut -f2 -d.)
49+OSX_MINOR_LT_5 := $(shell [ $(OSX_TARGET_MINOR) -lt 5 ] && echo true)
50+ifeq ($(OSX_MINOR_LT_5),true)
51 OS_CFLAGS += -DSQLITE_WITHOUT_ZONEMALLOC
52 endif
53 endif # Darwin
54