Commit Graph

60 Commits

Author SHA1 Message Date
e67fd6acf6 feat(c-api) Update headers + add the MIDDLEWARES_FEATURE_AS_C_DEFINE constant. 2021-03-01 17:21:43 +01:00
0f43391b78 Merge branch 'master' into feature/metering-c-api 2021-03-01 16:43:16 +01:00
527d5d97d9 chore(c-api) Fix merge conflicts. 2021-02-18 15:16:00 +01:00
bd25fafeb5 Merge branch 'master' into chore-c-api-formalization 2021-02-18 15:15:11 +01:00
830efaac17 fix(c-api) Use the name wasm_config_set_.
See the discussion here
https://github.com/wasmerio/wasmer/pull/2117#discussion_r575303872.
2021-02-18 15:04:21 +01:00
93a427505e doc(c-api) Add documentation. 2021-02-12 10:35:54 +01:00
bdcc95925c test(c-api) Add tests for the wasmer_is_*_available API. 2021-02-12 10:29:58 +01:00
17dbb32e5a feat(c-api) Do not rename wat2wasm for the moment. 2021-02-12 00:26:53 +01:00
fd6689c580 chore(c-api) Formalize API prefixes.
The new rule is the following:

* `wasm_` for the standard C API,
* `wasmer_` or `wasi_` for the Wasmer non-standard C API.

For all symbols inside the `unstable` module, the renaming `wasm_` to
`wasmer_` is done without deprecations. It was clear that those API
were unstable.

For all the other symbols, symbols have been renamed to `wasmer_` but
the old symbols have been kept with deprecation warnings.

Special note: The `wasm_named_extern_t` type (and associated
functions) was in `wasi` by mistake. Its place was in the `unstable`
module. This patch also fixes that.

The `wasm_declare_vec_*` macros have been updated to support a default
prefix, or a user-defined prefix. It's now possible to write
`wasm_declare_boxed_vec!(foo);` to get all the API prefixed by `wasm_`
(as previously), or `wasm_declare_boxed_vec!(foo, wasmer);` to prefix
with `wasmer_`.

A user not using symbols from the `unstable` module will continue to
get working code, modulo some deprecations, after this patch.
2021-02-11 23:56:36 +01:00
197d0f7a49 Initial commit of C API for metering and middleware. 2021-02-09 01:20:34 -08:00
30095e1600 fix(c-api) Do not run build.rs if the scripts/publish.py script is running. 2021-02-02 14:26:58 +01:00
e5d5303b50 Merge branch 'master' into feat-c-api-wasi-unordered-imports 2021-02-02 12:17:01 +01:00
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
4725a5d623 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-02-02 11:07:21 +01:00
e379fd79fb chore(c-api) Merge _CBINDGEN_IS_RUNNING with DOCS_RS. 2021-02-01 12:03:38 +01:00
79b5d5c032 chore(c-api) Exclude more functions from Wasm C API for the Wasmer C API. 2021-02-01 12:02:12 +01:00
8b29156d2d fixup 2021-02-01 12:01:30 +01:00
ffd07bcfd7 feat(c-api) Expand macros of the crate when generating C bindings. 2021-02-01 12:01:27 +01:00
c1092864e1 doc(c-api) Improve wasmer_wasm.h intro to explain stability and documentation. 2021-02-01 11:49:03 +01:00
3ecd71940f doc(c-api) Remove auto-doc from wasmer_wasm.h. 2021-02-01 11:48:55 +01:00
dc9f8fc82c chore(c-api) Update headers. 2021-01-29 14:34:59 +01:00
95887af4da Include 'extern "C"' in our C header files when included in a C++ build. 2021-01-27 11:41:31 -08:00
79e55927b4 chore(c-api) Update headers. 2021-01-26 14:28:12 +01:00
70858eb201 feat(c-api) Do not build C headers if the env var DOCS_RS exists. 2021-01-22 14:22:28 +01:00
ef8bf91e6a Handle cross-compilation in c-api build.rs 2020-12-16 12:35:16 -08:00
eb19ffdfbe Clarify new logic with a comment 2020-12-16 11:52:37 -08:00
dd226b1dab Add fixes from publishing 2020-12-16 10:53:09 -08:00
2ce2c9c7d5 feat(c-api) Add the WASMER_VERSION_{MAJOR|MINOR|PATCH|PRE} constants in C. 2020-12-11 11:03:01 +01:00
fdeb4a6845 feat(c-api) Add the WASMER_VERSION constant in C. 2020-12-11 10:51:40 +01:00
96a0d73ef8 fix(c-api): Remove the use of to link to Wasmer C API. 2020-11-13 21:09:04 +01:00
458daebe8c fix(c-api) Add -rpath to the linker only on Linux. 2020-11-13 17:04:10 +01:00
7cfd2ad161 fix(c-api) Use latest version of inline-c-rs and fix rpath on Linux. 2020-11-13 15:23:21 +01:00
637862dcdc test(c-api) Enable debug mode for C tests. 2020-11-09 15:45:17 +01:00
f02b8510d8 chore(c-api) Assert that shared object directory is well constructed.
Before `pop`ing the filename, let's check whether it's what we expect!
2020-11-06 08:59:37 +01:00
1d208af530 test(c-api) Create a tests/wasmer_wasm.h file.
Remove the `build.rs` hack to add helper functions that are used only
in our tests. Now the tests can use the `tests/wasmer_wasm.h` file,
which simplifies the test workflow: No need to hack the build script
or anything if we want to add a helper function.
2020-11-03 10:41:00 +01:00
ffba18d7b5 feat(c-api) Add a wasm_byte_vec_new_from_string helper.
It's very similar to `wasm_name_new_from_string` but for
`wasm_byte_vec_t`. It does not make sense to get that in the standard,
but it's very useful when writing tests.
2020-11-02 16:23:56 +01:00
6b75648d82 test(c-api) Configure and start using inline-c-rs. 2020-11-02 15:49:52 +01:00
1b3254cf6a Move the generated-by comment up to the first comment. 2020-10-23 11:16:30 -07:00
e28fd7e755 Add a comment indicating what generates this file. 2020-10-23 11:10:21 -07:00
bb1b89f4f7 Removed all usages of wasm_instance_get_vmctx_ptr 2020-10-16 21:39:23 -07:00
c5d5ac7bfe Merge #1693
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey

This adds the `wasmer create-exe` subcommand.  This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer.  Put more plainly: it lets us transform Wasm modules into native executables in one step.

In order for this to work we need:
- [x] Ship wasm.h with Wasmer or use different mechanism to find it
- [x] Ship wasmer_wasm.h with Wasmer
- [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though
- [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested)
- [x] Add tests

# Review

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


Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
2020-10-13 21:46:16 +00:00
fd63ddb101 Merge branch 'master' into feature/wasmer-create-exe 2020-10-12 15:54:54 -07:00
b9f98ce1f6 feat(c-api) Update .h files. 2020-10-12 17:54:21 +02:00
ba7b24f696 Add --dir and --mapdir support to native executable 2020-10-09 17:38:14 -07:00
02c0df5101 Update to cbindgen 0.15.0
Manually specify that items should be sorted by name in the header
file. We do this because cbindgen 0.15.0 removed sorting by default.
2020-10-08 14:42:00 -07:00
ea8bb1ee79 Merge branch 'master' into feature/engine-object-file 2020-10-06 17:50:55 -07:00
ded3132b44 feat(c-api) Implement wat2wasm. 2020-10-06 11:09:35 +02:00
0f8d68652f Finish merge with C API refactor 2020-10-05 12:30:58 -07:00
2fdd9ea692 feat(c-api) Simplify the build.rs script. 2020-10-02 10:10:24 +02:00
a2854ebfea fix(c-api) Adjust cbindgen metadata for header files. 2020-10-01 21:20:13 +02:00