fingerprint.rs uses different target roots when serializing/deserializing #8817
Description
Originally found in EmbarkStudios/rust-gpu#120, I'll use paths from my debugging there
On this line of code, serializing the dep file, target_root
== /home/khyperia/me/rust-gpu/target
cargo/src/cargo/core/compiler/fingerprint.rs
Lines 1834 to 1835 in 358ee54
On this line of code, parsing the dep file, target_root
== /home/khyperia/me/rust-gpu/target/release
cargo/src/cargo/core/compiler/fingerprint.rs
Line 1669 in 358ee54
This causes extremely bizzare incorrect paths to show up in target/spirv-unknown-unknown/release/example_shader.d
, for example, /home/khyperia/me/rust-gpu/target/release/debug/deps/librustc_codegen_spirv.so
(note the release/debug
)
I believe this is because when serializing, the root is taken from cx.bcx.ws.target_dir().into_path_unlocked()
, which is the simple target
dir.
cargo/src/cargo/core/compiler/mod.rs
Line 221 in 358ee54
But when parsing the dep file, the root is taken from cx.files().host_root()
, which is the specific target directory target/release
.
I think the only reason this hasn't been noticed before is that before rust-lang/rust#77565, absolute paths converted to relative paths never went through the TargetRootRelative
codepath, it was always kept as absolute paths. Maybe? I don't know.
I would submit a PR to fix this, but I don't know which path is correct to use here.