Commit Graph

1044 Commits

Author SHA1 Message Date
Ivan Enderlin
995a2d4779 feat(c-api) No longer expand with cbindgen: drop dependency to Rust nightly.
So. Let's explain a dirty hack. `cbindgen` reads the code and collects
symbols. What symbols do we need? None of the one declared in
`wasm.h`, but for non-standard API, we need to collect all of
them. The problem is that `wasm_named_extern_t` is the only
non-standard type where extra symbols are generated by a macro
(`wasm_declare_boxed_vec!`). If we want those macro-generated symbols
to be collected by `cbindgen`, we need to _expand_ the crate
(i.e. running something like `rustc -- -Zunstable-options
--pretty=expanded`). Expanding code is unstable and available only on
nightly compiler. We _don't want_ to use a nightly compiler only for
that. So how can we help `cbindgen` to _see_ those symbols?

First solution: We write the C code directly in a file, which is then
included in the generated header file with the `cbindgen`
API. Problem, it's super easy to get it outdated, and it makes the
build process more complex.

Second solution: We write those symbols in a custom module, that is
just here for `cbindgen`, never used by our Rust code (otherwise it's
duplicated code), with no particular implementation.

And that's why we have the following `cbindgen_hack` module.

But this module must not be compiled by `rustc`. How to force `rustc`
to ignore a module? With conditional compilation. Because `cbindgen`
does not support conditional compilation, it will always _ignore_ the
`#[cfg]` attribute, and will always read the content of the module.

Sorry.
2021-02-02 12:05:47 +01:00
Ivan Enderlin
4725a5d623 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-02-02 11:07:21 +01:00
bors[bot]
c4c7b2bb9b Merge #2083
2083: doc(c-api) Remove inline documentation in `wasmer_wasm.h`, clarification about stability… r=Hywan a=Hywan

# Description

As suggested in https://github.com/wasmerio/wasmer/pull/2053#discussion_r566692725, this PR removes the automatically generated documentation when building `wasmer_wasm.h`.

It also clarifies our position regarding stability, and add a section about the documentation.

This PR takes also the opportunity to mark `wasi_env_set_(instance|memory)` as deprecated functions.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2021-02-02 09:24:37 +00:00
Ivan Enderlin
0826d3d722 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-02-02 09:51:01 +01:00
Ivan Enderlin
7eb08399f2 fix(c-api) Include feedbacks from @MarkMcCaskey! 2021-02-02 09:49:39 +01:00
Ivan Enderlin
b2bc62d43a chore(c-api) Update headers. 2021-02-02 09:23:37 +01:00
Ivan Enderlin
98bff43f35 chore(c-api) Remove useless unsafe keywords. 2021-02-01 15:49:53 +01:00
Ivan Enderlin
b954429ca6 fix(c-api) Avoid more than one call to the function environment finalizer.
A function environment `WrapperEnv` can be cloned. In case the
original and the cloned environments are being dropped, the
`self.finalizer` function —if any— is called twice. That's a bug. It
must be called only once.

This patch updates the code to apply the finalizer only once by taking
it —if any— the first time it's called.
2021-02-01 15:42:28 +01:00
Ivan Enderlin
7c63648eb7 Update lib/c-api/src/wasm_c_api/wasi/mod.rs
Co-authored-by: Julien BIANCHI <contact@jubianchi.Fr>
2021-02-01 15:06:26 +01:00
Ivan Enderlin
9a835a4fdc doc(c-api) Remove incorrect link. 2021-02-01 15:00:13 +01:00
Ivan Enderlin
d48bc1e67e chore(c-api) Update headers. 2021-02-01 14:58:54 +01:00
Ivan Enderlin
8ab82cf589 doc(c-api) Fix documentation. 2021-02-01 14:58:42 +01:00
Ivan Enderlin
9e63ba9a25 fix(c-api) Fix memory leak and owernship in WASI.
In `wasi_get_imports` and `wasi_get_unordered_imports`, we said the
ownership of `wasi_env_t` was taken by the function, but it wasn't the
case. This patch changes the type from `&wasi_env_t` to
`Box<wasi_env_t>` to take ownership of it.

The rest of the patch updates the documentation, and improves null
protections with `Option<T>`.
2021-02-01 14:55:45 +01:00
Ivan Enderlin
b1dc0416dd chore(c-api) Make type explicit for the sake of simplicity. 2021-02-01 13:42:06 +01:00
Ivan Enderlin
bbbbe53602 test(c-api) Move a doctest into a test. 2021-02-01 13:38:51 +01:00
Ivan Enderlin
0861b73974 Fix rebase. 2021-02-01 12:04:10 +01:00
Ivan Enderlin
37aee2d7ad chore(c-api) Simplify code. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
e379fd79fb chore(c-api) Merge _CBINDGEN_IS_RUNNING with DOCS_RS. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
83c69a5623 feat(c-api) Implement From<String> for wasm_name_t. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
5fc3e9fbca chore(c-api) Update headers. 2021-02-01 12:03:36 +01:00
Ivan Enderlin
1042dad5eb chore(c-api) Update headers. 2021-02-01 12:03:08 +01:00
Ivan Enderlin
18761cad7d feat(c-api) Implement wasm_extern_copy.
This patch also moves `wasm_extern_delete` into the correct Rust module.
2021-02-01 12:02:39 +01:00
Ivan Enderlin
79b5d5c032 chore(c-api) Exclude more functions from Wasm C API for the Wasmer C API. 2021-02-01 12:02:12 +01:00
Ivan Enderlin
5abac74618 feat(c-api) Rename wasm_named_extern_extern to wasm_named_extern_unwrap. 2021-02-01 12:02:12 +01:00
Ivan Enderlin
5de7d71e84 chore(c-api) Update headers. 2021-02-01 12:02:10 +01:00
Ivan Enderlin
8b29156d2d fixup 2021-02-01 12:01:30 +01:00
Ivan Enderlin
ffd07bcfd7 feat(c-api) Expand macros of the crate when generating C bindings. 2021-02-01 12:01:27 +01:00
Ivan Enderlin
0ad4d319d6 chore(c-api) Update headers. 2021-02-01 12:01:00 +01:00
Ivan Enderlin
00bf74c488 chore(c-api) Reorder field for the sake of consistency. 2021-02-01 11:59:23 +01:00
Ivan Enderlin
dc0cf7d4a4 feat(c-api) Implement wasi_get_unordered_imports. 2021-02-01 11:59:23 +01:00
Ivan Enderlin
a6ce35b824 chore(c-api) Update headers. 2021-02-01 11:55:46 +01:00
Ivan Enderlin
277d85c5ae fix(c-api) Mark wasi_env_set_(instance|memory) as deprecated. 2021-02-01 11:55:38 +01:00
Ivan Enderlin
cbc8b4a773 chore(c-api) Update headers. 2021-02-01 11:50:11 +01:00
Ivan Enderlin
c1092864e1 doc(c-api) Improve wasmer_wasm.h intro to explain stability and documentation. 2021-02-01 11:49:03 +01:00
Ivan Enderlin
3ecd71940f doc(c-api) Remove auto-doc from wasmer_wasm.h. 2021-02-01 11:48:55 +01:00
Ivan Enderlin
7e757ded6b test(c-api) Simplify test by using wasm_name_new_from_string. 2021-01-29 15:04:40 +01:00
Ivan Enderlin
9fb174e961 doc(c-api) Add more documentation. 2021-01-29 14:41:41 +01:00
Ivan Enderlin
3c5692ca2f doc(c-api) Mark some types as unstable. 2021-01-29 14:39:59 +01:00
Ivan Enderlin
dc9f8fc82c chore(c-api) Update headers. 2021-01-29 14:34:59 +01:00
Ivan Enderlin
e4057469bc chore(c-api) get_default_compiler_config can stay private. 2021-01-29 14:29:50 +01:00
Ivan Enderlin
9fda912f31 feat(c-api) wasm_config_t and wasm_engine_new_with_config handle the target. 2021-01-29 14:27:07 +01:00
Ivan Enderlin
14b8fb0a9a feat(c-api) Implement wasm_config_set_target. 2021-01-29 14:26:52 +01:00
Ivan Enderlin
bc5bbfdeef feat(c-api) Implement Debug for wasm_target_t. 2021-01-29 14:26:38 +01:00
Ivan Enderlin
1eec258550 chore(c-api) Remove warning. 2021-01-29 14:25:47 +01:00
Ivan Enderlin
169fe16f31 doc+test(c-api) Add more tests and more documentation. 2021-01-29 12:34:14 +01:00
Ivan Enderlin
8f42485a49 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-01-29 11:55:14 +01:00
bors[bot]
a0cadcf361 Merge #2071
2071: feat(c-api) Rename the `wasmer` module to `unstable` r=Hywan a=Hywan

# Description

This patch is the first step to prepare more unstable API (like cross-compilation etc.). Nothing changes for the moment from the user perspective, it's not a breaking change. It's just a reorganisation of the code, and better documentation. Basically the `wasmer_c_api::wasm_c_api::wasmer` module has been renamed `unstable`, so that it's super clear :-).

# Review

- [ ] ~Add a short description of the the change to the CHANGELOG.md file~ not necessary


Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2021-01-28 17:54:24 +00:00
Ivan Enderlin
b201f12494 feat(c-api) Start implementing wasm_target_t, wasm_triple_t and wasm_cpu_features_t. 2021-01-28 17:26:15 +01:00
Ivan Enderlin
2f82d5536f feat(c-api) Rename the wasmer module to unstable. 2021-01-28 15:35:51 +01:00
Ivan Enderlin
2df343dc70 test(c-api) Test WASI captured stdout API. 2021-01-28 11:25:42 +01:00