I think it would be better to have a cache, instead of a shared target dir.
Currently I have the code change for sharing the .rlib and .d. But I think it’s another problem is, the shared target folder actually consumes huge disk space. I think it should have a cache management mechanism.
For example, if the dependency is compiled only once, cargo make the output to the package’s target. And if cargo finally realized this binary is used several times, then it will cache the compilation result. Also, we can put a limit of amount of disk space the cache can use. If the binary haven’t been use for a while, we probably can just remove it without hurting the performance and just make it a LRU cache.
So it turns out probably a file like ~/.cargo/bin-cache.conf, which defines the cache configurations.
At the same time, we probably need a manifest file tracking the status of the cached binaries. For example: the timestamp of last use, the total size of the binary, and probably flag prevents the binary from being deleted for a while (I would like call it a lease. Just think about there are multiple cargo instance is running, once one cargo decide to use a cached binary, it should have a way to pin the binary in the cache a little while. And the lease has a expire timestamp just in case cargo crashes during the build).
Any ideas on this ?