Description
Problem
It looks like changing RUSTFLAGS
(or, more likely, the rustflags
key in .cargo/config
) will currently recompile all dependencies with the new flags (which is fine) and invalidate/overwrite the already built artifacts with the older RUSTFLAGS
value.
This is causing significant pain for me as I work on a project that has multiple workspace members that define their own .cargo/config
with different rustflags
. This is an embedded project, an RTOS consisting of kernel and userspace binaries, to be precise, so rustflags/linker shenanigans are somewhat expected.
This issue causes a kernel build to invalidate all userspace artifacts and vice-versa, which makes development sufficiently painful that we're not using a Cargo workspace at all (breaking IDE integration in the process). Having multiple target
directories of course will work around the issue, but is less than ideal.
Steps
Unfortunately the code base is not yet open-sourced, but I can try to provide a minimal example if requested.
Possible Solution(s)
The old artifacts should be reused when RUSTFLAGS
is changed back to the original value.
Notes
Output of cargo version
: cargo 1.42.0-nightly (86134e766 2019-12-23)