Jon Palmisciano

A native build of Emacs for macOS/ARM64

I recently purchased one of the new MacBook Air models with the M1 chip, and I wanted to try out a “fully native” build of Emacs — where “fully native” means:

  • using Emacs 28’s native Elisp compilation; and
  • compiled for ARM64 (rather than running under Rosetta).

There are many different macOS Emacs “distributions” out there, and I wasn’t sure which to choose so I opted to compile Emacs from source myself.

The rest of this post is primarily a guide for my future self, but I’ve published it for anyone else interested in building Emacs from source on macOS. I’m not super familiar with building Emacs from source — these are just the steps that worked for me.

Prerequisites and dependencies

Emacs has a handful of dependencies which can all be installed via Homebrew with the following command:

brew install autoconf texinfo gnutls jansson gcc libgccjit

Next, get the Emacs source code by cloning it from the GitHub mirror:

git clone https://github.com/emacs-mirror/emacs.git --branch emacs-28 --depth 1

Depending on how far in the future you are reading this, the specific branch to use will likely have changed. However, never forget to specify --depth 1 as it reduces the download size and speeds up the clone operation tremendously.

Building (and waiting)

This is the important part. Start by running autogen.sh to generate the appropriate configuration utility, then invoke it as follows:

CFLAGS="-I$(brew --prefix libgccjit)/include -I$(brew --prefix gcc)/include"

# The major version '11' is hardcoded here and needs to match the major version
# of the GCC you have installed.
LDFLAGS="$CFLAGS -L$(brew --prefix gcc)/lib/gcc/11"

./configure --disable-silent-rules --with-xml2 --with-gnutls \
	--with-native-compilation --with-json --with-modules --with-ns \
	--without-mailutils --without-dbus --without-imagemagick --without-rsvg \
	--without-xpm --without-tiff --without-gif --without-lcms2 \
	--without-libsystemd --without-cairo

You may want to adjust the features enabled/disabled as you see fit. Once configure is done running, the rest of the build is rather easy:

make -j8
make install

Assuming all goes well, you should be greeted with a nice “fully-native” Emacs application bundle located in the “nextstep” directory of the Emacs source tree.