This is an experimental build of the emacs-mac (aka Carbon1 Emacs) port of emacs, updated for Emacs v30.2, and Emacs master.
Warning
This is an experimental build of emacs-mac; there will certainly be bugs. We are looking for feedback and testing from experienced users. If you are familiar with or willing to learn about running new builds of Emacs, including under a debugger, perfect. If you are a Mac developer familiar with ObjC or Mac Window frameworks, even better (get in touch)! Other users should stick to the official NS build or recent v29.4 emacs-mac release for now.
Note
Branch organization and naming are subject to change.
Known working systems:
- MacOS 26
- MacOS 15 (Sequoia) on ARM64 (M1, M2, M3, M4), X86_64 (Intel)
- MacOS 14 (Sonoma) on ARM64 (M1, M3)
- MacOS 12 (Monterey) on X86_64 (Intel)
Please see the discussion for advice on build configurations for your system.
Important
Please start a discussion to report your build experiences, even if you encounter no problems. Mention your OS version, CPU, which branch you built, and any other relevant details, including the build/configure flags you used.
This build is kept current with the emacs-30 release branch.
For an experimental build synced with Emacs master, see this branch.
See the emacs-mac-30_1_exp or emacs-mac-gnu_master_exp branch and the file README-mac for additional compile instructions.
Note
On MacOS, gcc is aliased to the clang compiler, which is required to build emacs-mac. Recent gcc versions either cannot build for the architecture (e.g. Apple Silicon) and/or do not support blocks, which this build uses heavily.
Briefly:
brew install pkgconf texinfoIf you'd like to build with tree-sitter support, native-compilation, and RSVG (all recommended), first install the necessary libraries, here demonstrated using HomeBrew:
brew install tree-sitter libgccjit librsvgYou can configure the app either as self-contained (all resources live within the app), or non-self-contained (the default). A self-contained app is recommended. The recommended configuration options are given below; see the file README-mac for others.
A self-contained app by default will go into /Applications/Emacs.app.
./autogen.sh
CFLAGS="-O2 -mcpu=native" ./configure --with-native-compilation --with-tree-sitter --enable-mac-app=yes --enable-mac-self-containedOptionally, you can add -DFD_SETSIZE=10000 -D_DARWIN_UNLIMITED_SELECT to CFLAGS to increase the file descriptor limit, to help with packages that open many connections (like LSP).
Note that this may degrade performance in some cases.
You can specify another build directory for the self-contained app using --enable-mac-app=/path/to/dir.
Note
Please note the yes argument to --enable-mac-app=yes, which is required to build a self-contained app under /Applications.
./autogen.sh
CFLAGS="-O2 -mcpu=native" ./configure --with-native-compilation --with-tree-sitter make -j6 # or however many CPU cores you want to useYou'll find the staging build of the app under mac/.
This step compresses EL files and fully populates the app.
make install # Installs all resources under /Applications/Emacs.app (or wherever your self-contained build is going)sudo make install # installs resources in, e.g., /usr/local/share/emacs/30.2.50If you choose not to make install, but instead want to run the application directly from the mac/ sub-directory, you may need to:
% cd mac/Emacs.app/Contents
% ln -s ../../../native-lisp .to associate the native lisp files. This is useful for debugging, to quickly rebuild and test, for example (saving the install step). But a self-contained app build is easier, and recommended for most uses.
- The new builtin
pixel-scroll-precision-modedoes not work withemacs-mac, which has its own flavor of scroll event. Instead, check outultra-scroll, which was designed foremacs-macoriginally. - Some tools want a proper
emacscommand. If you build self-contained, you can link/usr/local/bin/emacs->/Applications/Emacs.app/Contents/MacOS/Emacs.
Several additional features and fixes have been added on top of upstream emacs-mac and Emacs proper.
- A
New FrameDock Menu entry. - Support compiling with non-system versions of CLANG.
- New custom variable
mac-underwave-thicknessto customize the thickness of squiggly underlines (e.g., as drawn by linters or spell-checkers). - A new full-featured
Windowmenu (including tab and tiling support, with default system shortcuts, e.g.C-Fn-left/right/up/down). Thanks to @rymndhng! - Add a new
mac-raise-all-framescommand, also found in theWindowmenu ("Bring All to Front"). - A new
mac-toggle-frame-full-screencommand for toggling "real" full-screen window display. - Automatically enable Retina 2x support for known high-DPI images.
- Avoid crashes when selecting certain fonts from the system font panel.
- Guard against using native image API when unavailable.
- Prevent zombie "Emacs Web Content" processes on SVG load,
restoring normal WebView SVG rendering for MacOS v14+. Update:WebViewis deprecated, so this has been reverted and another workaround installed. It's recommended to build with RSVG (it is enabled by default if thelibrsvg2library is found during build). - Fix occasional hangs when callbacks are invoked on dying threads.
- Fix rare occasional hangs upon waking from sleep with multiple monitors.
- Normalized the use of
CF|NS_NOESCAPEto prevent compilation issues and hangs when built with non-system CLANG. See this PR. - Handle cropped PDF images correctly.
- Correctly handle pixel-doubled images during allocation (fix regression from FSF upstream).
- Fix various compiler warnings related to type casting.
If you get crashes or just want to help with debugging, it would be very useful to run emacs-mac under lldb, the clang debugger. Here's how:
- Build emacs-mac with debug flags:
CFLAGS="-O0 -g3" ./configure --with-native-compilation --with-tree-sitter --enable-mac-app=yes - Link in the native-lisp directory.
- In an
~/.lldbinitfile, addsettings set target.load-cwd-lldbinit true, so Emacs can read the custom lldb commands it has defined. - Start the emacs binary from the
src/directory, like:Then%lldb ../mac/Emacs.app
run(or better,run -Q). - Now cause your crash to occur, go
upto the frame of interest, and usexprint,p, etc. on the potentially problematic variables. - You can also try
guiwhich is a little curses-based terminal GUI inside lldb (slow for me though), orrealgud-lldbwhich isn't very complete but can do some things.
We are very happy to accept contributions, especially bug fixes and other improvements. Note that, to preserve options for upstreaming, any contributor of substantial code must have valid copyright assignment paperwork with the FSF, and be willing to assign copyright, should that option be taken in the future.
You can read about the issues encountered during the merge of Emacs v30 in the debugging notes.
Footnotes
-
Calling this the "Carbon" port is a vestigial nod to its origins back in the pre-OSX days. It is also what
M-x emacs-versionsays. But "Carbon" is a misnomer now. The ancient Carbon API never supported 64bit applications, and was deprecated and removed by Apple in 2019. A few convenience functions do remain (e.g.Carbon.h), and these are used by the NS build as well. Both NS and emacs-mac are Cocoa applications. ↩