How to build Emacs with JIT on Ubuntu 20.04

Editing the Emacs source code using emacs.

Emacs is a text editor that was initially released in 1976. It is widely used by many who enjoy a programmable, moldable computing environment. A recent addition to Emacs brings improved performance using just-in-time compilation. This feature is referred to as native-compilation, and leverages the GCC compiler. This post will provide instructions for building emacs 28.1 on Ubuntu 20.04. The instructions should be very similar for any Debian-based distribution. For those interested in learning more about emacs and the technical details of the improvements, please refer to the links at the bottom of the post.

Open a shell and follow along with the commands below.

Enable Source Repositories.

# Become root.
$ sudo su -
$ sed -i '/deb-src/s/^# //' /etc/apt/sources.list && apt update
# Exit root.
$ exit 

Install dependencies

$ sudo apt -y install software-properties-common ca-certificates
$ sudo apt build-dep -y emacs
$ sudo apt install -y gcc-10
$ sudo apt install -y libgccjit0 libgccjit-10-dev libjansson4 libjansson-dev gnutls-bin
$ sudo apt install -y autoconf git make
$ sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev

Clone the emacs source code

$ git clone
$ git checkout emacs-28.1

Build emacs

# Set your compiler.
$ export CC=/usr/bin/gcc-10
$ export CXX=/usr/bin/gcc-10
# Prepare the build
$ ./
$ ./configure --with-cairo --with-xwidgets --with-x-toolkit=gtk3 --with-native-compilation
# Build and install.
$ make -j$(proc)
$ sudo make install

Now you can start the application by running the command emacs in a terminal.

Further Reading

Introductory Post

Welcome to my Blog

It’s me!

My name is Rafi Khan, and I am a passionate human who is devoted to making the world a safer, better place for everyone. I could go on about the places I have lived, people I have met and projects I have been involved in. But rather than a biography, I’d like to give you a sense of some of the themes that are prevalent throughout my life and my work.

As a concerned human, I look around me and see that we live in a prosperous world, but not a prosperous society. I believe the reason for this disconnect between opportunity and reality is that we prefer to look out for our own needs instead of functioning as a team/community.

Earth is plagued by divisions, everywhere we look. They may be based on skin colour, language and geographical border. As a society, we place more weight on power and wealth, than we do on justice, fairness and critical thinking. I want to work together to better understand each other and the problems which continue to plague our societies. In this collaborative fashion, we can move forward to rebuild ourselves as responsible, conscientious habitants of Earth and the Solar System.

Continuing to write, after several failed attempts

For a long time, I have wanted to become an active blogger. I have created and developed many profile pages and blogs over the years, but have found it difficult to write consistently. I could point to the usual distractions in life, work, family, school and other hobbies. But really the reason I was distracted from writing, is that I found the technical challenges of setting up a blogging system to be much more personally gratifying. I felt more productive configuring and customizing the blog. This time, I opted to purchase a managed WordPress subscription1.

After spending a few days configuring a basic blog with sane defaults, I am ready to write!.

How to reach me?

The best way to reach me is to shoot me an email at [email protected] or fill out the contact form.

  1. I am using the $1/month Managed WordPress offering from IONOS: []