Does rust enable a global build cache just like golang?
I know the sccache would use global cache for compiling. But the build output are still inside the project target/ dir.
I also know that we can configure cargo to enable global target-dir. But how it handles project conflicts? For example, two different projects but with the same name; Same dependency lib with the different feature settings.
What's stopping you from adding export CARGO_TARGET_DIR=/tmp/ to your bashrc?
The compiler will handle multiple versions of the same crate just fine because their artifacts are placed in different locations, but using different inputs (RUSTFLAGS, cargo features, etc.) for the same version of the same crate will trigger a recompile for that crate.
This is because Cargo conflates the concepts of final build products (like executables and crate's own libraries) and intermediate build artifacts (dependencies, temp files) and uses a single directory for all of them.
Because Cargo places project-specific build products without any namespacing in the in target/ dir, having literally a single global target dir would make different projects overwrite each other's executables. This is already an issue for workspaces.