4 ms·
One of the biggest issues that I face with Rust is that its builds are enormous, and I often work on machines with limited disc space. The actual binary sizes
by leggomylibro 7y ago
One of the biggest issues that I face with Rust is that its builds are enormous, and I often work on machines with limited disc space.
The actual binary sizes are fine - even with embedded devices that have <1MB of program space, there doesn't seem to be much bloat. But I need to remember to clean every project when I finish working on it, because otherwise the build folders will eat 100s-1000s of megabytes each on a 16-32GB partition.
I really appreciate Rust's inclusive approach to learning and teaching, but I can't justify using it for education on ultra-affordable machines for that reason. People often scatter one-off projects all over the place as they learn, and when they run out of space it takes a long time to clean everything up.
So I would also be very in favor of some sort of simple shared package cache.
- asgeir 7y agoHave you considered doing something like this: cargo build --target-dir ~/build-artifacts/$(basename $(pwd)) Then you can have something like this in your ~/.config/user-tmpfiles.d/clean_build.conf d /home/user/build-artifacts - - - 1d - You can then do cleanup by calling systemd-tmpfiles --user Or you can use the tmpfiles timer systemctl enable --user --now systemd-tmpfiles-clean.timer
- leggomylibro 7y agoThat sounds like an interesting idea, thanks! Can that '--target-dir' argument be added in the build.rs script?
- asgeir 7y agoIt looks like you can set it using a CARGO_TARGET_DIR environment variable or build.target-dir config value. So I guess you could create a $HOME/.cargo/config file with the following in it (letting you skip the --target-dir part): [build] target-dir = "/home/user/build-artifacts" But I don't know if the different projects will trample each other that way. If that's the case you could just go with a .cargo/config per-project targeting a subdirectory of the build-artifacts directory. https://doc.rust-lang.org/cargo/commands/cargo-build.html https://doc.rust-lang.org/cargo/commands/cargo-build.html https://doc.rust-lang.org/cargo/reference/config.html https://doc.rust-lang.org/cargo/reference/config.html