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

From: Philipp Stephani <[email-masked]>
Date: Sun, 27 Dec 2020 21:30:34 +0100

Am So., 27. Dez. 2020 um 21:12 Uhr schrieb Artem Loenko <[email-masked]>:
>
> Looks strange indeed.
>
> I see that these changes were introduced in this commit – https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-27&id=fda9b3e83a434706c31ab1bee5c15511c0181d5a So, emacs-27 branch does not compile on Apple Silicon as well any more. Also, I believe, it should be at least `arm64-apple-darwin` and not `arm-apple-darwin`. Though, I tried to compile with `arm64-apple-darwin` but got the same error with `temacs`.

I'd agree, but then, the src/Makefile for my emacs-27 worktree has

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 checked LLVM bundled with Xcode 12.3 and LLVM 11.0.0. Both report `arm64-apple-darwin` as a target (the same for `-print-effective-triple`:
>
> > ~/Projects/emacs $ /opt/homebrew/opt/llvm/bin/clang --version
> > clang version 11.0.0
> > Target: arm64-apple-darwin20.2.0
> > Thread model: posix
> > InstalledDir: /opt/homebrew/opt/llvm/bin
>
> > ~/Projects/emacs $ xcrun clang --version
> > Apple clang version 12.0.0 (clang-1200.0.32.28)
> > Target: arm64-apple-darwin20.2.0
> > Thread model: posix
> > InstalledDir: /Volumes/Extended/Archives/Xcode_12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
>
> Though, during the ./configure, `config.guess` identifies the system as `aarch64-apple-darwin`:
>
> > Running ./configure ...
> > ./configure
> > ...
> > checking build system type... aarch64-apple-darwin20.2.0
> > checking host system type... aarch64-apple-darwin20.2.0
> > …
> > Configured for 'aarch64-apple-darwin20.2.0’.
>
> > ~/Projects/emacs $ ./build-aux/config.guess
> > aarch64-apple-darwin20.2.0
>
> It seems that `clang` is good with both versions as a target.
>
> Anyway, the fact is that `temacs` works fine with `aarch64-apple-darwin` target and does not with `arm(64)-apple-darwin`. I do not know much about `temacs` and Emacs internals, if you have any leads or theories to check – let me know, I will try my best. So far, my best idea is that we propagate the target to other tool that does not “understand” `arm64-apple-darwin`.

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.