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

Implement wasm=>host feature query #37

Closed
wants to merge 2 commits into from

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Mar 12, 2020

Supersedes #36, closes #35

This implements a call from the wasm to the host runtime that queries for a given feature string, returning 0 for a feature that has been shared as false, 1 for true, and any other value (-1) for a flag that has not been shared to the wasm.

Rather than bolting this onto proc_macro2 like was done in the PoC #36, I've created a new micro-crate to link just this functionality, that the macro can use as a path dependency (as is patched for proc_macro2 as well).

For testing/not-in-watt use, the crate should probably only link the watt impl under a feature flag, and just always return Some(true).

@CAD97 CAD97 mentioned this pull request Mar 12, 2020
@CAD97
Copy link
Contributor Author

CAD97 commented Mar 12, 2020

The way to inform the runtime of what features to forward can, of course, be changed. I do not believe there is a fully implicit/automatic way that this could be done, but I also think that this "opt-in sharing" is in line with the design of wasm of being secure-by-default and share-nothing-by-default.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this and the other PR! I think, looking at these implementations, I would prefer to hold off growing the API in this way until we have a bit more experience to assess how commonly functionality like this is required.

For now hopefully the workaround of communicating features as tokens unblocks what you are building.

@dtolnay dtolnay closed this Mar 12, 2020
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.

Forwarding cargo features into the wasm
2 participants