Thoughts on a binary crate repository

One frequent annoyance as a rust programmer is slow compilation time.

Instead of solving this by waiting for faster compilers to be implemented or avoiding coding patterns which are slower to compile, could we just compile less code on our machines? How?

By creating a binary (libraries .rlib, etc) crate repository. Maybe there are so many caveats that this wouldn't be feasible in practice:

  • no stable abi
  • many platforms to support
  • many rust compiler versions
  • ... and nightly
  • and feature flags
  • and compilation flags
  • ... Panic vs about
  • ... Integer overflow behavior
  • ... Probably many more that I'm not thinking
  • users trusting the compiled assets
  • licence issues distributing binaries
  • this really only helps with public crates, not private, proprietary code compilation time.
  • maybe download time would be more then compilation time in some cases

As I user, I think I'd only use this if the builds were reproducible from crates.io and signed by a trusted party. (No uploading of binaries by users).

Could this work? I don't know enough about the binary format rust uses for compiled crates.

I believe serde temporarily moved to shipping with precompiled binaries in 2023, but reverted due to concerns around some of the issues you mentioned above: YC Hacker News link.

I think using precompiled binaries should definitely be an opt-in choice.

For some reason, I thought it was wasm binaries they were shipping, not native binaries, but I guess that's just this project GitHub - dtolnay/watt: Runtime for executing procedural macros as WebAssembly

1 Like

Julia has a much worse problem because they compile at runtime. :slight_smile: So they have put a ton of effort into module precompilation, including shipping of precompiled libraries.

https://docs.julialang.org/en/v1/manual/modules/#Module-initialization-and-precompilation

https://julialang.github.io/PrecompileTools.jl/stable/

as an opt-in third party service, perhaps an approach similar to that used by cargo-binstall could work?

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.