Duplicate artifact tracking issue.

Open
#6,313 70 comments 30 reactions 1 assignee View on GitHub

@ehuss is already working on this.

Since Nov 13, 2018.

Assessment

This issue has not been assessed yet.

Description

A-layout C-tracking-issue S-needs-mentor

View all comments

#6308 added a check if multiple jobs produce the same files. To be safe, it is currently a warning. At some point in the future it should be turned into a hard error if no problems are reported. Collisions are almost certainly bad behavior that will cause problems, so rejecting it is probably the right thing to do.

Related issues:

  • #5524: Request to warn on duplicate artifact creation — wherein .rmeta files started to collide because bin targets started producing them, and were corrupting one another if built simultaneously. .rmeta collisions fixed in #6292.
  • #6293: Handling multiple targets in a workspace with the same name.
  • #5444: Hardlink collisions when target is built multiple times (like panic/no-panic). Fixed by #5460 by only hardlinking what was requested.

Known situations where collisions may occur:

  • Multiple binary/example/lib targets in a workspace with the same name. (Or reusing a shared target directory.)
  • Using --out-dir with an example and binary with the same name.
  • Multiple path dependencies with dylibs with the same name.
  • Multiple dependencies with the same name and you select both of them on the command-line, for example: cargo build -p rand:0.4.3 -p rand:0.5.5.
  • rustdoc in a workspace where multiple crates have the same name. This can arise from a variety of situations (renamed dependencies, multiple versions of a package, different packages with the same crate names, etc.). (rust-lang/rust#56169, rust-lang/rust#61378)
  • panic="abort" and cdylibs and tests: Create a project with a lib (cdylib crate type), binary, and an integration test, with panic="abort" in the profile. When cargo test runs, the cdylib is built twice (once with panic=abort for the binary, and once without for the test), with the same filename. Building the lib for the test should probably skip the cdylib crate type (assuming rlib is also available), but implementing this is very difficult. See https://github.com/rust-lang/cargo/issues/6313#issuecomment-480014371.
  • Multiple targets (particularly executables) that differ only by case on case-insensitive filesystems.
  • PDB collisions on Windows. If the package has a binary and a dylib library of the same name, then the .pdb file for each target will have the same name. This is easy to hit if you have a proc-macro package with a binary.
  • Dylib built multiple times with different features
    • for example with new feature resolver, see #9278.
    • and with workspace members, see #12345
  • Shared cdylib built with different profile settings, such as a build script and release mode https://github.com/rust-lang/cargo/issues/6313#issuecomment-916741203

Notes on implementation issues:

  • Cargo is hard-coded with the outputs that rustc produces. If those outputs change, it will not be able to catch those changes. In particular, #5524 would not have been caught by these checks.
  • OutputFile is currently not calculated correctly in some cases. Known issues:
    • Debug files (like .dSYM) are not tracked in some cases because TargetInfo::file_types is making decisions about what should be hardlinked too early. Fixed in #8210
    • It is also very likely that it is missing certain platform differences.
    • Doc outputs are not tracked correctly (it generates incorrect paths). Fixed in #6998.
    • Doctests generate incorrect paths. This should be fixed. Fixed in #6998, doc tests do not have any output paths.
  • Not all outputs are checked. Such as:
    • The .d dep info file. This uses the same hash as the main artifact, so is unlikely to be a problem.
    • Incremental files. One hopes that the hashes used in rustc are good enough?
    • Other temp files created by rustc, like rcgu files, which should always include the hash.
    • Anything done by build scripts.
  • cargo doc has a dedicated path for detecting collisions. If cargo doc is ever updated to support multiple crates with the same names, this code path can be removed.
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/cargo

All issues in rust-lang/cargo

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.