-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Features required for dependencies influenced by build-dependencies. #107845
Comments
If you're building in a virtual workspace then it's very likely you need to opt in to resolver version 2. Read this for more information https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2 |
You might have already noticed this, but you should read this too https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions |
@Xaeroxe awesome. Thanks so much for pointing me at this, you've saved me so much time! I'd have struggled to find this by myself! |
So it seems my issue is two-fold:
|
I don't think this should error, no, it's reasonable for a library to be unconditionally no_std but be used by a binary that links std.
You should report this in rust-lang/cargo; I don't think rustc has enough information to give a useful error. |
A couple of (stale) open pull requests addressing this. Feel free to jump in and move them forward. |
@weihanglo could you move this to the cargo issue tracker please? |
Given we have other issues covering this, I propose to close it as duplicate. |
I am trying to build a
#![no_std]
crate, but encountering the following error from the linker...Even though my crate is
no_std
, the linker is seemingly trying to linkstd
nonetheless (indeed if I comment out my implementations of the above functions in my crate, it links sucessfully). However, if a crate is markedno_std
, you wouldn't expect the std crate to be linked in no matter what, so this seems pretty odd?Anyway, I then investigate the dependencies for my crate to see where
memchr
is being included as a dependency. So as expected, it is included bycstr_core
from myCargo.toml
. But also as a build dependency frombindgen
.However,
cstr_core
should not include thestd
feature of memchr (e.g. thestd
feature should be required only at build time and not needed to be linked into the resulting binary). A similar project also linked againstcstr_core
, but without usingbindgen
shows no such depdendency?Have I mis-understood something?
The text was updated successfully, but these errors were encountered: