HOME

Compiling Emacs on Debian 12

This page is a small tutorial on how to compile Emacs on Debian 12. It mainly serves as a reference for myself but could also be useful for others.

Dependencies

Emacs requires a bunch of dependencies, some of them already listed in the dependencies of the Debian 12 emacs package.

sudo apt build-dep emacs
sudo apt install libsqlite3-dev libgccjit-12-dev libtree-sitter-dev

Source Code Checkout

The command below checks out Emacs 29.1 on Debian with a depth of 1. This saves on downloading commit history from the remote and directly checks out the desired emacs-29.1 tag.

git clone -b emacs-29.1 --depth 1 git://git.sv.gnu.org/emacs.git

Optimized Compilation

Compile emacs with ahead-of-time (aot) compilation of elisp files - this takes a bit longer, but is more predictable at run-time. Also use full optimization options, giving a small performance boost. Deciding between -O2 and -O3 depends on many local factors, but here I trust the compilers decisions and hope they are (on average) better for the machine I'm working on.

The command below compiles emacs without the --with-pgtk option that would enable seamless Wayland support. If you don't plan on using Emacs with X11, also apply --with-pgtk.

./autogen.sh
./configure --without-compress-install \
            --with-native-compilation=aot \
            --with-tree-sitter \
            --with-json \
            --with-mailutils \
            --with-rsvg \
            CFLAGS="-O3 -mtune=native -march=native -fomit-frame-pointer" \
            prefix=/usr/local/
make -j8

Author: Maximilian Heisinger

Created: 2023-08-08 Tue 12:44