Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upShared build+target dependency crates conflate features #4361
Comments
This comment has been minimized.
This comment has been minimized.
|
Okay, it looks like the underlying reason that libc fails to compile in the latter case is a misunderstanding on my part about compiling libc at all on os-less targets, but I still think there's something weird. :) |
alexcrichton
added
the
A-features
label
Aug 9, 2017
This comment has been minimized.
This comment has been minimized.
|
IIRC there's another issue or two related to this in Cargo's issue tracker. It's related to how feature resolution works today which happens on a per-crate basis instead of just per-crate-within-a-target basis. |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Nov 17, 2017
|
This may be the same problem I'm hitting?
The build command incorrectly uses default features for
(error is because The only workaround I see is to remove Repo and version: https://github.com/dhardy/rand/tree/53ab77e320184b0950dfbdd44439fd44bdb57700 |
This comment has been minimized.
This comment has been minimized.
|
@dhardy I think that's the same issue, yes, but I believe it's because |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Nov 20, 2017
|
I don't really understand why That
|
This comment has been minimized.
This comment has been minimized.
cretz
commented
Nov 29, 2017
•
|
Note, this is failing with |
This comment has been minimized.
This comment has been minimized.
|
@dhardy sorry for the delayed response but Cargo has the concept of a "current package", and flags like @cretz I think that may be unrelated? |
This comment has been minimized.
This comment has been minimized.
cretz
commented
Nov 30, 2017
|
@alexcrichton, yes, likely... sorry |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Nov 30, 2017
|
@alexcrichton I wasn't building anything which depended on |
This comment has been minimized.
This comment has been minimized.
|
@dhardy try doing:
and you should see the same error. The |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Dec 1, 2017
|
@alexcrichton that's besides the point. As I understand it,
Yes, this may mean I guess the problem would be more apparent if there was a way to depend on another crate explicitly without certain features; that way there would be a feature resolution error if Cargo tried to build |
This comment has been minimized.
This comment has been minimized.
|
@dhardy heh sorry so this is when it quickly balloons into a larger design question! What I meant previously is just to explain what Cargo currently does, and then also what Cargo currently does is that it only ever compiles a crate once, never twice with different feature sets. Cargo by default unions all features for a crates so they're required to be additive, and this has been Cargo's behavior for quite some time as well! In that sense I believe right now |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Dec 1, 2017
|
Heh, yes it is a deeper Cargo design problem. Feature union (half) makes sense when crate X has multiple dependencies within the same build target (single lib or bin), but when the output targets are separate (libs or bins) it doesn't make sense IMO, but as you say Cargo can't do anything else for now. |
radix
referenced this issue
Dec 29, 2017
Open
Don't pass `--features` from `dev-dependencies` to `dependencies` #4664
This comment has been minimized.
This comment has been minimized.
archshift
commented
Feb 5, 2018
|
Given Rust's 2018 mission of being friendlier to use for embedded systems, I feel that this should be a higher priority. It basically renders it impossible to use any build-time crates which depend on |
alexcrichton
referenced this issue
Mar 5, 2018
Merged
Emit Resolve.features_sorted in "cargo metadata" #5122
This comment has been minimized.
This comment has been minimized.
|
This appears to be related to #2589 |
thenewwazoo commentedAug 4, 2017
Sorry about the title, this one was hard for me to nail down.
I'm working on a project (embedded, no_std) that relies on both
bindgenas a build-dependency andlibcas a dependency. When I setdefault-features = falsein Cargo.toml forlibc, the use ofbindgen(which depends uponlibc) influences the features enabled inlibcwhen building for the target. To wit:When
bindgenis specified as a build-dependency, thelibccrate is built with the command line:this fails for want of
std, namelyerror[E0463]: can't find crate for 'std'.When bindgen is removed, the
libccrate is build with the command line:this fails for reasons related to missing types (which appears to be a bug in
libc?), e.g.error[E0412]: cannot find typec_charin this scope.