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

feature request: support WASI preview 2 #69

Open
HarikrishnanBalagopal opened this issue Jan 29, 2024 · 3 comments
Open

feature request: support WASI preview 2 #69

HarikrishnanBalagopal opened this issue Jan 29, 2024 · 3 comments

Comments

@HarikrishnanBalagopal
Copy link
Contributor

golang/go#65333
https://github.com/WebAssembly/WASI/tree/main/preview2

@bjorn3
Copy link
Owner

bjorn3 commented Jan 29, 2024

WASI preview 2 depends on the wasm component model which browsers don't natively support. You need something like jco to transpile it to core wasm modules. Jco has experimental support for running WASI preview 2 in the browser already, so I think there is not much of a point to adding wasi preview 2 support to browser_wasi_shim.

@HarikrishnanBalagopal
Copy link
Contributor Author

HarikrishnanBalagopal commented Jan 30, 2024

WASI preview 2 depends on the wasm component model which browsers don't natively support. You need something like jco to transpile it to core wasm modules. Jco has experimental support for running WASI preview 2 in the browser already, so I think there is not much of a point to adding wasi preview 2 support to browser_wasi_shim.

Does JCO support WASI preview 1? because a lot of apps were compiled against WASI 0.1 and have yet to switch.

Also the virtual filesystem in this shim library is very flexible and I am not sure if JCO has an equivalent.

This is also interesting https://github.com/bytecodealliance/WASI-Virt

For example, consider converting an application to a WebAssembly Component that assumes it can load read some files from the filesystem, but never needs to write.

Using WASI Virt, those specific file paths can be mounted and virtualized into the component itself as a post-compile operation, while banning the final component from being able to access the host's filesystem at all. The inner program still imports a wasi filesystem, but the filesystem implementation is provided by another component, rather than in the host environment. The composition of these two components no longer has a filesystem import, so it can be run in hosts (or other components) which do not provide a filesystem API.

@bjorn3
Copy link
Owner

bjorn3 commented Jan 30, 2024

Does JCO support WASI preview 1?

There is an adapter between wasi preview1 and wasi preview2: https://github.com/bytecodealliance/cargo-component/tree/main/adapters/ab5a448 I don't know if there exists anything to apply this adapter with JCO rather than having to run a native executable to produce a new adapted wasm component.

Also the virtual filesystem in this shim library is very flexible and I am not sure if JCO has an equivalent.

Never tried it, so I can't for sure, but it seems like there is at least some amount of flexibility: https://github.com/bytecodealliance/jco/tree/main/packages/preview2-shim/lib/browser

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

No branches or pull requests

2 participants