Skip to content

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

Closed
@khyperia

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

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.

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions