268: add experimental virtual filesystem r=lachlansneff a=xmclark
This PR introduces some changes to the runtime and adds a new feature: virtual file system.
In the future, we may want to bundle data with our wasm apps. That data can be made available to apps in a virtual filesystem by the wasmer runtime. To do this:
- wasmer must understand custom section data
- wasmer must re-wire emscripten calls to access a virtual file system
- these features are experimental and should be guarded by a feature flag (`--features vfs`)
~This PR adds support for the `read` syscall. ~
Just kidding, this PR does a lot more. Enough syscalls were re-implemented that a code reorg was warranted.
Additions below ⬇️
Several new modules live under and around the `syscalls` module. These features are only supported on linux, but can be expanded to windows.
There are effectively two implementations: one for VFS and one for the host FS. In the future, we will have more tight control over access to the host, but this will do for now. The `select` function was also extracted into a new module as the complexity increased significantly.
`select`should be refactored in the future to use a runtime like tokio, but that will need to wait.
The introduction of the libsodium dependency introduced some stumbling blocks, so I forked the zbox project and added a new build step. See it [here](https://github.com/wasmerio/zbox/blob/bundle-libsodium/build.rs). This will build libsodium at `cargo build` time and will automatically configure the environment. This will help with adoption and it is something we may be able to give back to zbox.
Additional changes:
After review, this PR is just a bit too large. We will implement the emscripten changes in another PR. This will help accelerate the work on WASI.
Co-authored-by: Mackenzie Clark <mackenzie.a.z.c@gmail.com>
295: generate null funcs r=syrusakbary a=xmclark
This PR automates adding the `nullfunc` imports. A new macro is added to help working with namespaces. All functions in the env namespace that start with `nullFunc_` will be added to the import object. This is easy because *all* null funcs have the same expected signature.
Co-authored-by: Mackenzie Clark <mackenzie.a.z.c@gmail.com>
296: feat(runtime-c-api) Implement the `wasmer_export_to_memory` function r=Hywan a=Hywan
This new function returns a `wasmer_memory_t` from a `wasmer_export_t`. It allows to use the `wasmer_memory_*` API over the exported memories from a Wasm instance.
See `tests/assets/return_hello.rs` and `tests/test-exported-memory.c` for an end-to-end example.
This PR also moves all `tests/.wasm` files into `tests/assets/`. I've added the source of `return_hello.wasm` to be exhaustive and to serve as a documentation.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>