Warn on duplicate artifact creation · Issue #5524 · rust-lang/cargo (original) (raw)
With a workspace such as in this repository: https://github.com/Mark-Simulacrum/cargo-issue-5524, running Cargo check on stable results in the following metadata being generated.
I believe that Cargo should try to detect the situation where duplicate artifacts will be generated and stop compilation; however, I'm not sure it's possible to do this well. I think even a heuristic that checks for lib/bin entries with the same name
across the workspace would be sufficient for most of the benefits, though.
It's worth noting that I think this has only become an issue (at least for cargo check) since rust-lang/rust#49289, which made rustc --emit=metadata
emit metadata for bin targets. It might be enough to make change to rustc to disambiguate binary and lib metadata in the filename. In a way, this might be a regression, but I'm not sure.
$ find target -type f -name '*rmeta' | xargs ls -trl # stable 1.26
-rw-r--r-- 2 mark mark 1058 May 11 21:35 target/debug/libfoo.rmeta
-rw-r--r-- 2 mark mark 1058 May 11 21:35 target/debug/deps/libfoo-a9f370a27c2df2eb.rmeta
However, on beta, the following occurs:
$ find target -type f -name '*rmeta' | xargs ls -trl # beta 1.27
-rw-r--r-- 1 mark mark 1221 May 11 21:36 target/debug/deps/libfoo-11803c32bdc69a09.rmeta
-rw-r--r-- 2 mark mark 0 May 11 21:36 target/debug/libfoo.rmeta
-rw-r--r-- 2 mark mark 0 May 11 21:36 target/debug/deps/libfoo-f0bc89da5bcecba3.rmeta
cc @alexcrichton -- do you think this ought to be marked as a regression? It's confusing behavior that has only become a problem since 1.27, but I don't know whether it really warrants regression-like tracking.