Skip to content
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

Consider interaction between artifact dependencies and required-features #12061

Open
dtolnay opened this issue Apr 29, 2023 · 3 comments
Open
Labels
C-bug Category: bug S-needs-rfc Status: Needs an RFC to make progress. Z-bindeps Nightly: binary artifact dependencies

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 29, 2023

Problem

When you use artifact dependency to depend on a binary that has required-features, those features do not get enabled automatically. Should they?

This was not addressed in the artifact dependencies RFC.

Steps

For example the lalrpop package currently contains this binary crate:

[package]
name = "lalrpop"
version = "0.19.12"

[dependencies]
pico-args = { version = "0.4", default_features = false, optional = true }

[[bin]]
name = "lalrpop"
required-features = ["pico-args"]

If something depends on that binary as an artifact dependency, it will fail to build.

[dependencies]
lalrpop = { version = "=0.19.12", artifact = "bin" }
$ cargo check -Z bindeps

error[E0463]: can't find crate for `pico_args`
 --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lalrpop-0.19.12/src/main.rs:2:1
  |
2 | extern crate pico_args;
  | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

Possible Solution(s)

I would prefer if required-features of an artifact dependency automatically got enabled.

Notes

Mentioning artifact dependencies tracking issue: #9096

Version

cargo 1.71.0-nightly (9e586fbd8 2023-04-25)
release: 1.71.0-nightly
commit-hash: 9e586fbd8b931494067144623b76c37d213b1ab6
commit-date: 2023-04-25
host: x86_64-unknown-linux-gnu
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1t)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Ubuntu 22.04 (jammy) [64-bit]
@dtolnay dtolnay added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Apr 29, 2023
@dtolnay
Copy link
Member Author

dtolnay commented Apr 29, 2023

@rustbot label +Z-bindeps

@rustbot rustbot added the Z-bindeps Nightly: binary artifact dependencies label Apr 29, 2023
@weihanglo weihanglo added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label Jun 1, 2023
@weihanglo
Copy link
Member

I think this is covered by rust-lang/rfcs#3374.

When depending on a binary artifact dependency, Cargo should enable any enable-features features of that binary. This may require plumbing that information into the index so that the dependency and feature resolvers can determine that field is being set. This RFC does not propose a specific plan here, but that it should eventually be supported.

Leave this open as the RFC is not yet merged.

@weihanglo weihanglo added S-needs-rfc Status: Needs an RFC to make progress. and removed S-triage Status: This issue is waiting on initial triage. S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. labels Jun 2, 2023
@Nemo157
Copy link
Member

Nemo157 commented Jun 30, 2023

It seems like it should at least error earlier currently, if the required features are not active it should not be attempting to build the binary at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-rfc Status: Needs an RFC to make progress. Z-bindeps Nightly: binary artifact dependencies
Projects
None yet
Development

No branches or pull requests

4 participants