-
Notifications
You must be signed in to change notification settings - Fork 824
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
Recommended pattern to setup workspace have multiple binary depends on different feature sets #2817
Comments
Hey @kwonoj, I'm unable to access the repo posted: https://github.com/kwonoj/wasmer-js-test/tree/workspace-features-resolution So I'll reply a bit more blindly. It might be also doable to do it via target features. To put an example in our repo, the wasmer-wasi integration can target both the native system and the JS (just depending on its features) and it works in the desired way when used as a dependency. |
@syrusakbary sorry, I just made repo public. There is more contrived example at https://github.com/swc-project/swc we are trying to build, so far my attempt to set default-features=false with opt in specific feature somehow didn't work. |
No worries. How could I reproduce the issue on the provided repo? |
mind try |
Few findings:
I also created the PR showcasing a fix: kwonoj/wasmer-js-test#1 |
Thanks, I'll try to utilize suggestion into main repo to see if I can make things work. One quick q - https://github.com/kwonoj/wasmer-js-test/pull/1/files#diff-980f9468767d9444054506ddfa23bf39b71cafa00a6fe14d28339e2b85b98705R2 in here it selects specific pkg to build, will build whole ( |
No, the general I think the best way to manage this is to have the wasmer dependency in one crate only and feature gate the js or native options as we do for example in wasmer-wasi: https://github.com/wasmerio/wasmer/blob/master/lib/wasi/Cargo.toml In Wasmer, we had this same issue, and basically we are able to compile wasmer natively with So it's definitely doable |
Sorry, please allow me to have one more question: the repo's example is simplified, the actual goal is a base package contains (basically this again)
This is essentially same as what you suggested
if I understood correctly?
This is actually something I wanted to avoid and curious if I could still use current practices (just running |
Yup, that's it!
What we currently do in our codebase is: the native build builds normally with Hope this clarifies! |
Thanks, that was helpful context. I'll try to dig bit further on our end. |
Hey @kwonoj, please let us know if we should keep the issue open (if something is not yet clarified or there are more changes to do in our side) |
I saw you checked actual work swc-project/swc#4012 (comment) , indifferent to close issue or use it for further tracking. |
It's not super elegant but at least seems I've reached |
2821: build(wasmer/cache): opt 'sys' into default feature r=syrusakbary a=kwonoj <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description Context: this is originated from #2817 (comment) , where SWC (https://github.com/swc-project/swc) trying to setup its package dependencies orthogonally requires two distinct features of wasmer (js / sys), encounters feature selection getting merged by cargo. We have workaround it by manual opt in into each features, but the common dependency we have imports wasmer-cache, which ends up to enabling `sys` mandatory. It is also possible to do some workaround by having a feature with make dep as optional, but I feel it'd be better if `cache` allows to opt out from feature. I am honestly not sure if this is acceptable or recommended approach to resolve issue. Please feel free to close if that's the case. # Review - [ ] Add a short description of the change to the CHANGELOG.md file Co-authored-by: OJ Kwon <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
2821: build(wasmer/cache): opt 'sys' into default feature r=syrusakbary a=kwonoj <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description Context: this is originated from #2817 (comment) , where SWC (https://github.com/swc-project/swc) trying to setup its package dependencies orthogonally requires two distinct features of wasmer (js / sys), encounters feature selection getting merged by cargo. We have workaround it by manual opt in into each features, but the common dependency we have imports wasmer-cache, which ends up to enabling `sys` mandatory. It is also possible to do some workaround by having a feature with make dep as optional, but I feel it'd be better if `cache` allows to opt out from feature. I am honestly not sure if this is acceptable or recommended approach to resolve issue. Please feel free to close if that's the case. # Review - [ ] Add a short description of the change to the CHANGELOG.md file Co-authored-by: OJ Kwon <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
Summary
Hi, this time's question is regarding organizing workspaces.
Here's simplified example https://github.com/kwonoj/wasmer-js-test/tree/workspace-features-resolution
A and B are orthogonal, no direct overlaps except sharing some of common dependencies. Common dependency opt to in to specific feature of wasmer depends on build target. This makes build failures by cargo, with errors like
Which looks like cargo try to resolve wasmer for every feature for each build target somewhat sound similar to rust-lang/cargo#4463, but cannot say for sure if this is the exact case or wasmer have some internal behavior raises this.
Is there a recommended pattern to workaround this in easy way?
Thanks.
Additional details
Provide any additional details here.
The text was updated successfully, but these errors were encountered: