-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn on duplicate artifact creation #5524
Comments
I wonder why we uplink |
Yeah sort of like rlibs I think we could just avoid uplinking these altogether |
In rust-lang#49289, rustc was changed to emit metadata for binaries, which made it so that the librustc.rmeta file created when compiling librustc was overwritten by the rustc-main compilation. This commit renames the rustc-main binary to avoid this problem. rust-lang/cargo#5524 has also been filed to see if Cargo can learn to warn on this situation instead of leaving it for the user to debug.
I think if someone were to detail how to "avoid uplinking these altogether" it might expedite a fix here. 🙂 |
@dwijnand It's not clear (to me) how safe it is to change these behaviors. Like #6131 where someone was manually running rustc to link against rlibs created by cargo, the location of the rlibs is not easy to determine (generally need to slurp the json output to get the correct
The decision on what to hardlink is done here. The code relevant to rmeta and bin files is here. Essentially |
@nrc I was under the impression that rls read the |
Oh, and as a side note, it might be nice if |
@ehuss it doesn't. It does |
Don't hardlink rmeta files. `.rmeta` files shouldn't be needed in the main directory, and since rustc started outputing rmeta files for binaries, there are name collisions between bins and libs of the same name. Partial fix for #5524.
Don't hardlink rmeta files. `.rmeta` files shouldn't be needed in the main directory, and since rustc started outputing rmeta files for binaries, there are name collisions between bins and libs of the same name. Partial fix for #5524.
Check for duplicate output filenames. This generates an error if it detects that different units would output the same file name. This can happen in a few situations: - Multiple targets in a workspace use the same name. - `--out-dir` in some cases (like `examples` because it does not include the directory). - Bugs in cargo (like #5524, #5444) This includes a few cleanups/consolidations: - `export_path` added to `OutputFile` so there is one place where the `--out-dir` filename logic is located. - `TargetKind::description()` added for a simple way to get a human-readable name of a target kind. - The `PartialOrd` changes are a slight performance improvement (overall things are now slightly faster even though it is doing more work). Closes #5524, closes #6293.
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.However, on beta, the following occurs:
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.
The text was updated successfully, but these errors were encountered: