Paper on Native Compilation

If you’ve been following the Emacs native compilation effort and are curious about the technical details, Andrea Corallo, Luca Nassi, and Nicola Mancahave have an arXiv paper that describes Bringing GNU Emacs to Native Code. The paper does a good job explaining the technical details of how the native compiler works without requiring specialized compiler theory knowledge.

The TL;DR is that the native compiler uses the intermediate language from normal Emacs byte compilation as input and produces GCC intermediate code (IR). The final step is for GCC to compile this IR into native machine code. It’s a nice solution because it lets GCC worry about generating the final code so the solution should work for any architecture that GCC targets.

The details are a little more complicated, of course. The Emacs byte code IR is first translated into a special IR (called LIMPLE) that the native compiler can operate on and make optimizations that GCC can’t for various reasons having to do with the differences between LISP and C. It’s LIMPLE that is actually translated into the GCC IR. The paper explains all this so you should definitely read it if you’re interested.

This entry was posted in General and tagged . Bookmark the permalink.