-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Resolver is too strict in its multiple-crates-links
-ing check
#5969
Comments
cc @Eh2406, would you be able to help out with this one? |
@kamalmarhubi that is an important issue, but I am not quite seeing how you were proposing to use features to solve it. What prevents someone from specifying that they need both features? Can you point me at what you have tried so far? |
Note that #6179 (comment) wuld provide a workaround by using |
I know that features are additive, and I would like to use it as advantage: emit an error if and only if the final union of all enabled features ends up pulling two crates with conflicting Regarding lockfile, maybe build the lockfile while completely ignoring existence of |
Features being additive means that if it work with feature Checking |
The example you've linked to contains two semver-major-incompatible sqlite dependencies (0.x acts as major), so I think it's working as intended, and there is simply no solution for that dependency graph. I don't see how using The UX of dealing with conflicts is indeed poor. However, I think not looking at unused crates would make conflicts rarer, so it should actually improve the situation. |
We do ignore the unused optional crates in your dependencies. see my earlier reply. I believe this provides a way to work around this limitation in the functionality of |
In previous reply you've mentioned something about tests, but I don't see how that's related. The problem is reproducible with an empty project and just two dependencies (they are not dev deps, they're supposed to be usable in the final product). |
I am sorry for not explaining myself clearly. I am also sorry for coming across as rude and dismissive. You deserve a clear, explained, and reproducible response. Give me a little while to make sure I have my facts straight; I'd hate to spend the time to have a high quality right up that is completely wrong. |
Attached is a zip file, containing the folder structure I used to check that I was correct. The setup
The library
Just for testing, I added some code that depended on which features are on:
The problem There is no way to build "hard". A The
It can be built just fine and when it calls
It can be built just fine and when it calls So there is a way to make a shim library that can switch between two crates that have the same links attribute. It is painful to develop in, but it works. |
Thank you very much for your explanation and the example files. The result is very surprising to me, since I can build |
It is not intuitive. I would go so far as to say if we had to remake features from scratch this would not be the behaviour we would have designed. There are any number of "maybe someday we could" idys that may make this better without regressing the usability. Few of them are close to being designed let alone implemented. At least there is a workaround. |
I just experiemented with this example. If you are using workspaces and both library configurations are "reachable" within that workspace (choosing once libz-sys and once the cloudflare one), then this does not work. |
It still conflicts even in the In my case, I have a conflict in switching between |
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
I have a proposal for global, mutually exclusive features (https://internals.rust-lang.org/t/pre-rfc-mutually-excusive-global-features/19618) and hadn't considered this case! I wonder if there is a way we could tell cargo with that feature that this is safe. |
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: argmin-rs#368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
Due to the additivity requirement on cargo features even for features that are not enabled simultaneously, together with the requirement that only one crate in the dependency tree specifies any `links` attribute, it was not possible to test multiple backend versions for ndarray-linalg by features: #368 (comment) Previously this approach worked for different versions of ndarray-linalg insofar as the used backend `netlib` just coincidentally remained the same for all tested ndarray-linalg versions. This is not the case for the intel-mkl backend, which is desirable to use as the default because it works on all three major platforms. To enable the change of the backend as well as make the testing more robust against future changes in ndarray-linalg backend versions, the tests were factored out into their own crates. This works because the strict additivity requirement for inactive features is not enforced for dependencies: rust-lang/cargo#5969 (comment)
I'm attempting to use a feature to allow controlling which version of a -sys crate is used. It looks like I'm running afoul of the restriction on multiple crates having a
links
specified for the same library, even though in any particular invocation only one will be used.Does the resolver ignore features when deciding if a library is being linked multiple times? It seems that it is, and I think that it should only check the final resolved dependency tree for the target being built, and in particular after the features are applied.
The text was updated successfully, but these errors were encountered: