It's started with simple program:
#ifdef i386
#warning this is i386
#else
#warning this is NOT i386
#endif
#ifdef x86_64
#warning this is x86_64
#else
#warning this is NOT x86_64
#endif
#ifdef aarch64
#warning this is aarch64
#else
#warning this is NOT aarch64
#endif
#ifdef arm64
#warning this is arm64
#else
#warning this is NOT arm64
#endif
#ifdef arm
#warning this is arm
#else
#warning this is NOT arm
#endif
When cross-compiling on Linux for AArch64 using Linaro toolchain, the pre-processor produces following output:
$ aarch64-linux-gnu-gcc-4.8.2 -Wall -c aarch64.c
aarch64.c:4:2: warning: #warning this is NOT i386 [-Wcpp]
#warning this is NOT i386
^
aarch64.c:10:2: warning: #warning this is NOT x86_64 [-Wcpp]
#warning this is NOT x86_64
^
aarch64.c:14:2: warning: #warning this is aarch64 [-Wcpp]
#warning this is aarch64
^
aarch64.c:22:2: warning: #warning this is NOT arm64 [-Wcpp]
#warning this is NOT arm64
^
aarch64.c:28:2: warning: #warning this is NOT arm [-Wcpp]
#warning this is NOT arm
^
I expect that other cross-compilers define arm64 instead of aarch64 (or both), so there's my patch that causes checking for both. This is all-or-nothing approach, I did not try to investigate whether any of the parts of affected code are compiled on Linux or MacOSX - I altered all places where arm64 was used.
Before applying, it's worth to try if it still builds for ARM64 on MacOSX.