6 ms·
But the translation unit in Rust is the crate. Running `rustc` directly won't change that fact. Unlike in C, where you can compile TUs in any order since you've
by benesch 6y ago
But the translation unit in Rust is the crate. Running `rustc` directly won't change that fact. Unlike in C, where you can compile TUs in any order since you've got interfaces in headers, in Rust you can't compile a crate until you've compiled all its dependencies--and if it's not Cargo that's going to sort that out for you, Kbuild will have to.
- nitrogen 6y agoGiven the modular nature of the kernel, how big will each "crate" be? Will they mostly end up interfacing with the rest of the kernel using the C ABI and not need to be compiled as a single unit?
- cesarb 6y ago> in Rust you can't compile a crate until you've compiled all its dependencies Since Rust 1.38 (https://blog.rust-lang.org/2019/09/26/Rust-1.38.0.html#pipelined-compilation https://blog.rust-lang.org/2019/09/26/Rust-1.38.0.html#pipel...) that's no longer the case: "To compile a crate, the compiler doesn't need the dependencies to be fully built. Instead, it just needs their "metadata" (i.e. the list of types, dependencies, exports...). This metadata is produced early in the compilation process. Starting with Rust 1.38.0, Cargo will take advantage of this by automatically starting to build dependent crates as soon as metadata is ready."
- roca 6y agoThis is good but it doesn't work well enough in my experience. I still spend a lot of time waiting for dependencies to build before the crates that depend on them.
- pjmlp 6y agoEvery time a new Rust version comes out I compile my toy Gtk-rs application ported from a C/C++ User Journal article about Gtkmm. The C++ version still wins by several minutes on a Asus 1215B.
- swsieber 6y agoHas the gap at least narrowed over time?
- pjmlp 6y agoDefinitely, the improvements on rustc are visible, so eventually it will reach there. And I test it on that hardware on purpose, because I should not have to buy a top class desktop to achieve usable compile times similar to other AOT compiled languages. However, I also admit that what is missing is having a backend that favours debug workflows, which do exist just aren't yet there.
- AlphaSite 6y agoIs this a fresh compile each time?
- pjmlp 6y agoYes, make clean all, cargo clean build.
- fluffything 6y agoIf it does compile, could you try reporting results for multiple Rust compiles (e.g. the current one, and the ones from 6,12,18,24 months ago) ? (If you can, maybe do the same for C, but I don't know how easy that is).