-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
cargo: Fix feature resolution #12952
Conversation
0ca3969
to
8008bb7
Compare
d2da16b
to
4aa5b35
Compare
Before this MR it was possible to have a wrap or Cargo.lock for one specific crate which then also has a Cargo.lock with its own dependencies. With this MR, that doesn't seem to be the case anymore. |
@swick I'm not sure exactly what you mean. If the main project has a wrap for a cargo dependency, the Cargo.lock from that dep will be used as well. The big limitation this PR leaves is when you have multiple "entry point" into cargo. For example when the main project does :
If The easy workaround for that would be to have a single entry point, for example by adding |
Actually, reading the code again (been a while), it's a bit more complicated than that. The way Cargo works is the top level Cargo.lock takes precedence over all other dependencies. The main project's Cargo.lock is supposed to contain the whole dependency tree. It may not work exactly that way in Meson currently... need to double check. |
@swick I think I understood what you mean and I added a commit to fix your case. Can you test it again please? |
Same error locally as in CI. e: |
With that fixed it's behaving as before. e: The questions are answered in the docs update of this PR. I still don't know how to make my setup work though. If I have tow dependencies, their features are not unified though, are they? This is what I currently get:
I'm also failing to turn on the specific feature:
|
9cfcdd8
to
856ef89
Compare
They are not unified, that's the limitation I mentioned that could be worked around by adding e.g.
This PR removes those per subproject feature options because features are global. I think we should add a global module option like As workaround for now, you can create a dummy cargo project that depends on both crates you need, and use that as meson subproject. |
856ef89
to
9e60bec
Compare
Yeah, that seems to work. Now the biggest issue seems to be |
9e60bec
to
93534fd
Compare
93534fd
to
e527d8a
Compare
Breaks: This change removes per feature Meson option That were previously | ||
possible to set as show above or from command line `-Dfoo-rs:feature-foo=true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this also break projects that are setting those options via default_options: [...]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's an incompatible change for cargo subprojects, but we never claimed that was stable. Hopefully not many projects actually uses it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking and I cannot find a single place where we claim it is not stable, either as a meson warning (the way we print for import()
of an unstable module) or in the documentation.
I think the technical term for this is "we blew it".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's here: #12358. I asked many times to merge that before release...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the technical term for this is "we blew it".
yes... :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we did. I meant to just merge 12356 and replace it later if I ever got 12358 working. That's on me
Introduce a global Cargo interpreter state that keeps track of enabled features on each crate. Before generating AST of a Cargo subproject, it downloads every sub-subproject and resolves the set of features enabled on each of them recursively. When it later generates AST for one its dependencies, its set of features and dependencies is already determined.
The library name defaults to its package name, but it can be different. For example: - package name: cairo-sys-rs - library name: cairo-sys - dependency name: ffi
In the case the main project has a .wrap file for a cargo subproject, that subproject's Cargo.lock must be loaded before we can recursively fetch all its dependencies.
e527d8a
to
1070e56
Compare
This is based on top of #12945