-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo build
with a build-dependency that is a cdylib
results in a warning
#7825
Comments
Do we ignore |
The warning seems correct. The build script will not link against a cdylib. Can you explain more what you are trying to do? Why do you need a cdylib? What do you expect rustc to do with it? |
I would like to make an |
While unusual, imho depending on something which is linked manually is a legitimate use-case. This was explicitly considered in #4797. The reason for the strong warning is that cargo can't predict if linking will indeed fail if non-linkable targets are built, a situation leading to confusing error messages. It was also considered in #4797 that we might need an escape hatch which allows signaling that the user is aware that the target may not be linkable, suppressing the warning. |
An escape hatch sounds reasonable. There might be a bigger discussion around dealing with dependency crate types (it has come up a number of times). As for the original report, is there a reason you are using build-dependencies instead of normal dependencies? build-dependencies are intended for build.rs scripts. I would think in this case it should be a normal dependency. |
I had initially set up a build script but didn't really need it. Though since this particular binary depends on the |
I also recently noticed this problem in window-rs (microsoft/windows-rs#2545). I certainly hope it does not become a "hard error in the future". 😊 |
The original PR #4797 fixed a bad - that is, non existent - error message. We deliberately turned this into a warning instead of an error, as legitimate use cases might arise at a later time. Almost seven years have now passed since the original bug report, and there have been numerous requests to un-threat-ify the warning. IMHO the argument between "we might not be able to support this" vs. "hold my beer and watch this" comes down on the side of the beer. If there are no fundamental reasons that break Cargo (especially in hypothetical dependency-of-dependency cases, breaking upstream builds), this should be accepted behavior. Because it is. |
Various examples of "hold my beer and watch this" can be found in https://github.com/microsoft/windows-rs Please don't break me. 🙏 |
cargo build
emits the following warning when in theCargo.toml
under[build-dependencies]
I include a crate of typecrate-type = ["cdylib"]
(thecrate-type
is specified in the dependency'sCargo.toml
). The warning does not show if I modify the dependency'sCargo.toml
to compile withcrate-type = ["dylib"]
. However, I need the library to be acdylib
.The text was updated successfully, but these errors were encountered: