-
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
warning: output filename collision. #14253
Comments
Could you provide reproduction steps? |
I don't know what lead to this warnings, compiling almost all of my rust projects using latest cargo version For example for one project, the full list of warnings is:
As you see, every warning duplicate itself; and why only compiling |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
After some investigation, found this warning is relate to Cargo's
comment them out warning disappears. |
We're also seeing this after rust-lang/rust#128083, the exact symptoms mentioned in #7859. We also have a similar cargo.config, and not using that config makes the build succeed. I could reproduce this by setting the
and running |
Yes we are blocked on upgrading Rust due to this. I don't have a more minimal repro than what I described above. I suspect that it will require building the standard library anyway, as opposed to some smaller standalone project. |
Sorry, to clarify, this is building https://github.com/rust-lang/rust |
+1 to the build issue @aeubanks mentions. The repro steps are:
I'm observing this error on x86_64-unknown-linux-gnu. In fact, just about any invocation of I will try to create a smaller repro that doesn't rely on an entire Rust checkout. |
From inside the checkout, in the package that fails to build:
|
@rustbot label: Z-target-applies-to-host |
We're also seeing it with this config: target-applies-to-host = false
[unstable]
bindeps = true
host-config = true
target-applies-to-host = true |
The error can be reproduced with the follow steps in rust-lang/rust.
If you run |
@alecmocatta |
Alright. Just narrowed bootstrap down to this real-world reproduction: [package]
name = "cargo-14253"
version = "0.1.0"
edition = "2021"
[dependencies]
cc = "1.0.97"
lzma-sys = "0.1"
[profile.dev]
debug = 0 Run with
and you'll get this compile error (it is not deterministic, sometimes succeeds):
Note that For further investigation in Cargo here is a Cargo-flavored UI test reproduction: click to expand
#[cargo_test]
fn host_config_shared_build_dep() {
// rust-lang/cargo#14253
Package::new("cc", "1.0.0").publish();
Package::new("lzma-sys", "0.1.0")
.file("src/lib.rs", "")
.file("build.rs", "fn main() {}")
.build_dep("cc", "1.0.0")
.publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bootstrap"
edition = "2021"
[dependencies]
cc = "1.0.0"
lzma-sys = "0.1.0"
[profile.dev]
debug = 0
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("build")
.masquerade_as_nightly_cargo(&["target-applies-to-host", "host-config"])
.arg("-Zhost-config")
.arg("-Ztarget-applies-to-host")
.env("RUSTFLAGS", "--cfg foo")
.with_status(101)
// Sometimes it compiles. Not deterministic...
.with_stderr_data(str![r#"
[UPDATING] `dummy-registry` index
[LOCKING] 3 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] lzma-sys v0.1.0 (registry `dummy-registry`)
[DOWNLOADED] cc v1.0.0 (registry `dummy-registry`)
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rlib
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rmeta
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[COMPILING] cc v1.0.0
[ERROR] failed to build archive: No such file or directory
[ERROR] could not compile `cc` (lib) due to 1 previous error
"#])
.run();
} |
@alecmocatta @Wyvern @chbaker0 @aeubanks |
Ah, I was struggling to make a self-contained repro and thought there was something unique to how |
@weihanglo
settings. But, if |
This occurred building a private repo that I unfortunately can't share.
[profile.dev]
debug = "line-tables-only" Reproduced most of the rest here in case anything else is helpful.target-applies-to-host = false
[host]
rustflags = [
"-Zoom=panic",
"-Zproc-macro-backtrace",
"-Zmacro-backtrace",
"-Zthreads=8",
]
[target.'cfg(all())']
rustflags = [
"-Zoom=panic",
"-Zproc-macro-backtrace",
"-Zmacro-backtrace",
"-Zthreads=8",
]
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=mold"]
[unstable]
bindeps = true
host-config = true
target-applies-to-host = true
[profile.dev]
debug = "line-tables-only"
[profile.dev.package."foo"]
opt-level = 3
[profile.dev.package."bar"]
opt-level = 3
[profile.dev.package."baz"]
debug-assertions = false |
Verified this fix the problem in rust-lang/cargo#14253 (comment). Bug: 356618943 Change-Id: I8fd7fb3cd221169bc6b6fd62dc8dacb20540f076 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5762945 Reviewed-by: Arthur Eubanks <[email protected]> Commit-Queue: Arthur Eubanks <[email protected]> Cr-Commit-Position: refs/heads/main@{#1338074}
@nico This is the first I was alerted about this... I can set some time aside to work on this immediately. I'll update later today on whether or not I think I can quickly fix this. Generally speaking I don't see any issue with temporarily reverting 8457356 if a fix isn't likely to be very fast. We've all lived with the bug that fixed for long enough for it to not be high priority to the project. |
This is slightly tentative, but here's what I think is happening here so anyone can correct me if they know I'm wrong:
This wasn't caught because this is usually masked by the fact that the artifact (non-build-dep) version is passed either I haven't invested time into verifying this yet, but I believe that this should only occur in cases where the behavior pre 8457356 was already wrong. Specifically as I currently understand it this only occurs when
And the combination of those bullet points mean that pre 8457356 we are passing the rustflags for host-deps to target artifacts (i.e. whatever is in the This obviously needs to be fixed, but if I'm correct that this should only occur in cases where we would otherwise pass the wrong rustflags I don't think reverting 8457356 is much of an improvement. Reverting would replace inconsistent wrong behavior which sometimes errors with consistent wrong behavior that never does. I'm hopeful the fix is as simple as updating that hashing function and can be out quickly. * ** Incidentally there's another variant of it, with PS. Refined version of @weihanglo's test (`lzma-sys` crate as not necessary, `host-config` feature replace with `--config`)#[cargo_test]
fn host_config_shared_build_dep() {
// rust-lang/cargo#14253
Package::new("cc", "1.0.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bootstrap"
edition = "2021"
[dependencies]
cc = "1.0.0"
[build-dependencies]
cc = "1.0.0"
[profile.dev]
debug = 0
"#,
)
.file("src/lib.rs", "")
.file("build.rs", "fn main() {}")
.build();
p.cargo("build")
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
.arg("-Ztarget-applies-to-host")
.arg("--config=target-applies-to-host=false")
.env("RUSTFLAGS", "--cfg foo")
.with_status(101)
// Sometimes it compiles. Not deterministic...
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] cc v1.0.0 (registry `dummy-registry`)
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rlib
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rmeta
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[COMPILING] cc v1.0.0
[ERROR] failed to build archive: No such file or directory
[ERROR] could not compile `cc` (lib) due to 1 previous error
"#]])
.run();
} |
Thanks for the investigation. Yes. I am just about to post the same observation. |
The PGO argument against including them in the hash is also very compelling. In solving #10744 (the issue behind the PR causing this) I treated as design constraints that:
Those constraints put rustflags firmly in the category of "In general this must include all things that need to be distinguished in different parts of the same build" from the same comment. If we're sharing the artifacts then they must be part of the same build. If we're using different rustflags we need to distinguish that. Brainstorming approaches: An effective but very inelegant approach would be to hash where rustflags come from instead of what they are. I.e. hashing a A more elegant approach, also suggested in #8716, is to "go back to hashing RUSTFLAGS, but only in the We could abandon the first design constraint (which I don't think anyone other than myself ever made explicit), always compile host and target dependencies separately when |
@weihanglo I happened to click on the commit you just pushed (a15807e), it doesn't fully fix this issue because in the |
Thanks and yes I just realized that. |
@gmorenz This is not too bad and safer than |
IIRC, Cargo has been doing this since #11252. Unless the purpose of people doing Anyhow, we can do a tiny optimization that only when rustflags is empty does Cargo share them. This is nearly useless IMO, but easier in terms of implementation. |
Refining that proposal slightly, I don't think we actually need the whole enum. E.g.
I'm pretty sure my testing shows differently... I believe there's actually code to check if you can deduplicate host dependencies by changing debug info to match non-host dependencies though I'd need to dig that up again. |
There's code in #11252 that ensures deduplication happens: https://github.com/rust-lang/cargo/pull/11252/files#diff-195c704b6ca429e9c366aec7aa05d5c3f429ad41acdd6602a4ce946eb03e4f74R441
Today, yes. I'd really like to see these become the default some day (maybe tied to an edition). That's a discussion for somewhere else, but it's guiding the design choices I'm advocating for. |
Yes. Only when criteria is met. See this
Feel free to start the work if you're willing to. I won't be available to code in a few hours for a day or two. |
I'll push a PR tomorrow |
|
Problem
Got lots of warnings like below
Steps
no warnings:
warnings:
Possible Solution(s)
No response
Notes
Version
The text was updated successfully, but these errors were encountered: