-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.
Description
Docs: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#package-features
A tracking issue for #5353 and #5351. Historically, --feature
and related flags applied to the current package, and not to the package, specified via --package
. This is a bug, but fixing it could break someone's code, so currently new behavior exists under -Z package-features
opt-in. We need to check if it breaks code in the wild to see what we should do next.
ebkalderon, gnzlbg, dmitry-timofeev, stanislav-tkach, mtak- and 11 more
Metadata
Metadata
Assignees
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
matklad commentedon Apr 16, 2018
#5362 is I think the manifestation of the old odd behavior.
matklad commentedon Apr 16, 2018
Announcement on irlo: https://internals.rust-lang.org/t/help-us-test-the-breaking-bug-fix-to-cargo-features/7317
matklad commentedon Apr 16, 2018
I think #4942 is also this issue.
matklad commentedon Apr 16, 2018
And #4753 as well
dwijnand commentedon Apr 16, 2018
[-]New behavior of `--feature` + `--pacakge` combination[/-][+]New behavior of `--feature` + `--package` combination[/+]matklad commentedon Apr 28, 2018
This broke Servo unfortunately, so we probably would need to back this out, at least in this, maximally aggressive, form.
However, I wonder what we plan to do with feature-selection problems in general?
I assume that we want to eventually fix the main problem with features. Currently, features are global per compilation, and that means that features bleed from dev-deps to normal deps and that
cargo build -p foo
andcargo build -p foo -p bar
build thefoo
package differently.Fixing that, however, would be a breaking change: suddenly, Cargo would select a smaller set of features :-(
But, if we do fix that, then behavior of the combination of
--package
and--features
would necessary change as well. In other words, this PR is sort of a subset of that larger issue.The core question I think is do we feel comfortable with eventually changing the set of activated features? If we are, then I think we can modify current fix to not flatly error-out, but to ignore the features argument for several packages, printing a warning like "this was accepted in previous versions of Cargo and activated features in surprising way, and not it is ignored".
--feature
#5390pravic commentedon Apr 28, 2018
Used to work. And expectation was "Enable the specified set of futures for crates that support it".
Now we see this (thanks to CI to catch it soon and not after Rust release) and it does not matter whether all of workspace members have
xyz
or not, error is the same.How come that the original issue (
cargo --package foo --feature feat
) has affected builds without--package
? #5390 wasn't a good idea without a compatibility explanation (what is it? how to fix that mystical error? how it will work in future?). That error must have contained at least the issue number (since it is a breaking future and it is in nightly (i.e. unstable) anyway).matklad commentedon Apr 28, 2018
Not that this expectation is wrong. What actually happens is that the feature is enabled only for the package in the current working directory. In other words, it is irrelevant whether all members have the
xyz
feature, because this applies only to a single member, and not the one that is specified via the-p
argument.That was definitely an oversight on my part :(
matklad commentedon Apr 28, 2018
Here's a small example which demonstrates the difference in behavior: https://github.com/matklad/features-behavior
matklad commentedon Apr 28, 2018
--all
is a shorthand for--package member1 --package member2 --package member3
etc, and suffers the same problem:--feature
flag does not apply to the selected packages. I've extended the example at https://github.com/matklad/features-behavior to show how this affects--all
.--feature
" #543070 remaining items
Enable the `uffd` feature by default, but filter on OS
default-features = false
not working for dependency inside workspace. #8366Auto merge of #8997 - ehuss:stabilize-features, r=alexcrichton
Optionally compile wasmtime-bench-api with wasi-nn and wasi-crypto
Optionally compile wasmtime-bench-api with wasi-nn and wasi-crypto (#…