-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
let (ty, path) = if let Ok(stripped) = canon_file.strip_prefix(&target_root) { | |
(DepInfoPathType::TargetRootRelative, stripped) |
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
DepInfoPathType::TargetRootRelative => target_root.join(path), |
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
let target_dir = cx.bcx.ws.target_dir().into_path_unlocked(); |
But when parsing the dep file, the root is taken from cx.files().host_root()
, which is the specific target directory target/release
.
fingerprint::parse_dep_info(unit.pkg.root(), cx.files().host_root(), &dep_info_loc)? |
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.