Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fingerprint.rs uses different target roots when serializing/deserializing #8817

Closed
khyperia opened this issue Oct 28, 2020 · 2 comments · Fixed by #8819
Closed

fingerprint.rs uses different target roots when serializing/deserializing #8817

khyperia opened this issue Oct 28, 2020 · 2 comments · Fixed by #8819
Labels
C-bug Category: bug

Comments

@khyperia
Copy link
Contributor

khyperia commented Oct 28, 2020

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

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

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.

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.

@alexcrichton
Copy link
Member

Oh dear, thanks for the report and investigation here though! I believe the intention was to be relative to target itself, so anything that's actually relative to target/{debug,release} is a bug!

@khyperia
Copy link
Contributor Author

Ah cool! Submitted a PR changing that one, then.

@bors bors closed this as completed in 7197c66 Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants