-
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
poor error messages when depending on a |crate-type = ["staticlib"]| crate #3169
Comments
Right now Cargo filters out non-linkable targets, for example a staticlib, because the compiler can't actually use that for We should definitely have an error there if there aren't actually any linkable targets, as it it's basically guaranteed to fail! I'm going to tag this as an |
OK, so I took a crack at fixing this, basically returning an error if
You can see the current effort at froydnj/cargo@3b6c255. I suspect this is some sort of interaction with things that we aren't actually building, so we'd need something a little finer-grained than |
@froydnj oh we don't want to return an error if any target is not linkable, only if all targets are not linkable. Some dependencies are build scripts (we don't link those) while other dependencies are staticlibs (we also don't link those). If a dependency is an rlib or a dylib though (we link those) then this should be fine. |
Oh, duh. I had actually implemented that behavior in |
Actually, I don't think that's quite right, either. In the example given to start this bug, |
Oh I thought the problem Gecko was having was that |
Yes, we really did want to link |
In that state though I figured it was invalid when |
What is "that state"? I don't understand this comment. |
@froydnj oh sorry for being a little belated to get back to you! The state there I was referring to was where |
Is this still open? Building against a
|
@lukaslueg I think so, for example of you have |
Indeed it does. I have a test in place that didn't actually Besides, the docs I mentioned above leave room for improvement as the language used suggests a level of certainty that isn't founded. |
Bail out when trying to link to a library that is not linkable. There are more subtleties here than expected, as we can have situations where it is actually Ok to have no linkable targets: Build scripts are a common case, yet benchmark tests started to also fail. I have to say I'm not convinced if the situation "not one target is linkable, yet at least one target is a library (and therefor at least something should be linked)" is actually correct. All tests pass, however, including the one that checks for #3169
I have a library,
gkrust-gtest
, that depends on another library,gkrust
. Whengkrust
'scrate-type
is set to["staticlib"]
inCargo.toml
, I get the following output:This error is most puzzling, as
gkrust
'sCargo.toml
is where one would expect, etc. If you look at thedeps
folder, you can even see alibgkrust.a
file:The error from
rustc
is misleading. Notice that therustc
invocation doesn't include an--extern
forgkrust
. The real problem here is that Cargo isn't telling the user upfront, "hey, you can't link to astaticlib
library like that, you need to do something different."Listing
rlib
as acrate-type
solves the problem, but it would be most excellent if Cargo detected the configuration problem first, rather than leavingrustc
to do a poor job of diagnosing the issue.The text was updated successfully, but these errors were encountered: