Running out of disk space!


#1

I have just built gfx with docs but only debug, and I’m up to 650MB. Amethyst comes in at 1.5G. So if I have 20 projects, using amethyst then I’m up to, say, > 30GB. This isn’t good on my 64GB eMMC laptop!

Is there a way to share build artifacts between projects, and if there isn’t, should there be?


#2
cargo doc --no-deps

This will build the documentation for only your project, i.e. not any dependencies.


#3

I think the OPs issue is more that all these projects have a seperate /target directory with a copy of the dependencies.


#4

@derekdreery You can set CARGO_TARGET_DIR to a different location. Note, though, that this might lead to problems with libraries of different versions overwriting each other.


#5

Setting CARGO_TARGET_DIR as suggested by @skade should work reasonably well. I do combined builds of all of crates.io with a shared target dir and it works.


#6

I defer to veterans skade and brson for the current fix, I just wanted to add that there are more general solutions in the works on the internals forum, using sccache.


#7

Thanks for the replies, and the tip with CARGO_TARGET_DIR. I’m going to experiment.

It would be good maybe if different versions went in their own folder so they didn’t interfere with each other? I’m not an expert on how the build system works. @skade I’ve noticed some projects I’m using having 2 different versions that build side-by-side with no problems.


#8

Unfortunately it’s far more complicated than just the versions of the library. The internals forum thread I linked goes into more details, but in short:

Rust doesn’t (yet) have a stable ABI (binary interface), so the compilation results can be different based on compiler version, optimisation flags, statically included files, target platform and position of the moon.

A proper cache must account for all of that, and cargo’s directory structure currently only looks at target platform and debug-vs-release.
I.e. after a rustup update your cache needs to know to NOT reuse things. Otherwise the errors that result can be absolutely Byzantine to debug (along the lines of “why does println("hello") cause a segfault?!?”)


#9

I’ve gone with the solution using CARGO_TARGET_DIR, and I’ve also put the target directory on a tmpfs since there seems to be a lot of i/o and I don’t want to wear out my ssd (which has also sped up builds considerably :slight_smile: )