How Rust Compiles - Noratrieb
summary
Shows that Rust compiles by turning Rust into MIR then into LLVM IR where monomorphization and inlining happen, explains why generics create duplicate instantiations and how #[inline] delays codegen (its use hides a post‑monomorphization array‑size error in the library example), demonstrates measuring duplicates with cargo‑llvm‑lines, compares LTO modes (fat LTO slows clean builds ~2–4× but can speed runtime, thin LTO gives similar runtime with parallelism), and lists linkers (LLD, mold, wild) and the object/AR/link step that actually produces the binary.
AI-written summary · about
chapters (18)
- 0:00Rust compilation intro
- 1:30Rust speed focus
- 2:33Compiler phases and MIR
- 4:40Slow back end in Rust
- 6:07Codegen units and parallelism
- 7:50Linker optimizations
- 9:59Splitting code into units
- 10:20Generics and monomorphization
- 13:09Inlining trade-offs
- 15:57Lazy instantiation with inline
- 17:02Link time optimization
- 18:27Fat vs thin LTO
- 20:31Plugin LTO and cross-language
- 21:54Thin local LTO
- 22:15Inlining for runtime
- 23:18Reducing compile times
- 24:02Balancing compile vs runtime
- 24:43Inline attribute error
related talks
32mWhat Rust can teach us about Ruby
34mWhat Rust can teach us about Ruby
58m(Almost) Everything You Should Know About The Compiler Frontend
43mRust Unlinked: Rustc, Symbols, and Static Libraries
56mReady for Rust
23m"The Current State and Future of Rust Compiler Performance"
38mStrategies to speed up build iteration, or dynamic hot reloading
09mRustc: How I Learned to Respect the Compiler
