The Rust compiler code generation phase is mainly performed by LLVM . LLVM is the compiler toolkit most commonly used by Clang C [++] Compiler clang[++] .
Firstly, the Rust compiler (like clang , for example) does all Rust-specific stuff, such as type checking and borrowing; in the end, it generates LLVM-IR. IR stands for intermediate presentation, and it ... is comparable to an assembly, but a bit higher level and, most importantly, platform independent. Then the Rust compiler simply calls β LLVM and says:
Hey buddy, could you please take this IR and generate machine code for the current platform? That would be fantastic β β‘ β
What LLVM answers:
Ure Of course no problem, new friend. Here is your highly optimized machine code for [for example] x86_64 ! β« βͺ β«
After that, they invite several more friends to wrap all this in a small pretty [for example] ELF package and put it in the user file system. (and the user is like ...)
Such information can be found in the official FAQ, which in any case contains a lot of interesting information. For more information on the Rust compiler, you can read the Rustc Guide . On this issue, the High Level Review chapter is quite interesting.
source share