Emacs has recently merged into the master branch a long-awaited feature: native compiling of Lisp modules using
libgccjit (just-in-time compilation with GCC).
I was curious to try it without waiting the official Emacs 28.x branch release so I copied a Docker file "template" found at this link and adapted to my needs.
Changes I applied to that template:
- Since I use Debian, I changed the base image to
debian:testing-slim(to better match my dependencies)
- Removed from the
configurescript all the features I don't need (namely the GUI)
- Build a .deb package with
checkinstall(because I haven't yet figured out how to use Debian tools ...)
Here is my Dockerfile, copy this file next to your emacs sources (which you will get by cloning their repository).
The steps to build the package from scratch:
$ git clone --depth=1 https://git.savannah.gnu.org/git/emacs.git $ ls emacs Dockerfile.emacs-native-comp $ cd emacs $ docker build -t debian:emacs-builder -f ../Dockerfile.emacs-native-comp . $ container_id=$( docker run -d --name kill-me-when-finished debian:emacs-builder ) $ docker cp $container_id:/src/emacs-nc_0.1-1_amd64.deb . $ docker rm kill-me-when-finished
I am not interested in versioning this package (I'll delete it anyway after the official releases) so in the Dockerfile I've simply set
You'll now have a
emacs-nc_0.1-1_amd64.deb in the
emacs directory. Be mindful that Emacs with JIT has quite a few dependencies. After you're done building you also might want to remove the Docker image (~2.6gb).