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

build(wasmer/cache): opt 'sys' into default feature #2821

Merged
merged 6 commits into from
Mar 19, 2022
Merged

build(wasmer/cache): opt 'sys' into default feature #2821

merged 6 commits into from
Mar 19, 2022

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented Mar 17, 2022

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

@kwonoj kwonoj requested a review from syrusakbary as a code owner March 17, 2022 02:12
@syrusakbary
Copy link
Member

syrusakbary commented Mar 17, 2022

I thought about this further, and compiling wasmer-cache without the default features (that is without wasmer/sys) will make Rust compilation fail, as it depends on serialization/deserialization being present in the wasmer crate, however those methods are not present in wasmer/js.

To make this work when the default options are not present, the solution is simple: implement serialization/deserialization in wasmer/js, so wasmer-cache can be used also from JS. How?

Also, we could make serialization a feature in wasmer/js as well, so we don't have an added overhead saving the bytes if the user doesn't need serialization present.
Thoughts?

We can do that as part of the PR and we should be good to merge! :)

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 17, 2022

Thanks for the guide, I'll peek if I can spin some time to shape PR to correctly include those.

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 18, 2022

I tried to add a few paths as much to follow suggestions, open to reflect fixes / suggestions.

Comment on lines 28 to 30
default = ["sys"]
sys = ["wasmer/sys-default"]
js = ["wasmer/js-default", "wasmer/js-serializable-module"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should enforce sys or js by default. We can simplify this such as:

Suggested change
default = ["sys"]
sys = ["wasmer/sys-default"]
js = ["wasmer/js-default", "wasmer/js-serializable-module"]
default = ["wasmer/js-serializable-module"]

This should work without adding any feature dependency on wasmer (that is, that the wasmer crate will not automatically use js or sys, it will just use the wasmer/js-serializable-module feature when using js but do nothing on sys, which is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was curious about this

wasmer crate will not automatically use js or sys

Wouldn't it make existing build as breaking, that upper deps having wasmer-cache or transitive deps need to manually opt in sys if they're using default? Or it'll be fine since any pkg having wasmer already may opt in js / sys?

Copy link
Member

@syrusakbary syrusakbary Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think I was not super clear. I think the filesystem should be enabled by default as well (that way there are no breaking changes).
However, we should not enforce sys or js by default (wasmer-cache should remain agnostic).
In any case, I did applied a small suggestion and the PR looks good!

@syrusakbary
Copy link
Member

Thanks @kwonoj, I added some feedback!

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 18, 2022

Thanks for the help, updated as suggested.

lib/cache/Cargo.toml Outdated Show resolved Hide resolved
@syrusakbary
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Mar 18, 2022
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]>
@bors
Copy link
Contributor

bors bot commented Mar 18, 2022

Build failed:

@syrusakbary
Copy link
Member

syrusakbary commented Mar 18, 2022

Linting is failing, but once is solved we should be good to merge.
You can lint locally with: cargo fmt --all @kwonoj

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 18, 2022

Thanks, applied fmt.

@syrusakbary
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 19, 2022

@bors bors bot merged commit 5b77bc4 into wasmerio:master Mar 19, 2022
@kwonoj kwonoj deleted the feat-cache-no-default-sys branch March 19, 2022 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants