Hacker News new | past | comments | ask | show | jobs | submit login

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.




Cargo 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

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.


Hosted 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.


sure all the combos tail into practical inf, but with an 80/20 approach if you limit those combinations to just the most common, wouldn't it hugely reduce the waste of rebuilding everything locally?


sccache seems awesome. I wasn't aware of it. Thanks.


because of the lack of stable ABI they'd need to pre-compile it however many versions of the rust compiler they wanted to support.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: