Subject: Re: bug#45455: [nextstep]: Emacs master does not compile on Apple Silicon (arm64)

From: Artem Loenko <[email-masked]>
Date: Sun, 27 Dec 2020 21:37:23 +0000

> DO_CODESIGN=$(patsubst arm-apple-darwin%,yes,arm-apple-darwin20.2.0)
> 
> indicating that at least here the architecture was detected as
> arm-apple-darwin20.2.0. On master it's aarch64-apple-darwin20.2.0 for
> me as well.

I believe that you see `arm-apple-darwin` in the emacs-27 branch because aarch64 support was incorporated only for Emacs master branch and was not backported. There is a commit – https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5d89a9c2846d32b4726faaf5c8652f3f23dc7d73 <https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5d89a9c2846d32b4726faaf5c8652f3f23dc7d73> with the following changes in the master:

diff --git a/build-aux/config.guess b/build-aux/config.guess
index 92bfc33e29..e94095c5fb 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2020 Free Software Foundation, Inc.
 
-timestamp='2020-04-26'
+timestamp='2020-07-12'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -1342,6 +1342,9 @@ EOF
     *:Rhapsody:*:*)
 	echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
 	exit ;;
+    arm64:Darwin:*:*)
+	echo aarch64-apple-darwin"$UNAME_RELEASE"
+	exit ;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p`
 	case $UNAME_PROCESSOR in

But in the `emacs-27` branch it calculates with a simple `uname -r` – to the `arm-apple-darwin` (I was able to reproduce it locally on the `emacs-27` branch).

> IIUC the only thing that this line does is to check whether to
> codesign the resulting binary. That's necessary on Apple Silicon.
> Maybe we should codesign on all macOS installations? It shouldn't hurt
> even if it's not needed.

Yes, you are right. The problem has nothing to do with `temacs`; it is about signing. I tried to call `codesign` explicitly, and everything works fine in this case. About codesigning for all macOS installations, I am not sure. Such change can break things in many unexpected ways from my point of view. It is better to stay on the safe side.

I see two options:

- Backport `arm64:Darwin:*:*)` support within `config.guess` to emacs-27 branch and switch to `aarch64-apple-darwin` everywhere
- Do not backport, but switch to `aarch64-apple-darwin` everywhere anyway :)

What do you think?

Regards,
Artem Loenko