Flaky Goodness

Upgrading to Emacs 28.1 on Apple Silicon (M1) Macs

April 10, 2022

This is an update of sorts to my previous Emacs build recipe and late-night Emacs-on-M1 twitter thread.

The Emacs Mac Port has been updated for Emacs 28.1 and here are the steps I used to build and install it on my M1 MacBook Air. Overall the process seems much smoother than the pre-release build experience but as always YMMV.

Install/re-install dependencies

brew reinstall gcc
brew install libgccjit texinfo
brew ln texinfo --force

I’m not sure why it was necessary to reinstall gcc (maybe an architecture issue?), but it seemed to help with a build error in a subsequent step. Also texinfo provides an updated makeinfo which is now no longer optional in the Emacs build process.

Add makeinfo to path

Add this to your shell path (necessary so that the makeinfo provided by texinfo is seen before the older macOS-provided version).

/opt/homebrew/opt/texinfo/bin

Install/re-install Xcode command-line tools

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Again, something was wedged in the subsequent build process until I took this step, as recommeded in this GitHub thread.

Clone Emacs

These steps also apply the (optional) multi-tty patch that I’ve written about before.

git clone https://bitbucket.org/mituharu/emacs-mac
cd emacs-mac git
checkout emacs-28.1-mac-9.0
autoreconf -i
wget https://gist.github.com/genegoykhman/6effe7fa25696c49d0519af877f5fb42/raw -O multi-tty.patch
git apply multi-tty.patch

Configure and build

./configure \
  --with-native-compilation \
  --with-modules \
  --enable-mac-app \
  --prefix=/Applications/Emacs.app/Contents/Resources

make install

Confirm your emacsclient is linked to the right place

The above steps will update your /Applications/Emacs.app in place, so if you had emacsclient in a different subdirectory (as I did) you may want to replace any symbolic links to the newly build version at /Applications/Emacs.app/Contents/Resources/bin/emacsclient.

Starting Emacs

If all goes well you should be able to start Emacs and (emacs-version) will report 28.1. The new native-compilation feature will churn through your startup Elisp and probably spew a ton of warnings, but eventually you’ll notice that Emacs feels much zippier.

If you don’t see any (comp) warnings on first startup you might just want to check that native compilation is working … (fboundp 'native-compile-async) should return t.