Understanding the compiler



I am interested in understanding and learning how the compiler works. I am a compiler engineer and I am currently writing this from EuroLLVM. I am surprised that nobody here has mentioned Rust. I have heard uses LLVM so I am quite surprised no presentations exist discussion how Rust uses LLVM and if there are any specific Rust optimizations, plugins, etc.

Where can I find internals documentation on rustc?


I’m not a compiler dev, but can provide some links:


The reason for Rust’s absence at LLVM conferences might be that there’s not a lot of interesting interaction between rustc and LLVM, relative to the size of the Rust project. We mostly just generate IR straightforwardly and then run the standard optimization passes on it. While this heavily relies on LLVM as a library, there’s no fancy plugins, no custom optimizations, no complicated encoding of language-specific data in the IR, or anything like that. And while feedback from front ends is obviously important for LLVM, I can’t think of many requirements or complications on top of what any other front end (e.g., clang) faces.

That’s not to say we couldn’t benefit from more interaction with the LLVM community, of course. I’m actually a bit saddened by the state of affairs, but ¯\_(ツ)_/¯

As for documentation, in addition to what @killercup posted, there’s the readme of librustc, which sketches a 50,000 feet view of the compiler, and https://forge.rust-lang.org/. Other than that and a couple of blog posts (many of which are very high-level or long outdated), I can’t think of much documentation going into rustc internals. There’s doc comments in the source code, but even those are sparse. It’s quite unfortunate, but in my experience the best source of knowledge about rustc internals is reading the source and asking many, many questions on IRC. (One can also pick up a lot by lurking on the issue tracker, in RFC threads, etc. but this is no way to get up to speed quickly.)


There is now a guide.

closed #6

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.