Rust GCC backend: Why and how
blog.guillaume-gomez.fr·3d
🚂Cranelift IR
Preview
Report Post

Whenever you compile using Rust, the compiler goes through different passes and in the end, generated binary code for the target processor. By default, it uses LLVM as backend to generate the binary code, but more backends exist like cranelift and GCC. This post is about how it’s possible for one compiler to use different backend to generate binaries, in particular GCC.

Passes

Before going into details, we need to describe how compilers actually work. They read source code and convert it internally into a format they can manipulate, commonly called Abstract Syntax Tree (shortened "AST").

However, compilers go through multiple passes, and often each pass has their own AST. Let’s take a short and very incomplete example with the Rust compiler passes. We have 4 steps (again,…

Similar Posts

Loading similar posts...