-
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
What to do about duplicate targets in a workspace? #6293
Comments
Hm I hadn't thought of this before! I think I'd personally be a fan of the hard error though. The result is already nondeterministic and probably broken today, so as long as we don't have any false positives from the error it seems unlikely that we'll break existing working workflows! |
I download ~3300 workspaces off github to see how widespread it was. I found 63 workspaces that get tripped by this error. The rust-lang/rust repo had this problem until recently ( CLICK - list of affected workspaceshttps://github.com/Hossein-Noroozpour/vulkust/tree/master error: package more-things has a bin target with the same name `main` as package hello-world https://github.com/OpenAPITools/openapi-generator/tree/master/samples/server/petstore/rust-server https://github.com/vorner/spirit/tree/master https://github.com/hawkw/tokio-trace-prototype/tree/master https://github.com/Arvamer/gilrs/tree/master https://github.com/Avekvist/oxygen-game-engine/tree/master https://github.com/Grokmoo/sulis/tree/master https://github.com/diesel-rs/diesel/tree/master https://github.com/msiglreith/tanya/tree/master https://github.com/tobyjsullivan/fonts/tree/master https://github.com/tokio-rs/tokio/tree/master https://github.com/rust-av/opus-rs/tree/master https://github.com/qnighy/honeybadger-rs/tree/master https://github.com/Nemo157/embrio-rs/tree/master https://github.com/mit-pdos/noria/tree/master https://github.com/sozu-proxy/sozu/tree/master https://github.com/dgrunwald/rust-cpython/tree/master https://github.com/rustkas/rust-by-example-imp/tree/master/rust-by-example https://github.com/sozu-proxy/lapin-futures-tls/tree/master https://github.com/diwic/dbus-rs/tree/master https://github.com/paritytech/jsonrpc/tree/master https://github.com/SergioBenitez/Devise/tree/master https://github.com/kureuil/batch-rs/tree/master https://github.com/glebpom/rust-netif/tree/master https://github.com/cogciprocate/ocl/tree/master https://github.com/rust-av/speexdsp-rs/tree/master https://github.com/ubnt-intrepid/doubter/tree/master https://github.com/lettre/lettre/tree/master https://github.com/weiznich/wundergraph/tree/master https://github.com/WiSaGaN/ctp-rs/tree/master https://github.com/marhel/r68k/tree/master https://github.com/dtcristo/raylib-rust/tree/master https://github.com/Hoverbear/rust-rosetta/tree/master https://github.com/LevitatingOrange/oblivious-transfer/tree/master/examples https://github.com/erlepereira/x11-rs/tree/master https://github.com/johalun/rustkpi/tree/master/rust/rust-src-1.25.0/src https://github.com/royallthefourth/platformsh-rust-rocket/tree/master https://github.com/George3d6/Inquisitor/tree/master https://github.com/hhatto/rust-snippets/tree/master/extension https://github.com/little-dude/netlink/tree/master https://github.com/king6cong/moon/tree/master https://github.com/tailhook/abstract-ns/tree/master https://github.com/elastic-rs/elastic/tree/master https://github.com/kabelyang/Parity-JSON-RPC/tree/master https://github.com/gretchenfrage/ws_problem/tree/master https://github.com/mimirblockchainsolutions/mimir-rust-alpha/tree/master https://github.com/benywan/jsonrpc/tree/master https://github.com/akashche/itw_win_devkit/tree/master/rust/src https://github.com/stefan-k/kraxn/tree/master https://github.com/jjpe/amplify/tree/master https://github.com/super-string/jsonrpc/tree/master https://github.com/randomPoison/polygon/tree/master https://github.com/mob-rs/mob/tree/master https://github.com/ryoon/rustc-1.19.0/tree/master/src https://github.com/KeenS/onigmo-rs/tree/master https://github.com/sorpaas/devp2p-rs/tree/master https://github.com/sujayakar/rust-rt/tree/master/rust-cpython https://github.com/combustion-engine/combustion/tree/master https://github.com/aidanhs/rust-appveyor/tree/master/src https://github.com/zzeroo/ArcadeRS-1.0/tree/master https://github.com/JBisnett/rust-mir-plugin/tree/master/src https://github.com/Metadiff/gir/tree/master https://github.com/lazybox/lazybox/tree/master |
Hm that's quite a few! I wonder, though, if we can still get away with making this a hard error. If we change it to say that in one build if more than one binary of the same name is produced with the same name that's an error, then that may mostly cover our bases. Today's behavior is "pretty wrong" in the sense that it's just giving you a random binary with the right name, so it seems unlikely that anyone's build steps are building the same named binary in the same build step. I think it's probably best though, given this data, to start with a warning. I think the warning should be scoped to only where we'd want a hard error eventually (probably only for when you're building two binaries of the same name, not if they just exist in a workspace). |
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.
Currently a workspace can have multiple packages with the same target names. This causes a problem if you attempt to build both targets at the same time. One will overwrite the other when it is hardlinked in the target dir, and the result is somewhat random.
This affects binaries, examples, and libraries. Tests and benchmarks have unique hashes in their names.
I'm unsure of the best way to deal with this. One option is to issue a warning if this happens (at workspace validation phase), and turn that warning into a hard error after a sufficiently long time.
Another option is to detect if you attempt to build conflicting targets and return an error explaining you can only build one at a time (with some explanation about the naming conflict).
The text was updated successfully, but these errors were encountered: