3 ms·
Understanding the Rust toolchain when you come from the C/C++ world
- Const-me 4y agoI wonder which C++ compiler the article is about? My toolchain is way more complicated, not straightforward at all. The obj files made from cpp sources contain some intermediate representation, very far from machine code or assembly. The machine code is generated by linker after multiple complicated (and expensive, I often see linker consuming gigabytes of memory and substantial CPU time) steps of the optimization. There's no text assembly representation anywhere, unless specifically asked for that. There's usually extra inputs involved: precompiled headers, data for profile-guided optimization, linker inputs such as static and dynamic libraries and module definition files.
- linkdd 4y agoThe whole article is (voluntarily) an oversimplification of how things happen. It's mainly intended to create a mapping "C world" <-> "Rust world", and from there you can go into the multiple rabbit holes that are compiler designs. In the past, I've written some toy programming languages, targeting Assembly (nasm). The toolchain was mycompiler + nasm + ld. Very much like a straightforward cc+as+ld (which of course is more complex than this in 2022). Now, I'm writing a more serious programming language, targeting Rust. And I wanted to know more about the toolchain and rustc. I've been writing Rust code for a few months now, and I never stopped before to think about "what is a crate" or "how does it relates to C/C++ toolchains". As a friend of mine said: > Rust is easy, write shitty code and let the compiler tell you how to fix it.