-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 buildNotice 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)