3 ms·
I don't know much about how the compiler works, so the answer here is probably that I should read a book, but can external crates from crates.io be precompiled?
by mcdonje 4y ago
I don't know much about how the compiler works, so the answer here is probably that I should read a book, but can external crates from crates.io be precompiled? Or maybe compile my reference to a part of an external crate once and then it doesn't need to be done on future compilations?
If the concern is that I could change something in a crate, then could a checksum be created on the first compilation, then checked on future compilations, and if it matches then the crate doesn't need to be recompiled.
- runevault 4y agobecause of the lack of stable ABI they'd need to pre-compile it however many versions of the rust compiler they wanted to support.
- duped 4y agoCargo already does this when building incrementally, and there are tools for doing it within an organization like sccache. > If the concern is that I could change something in a crate It's possible for a change in one crate to require recompiling its dependencies and transitive dependencies, due to conditional compilation (aka, "features' [0]). Basically you can't know which thing to compile until it's referenced by a dependent and provided a feature set. That said, many crates don't have features and have a default feature set, but the number of variants to precompile is still quite large. [0] https://doc.rust-lang.org/cargo/reference/features.html https://doc.rust-lang.org/cargo/reference/features.html Note that C and C++ have the exact same problem, but it's mitigated by people never giving a shit about locking dependencies and living with the horrible bugs that result from it.
- epage 4y agoHosted pre-compiled builds would need to account for - Feature flags - Platform conditionals - The specific rust version being used - (unsure on this) the above for all dependencies of what is being pre-compiled There is also the impediments of designing / agreeing on a security model (do you trust the author like PyPI, trust a central build authority, etc) and then funding the continued hosting. Compiling on demand like in sccache is likely the best route for not over-building and being able to evict unused items.