4 ms·
Except the Rust ecosystem lacks the solutions we have in C++ land to compile fast and have easy paralelisation of builds. Because C and C++ communities for his
by pjmlp 2y ago
Except the Rust ecosystem lacks the solutions we have in C++ land to compile fast and have easy paralelisation of builds.
Because C and C++ communities for historical reasons embrace binary libraries, and binary component frameworks like COM, so while in theory a full build from scratch takes similar time as Rust, in practice that isn't the case.
Also note that D, a language as complex as C++, with three compilers, one of them being based on LLVM, is largely faster to compile than Rust while using the LLVM backend, because Walter Bright did the right decisions on what to focus for development workflow.
- Ygg2 2y ago> Also note that D, a language as complex as C++ While D is complex, it's a different beast than Rust. I suspect think various checks, from lifetime to trait resolution, might make it more complex to parallelize than C++.
- steveklabnik 2y agoRust is already able to do more fine-grained parallel compilation than C or C++, at least in the codegen step. The "codegen units" concept doesn't work for those languages.
- wahern 2y ago> The "codegen units" concept doesn't work for those languages. Sure it does. Or at least could, depending on what you mean by that term. See, e.g., GCC's -flto-partition option, which supports various partitioning strategies for parallel LTO codegen.
- steveklabnik 2y agoLTO is distinct, and happens after what codegen units does. That said, it is a more fine grained parallelism, for sure. Rust does LTO as well as codegen-units. Really, as you gesture towards, on some level, this is all semantics: our linkers are also basically compilers too, at this point.
- dathinab 2y ago> have easy paralelisation of builds. except the company had a straight forward solution to the problem and it's not always possible in C++ land either and COM isn't part of C/C++ but a microsoft specific extension which solves very different issues as it's for cross application communication while we here have compile time perf issues inside of a single library > binary libraries I'm not sure if you mean dynamic linking or binary objects but there is the thing: - dynamic linking isn't the issue here as the issue has nothing to do with re-compilation and similar (where dynamic linking can help), - binary object files on the other hand are also something rust has and uses, it just sets the boundaries in different places (crate instead of file) which makes development easier, can lead to better runtime performance etc. It just has the drawback that you sometimes have to split things into multiple crates. > a language as complex as how complex a language is to write has not too much to do with how complex it is to split a single code unit into multiple parts for parallel compilation. C, C++ and D mainly side steps this by making each file a compilation unit, while in rust it's each crate. But that isn't fundamentally better or worse, it's trade offs. It's trade offs. > because Walter Bright did the right decisions on what to focus for development workflow. and so did rust, just with different priorities and trade offs and given that D is mostly irrelevant and rust increasingly more successful maybe it was pursing the more important priorities Also the OP case is about release builds i.e. not the normal dev loop neither does the splitting affect dev experience as it's all auto generated code and if projects which aren't auto generated it's very normal to split out libraries etc. anyway, and weather you split them into their own module, file or crate doesn't matter too much as long as you keep code clean (as in not having supper entangled Spagetti code) and I wouldn't even be sure if D does perform in any relevant way better in compiler time if you compare their performance with the end result after they split the crate
- pjmlp 2y agoCOM is one approach, among others like SOM, DCE, ... as means to write binary libraries in poliglot languages. Turns out that it is mostly used on Windows since Vista days, as means to have an OOP based OS, with most libraries written in C++, and having a stable ABI for such components. So while it isn't ISO C++, it is mostly used by and from C++. .NET land usually only reaches for COM when using Windows APIs. Binary libraries, mean binary libraries, doesn't matter if static or dynamically linked. My point is that Rust ecosystem does not use them, you always need to compile from source code the complete dependency tree after a git clone, some of them even multiple times due to different feature flags configurations. Not so with most commercial C and C++ development, we enjoy having binary libraries for dependecies, after a git clone only the main code needs to be compiled from scratch. Yes there are ways to kind of do with sccache, but it is additionally tooling, not something that apparently cargo will ever support. Also if you watch recent talks from Microsoft regarding their Rust adoption, the lack of tooling support for binary libraries distribution is one of their pain points.