Skip to content

macos: unreported filename collision with bin and dylib #9325

Closed
@ehuss

Description

Problem
On macOS, if there is a project with a bin and a dylib (or cdylib), there is a filename collision with the dep-info file foo.d. Cargo does not detect this, and results in possible corruption of the fingerprint file. Since there is a race for writing the .d file, it is possible for both fingerprints to think they are pointing at main.rs or lib.rs.

Steps

cargo new foo
cd foo
cat <<EOF >> Cargo.toml
[lib]
crate-type = ["cdylib"]
EOF
touch src/lib.rs
cargo build

Notice there is only one .d file in target/debug/deps (foo.d). If you're unlucky, you may also notice that Cargo now thinks that both lib and bin are main.rs (cat target/debug/.fingerprint/foo-*/dep-*). That means that touch src/lib.rs && cargo build will have no effect.

Possible Solution(s)
Off the top of my head, I cannot think of how to solve this. For reasons, it cannot use -C extra-filename for both bins and dylibs. --emit can take paths like --emit dep-info=target/debug/deps/foo-somehash.d, so maybe that is an option. At a minimum, cargo should emit a warning that this is a known bug, similar to #6313.

Notes

Output of cargo version:

cargo 1.52.0-nightly (90691f2 2021-03-16)

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: target output directory layout, naming, and organizationC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions