Commit Graph

68 Commits

Author SHA1 Message Date
bors[bot]
ea4ea47e17 Merge #2003
2003: chore: Build Wasmer on musl r=jubianchi a=jubianchi


This patch adds a specific build for musl. Currently, it will only support JIT engine.

I also changes the workflow definition a bit so we don't depend on the OS name but rather on the environment ID which is our convention.

Closes #1482
Closes #1766

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description
<!-- 
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->

# Review

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


Co-authored-by: jubianchi <julien@wasmer.io>
2021-03-05 20:24:45 +00:00
Ivan Enderlin
21ea09f8ff chore(c-api) Fix merge conflicts. 2021-03-05 01:03:54 +01:00
Ivan Enderlin
1700c2d056 feat(c-api) Return ~1 if metering are exhausted. Add wasmer_metering_points_are_exhausted. 2021-03-05 00:49:13 +01:00
Ivan Enderlin
4f2ba728dd feat(c-api) Simplify the metering API.
This patch removes the following type and functions:

* `wasmer_metering_points_t`,
* `wasmer_metering_points_delete`,
* `wasmer_metering_points_is_exhausted`,
* `wasmer_metering_points_t`,
* `wasmer_metering_points_unwrap_or`.

Now, `wasmer_metering_get_remaining_points` returns the number of
points, with zero to represent `MeteringPoints::Exhausted`.

The API is greatly simplified as there is no longer need to allocate
and deallocate a `wasmer_metering_points_t` type.
2021-03-04 22:53:02 +01:00
Ivan Enderlin
072066acaf Merge branch 'master' into feature/metering-c-api 2021-03-04 22:31:12 +01:00
jubianchi
52901850a9 chore: Build Wasmer on musl
Closes #1482
Closes #1766
2021-03-03 17:07:47 +01:00
Ivan Enderlin
0c4e0633f4 chore(c-api) Update headers. 2021-03-02 16:32:54 +01:00
Ivan Enderlin
e67fd6acf6 feat(c-api) Update headers + add the MIDDLEWARES_FEATURE_AS_C_DEFINE constant. 2021-03-01 17:21:43 +01:00
Ivan Enderlin
0f43391b78 Merge branch 'master' into feature/metering-c-api 2021-03-01 16:43:16 +01:00
Ivan Enderlin
807bd2d1ee feat(c-api) Update headers. 2021-03-01 16:06:20 +01:00
Ivan Enderlin
527d5d97d9 chore(c-api) Fix merge conflicts. 2021-02-18 15:16:00 +01:00
Ivan Enderlin
bd25fafeb5 Merge branch 'master' into chore-c-api-formalization 2021-02-18 15:15:11 +01:00
Ivan Enderlin
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
Ivan Enderlin
93a427505e doc(c-api) Add documentation. 2021-02-12 10:35:54 +01:00
Ivan Enderlin
bdcc95925c test(c-api) Add tests for the wasmer_is_*_available API. 2021-02-12 10:29:58 +01:00
Ivan Enderlin
17dbb32e5a feat(c-api) Do not rename wat2wasm for the moment. 2021-02-12 00:26:53 +01:00
Ivan Enderlin
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
Nick Lewycky
197d0f7a49 Initial commit of C API for metering and middleware. 2021-02-09 01:20:34 -08:00
Ivan Enderlin
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
Ivan Enderlin
e5d5303b50 Merge branch 'master' into feat-c-api-wasi-unordered-imports 2021-02-02 12:17:01 +01:00
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
Ivan Enderlin
e379fd79fb chore(c-api) Merge _CBINDGEN_IS_RUNNING with DOCS_RS. 2021-02-01 12:03:38 +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
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
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
dc9f8fc82c chore(c-api) Update headers. 2021-01-29 14:34:59 +01:00
Nick Lewycky
95887af4da Include 'extern "C"' in our C header files when included in a C++ build. 2021-01-27 11:41:31 -08:00
Ivan Enderlin
79e55927b4 chore(c-api) Update headers. 2021-01-26 14:28:12 +01:00
Ivan Enderlin
70858eb201 feat(c-api) Do not build C headers if the env var DOCS_RS exists. 2021-01-22 14:22:28 +01:00
Mark McCaskey
ef8bf91e6a Handle cross-compilation in c-api build.rs 2020-12-16 12:35:16 -08:00
Mark McCaskey
eb19ffdfbe Clarify new logic with a comment 2020-12-16 11:52:37 -08:00
Mark McCaskey
dd226b1dab Add fixes from publishing 2020-12-16 10:53:09 -08:00
Ivan Enderlin
2ce2c9c7d5 feat(c-api) Add the WASMER_VERSION_{MAJOR|MINOR|PATCH|PRE} constants in C. 2020-12-11 11:03:01 +01:00
Ivan Enderlin
fdeb4a6845 feat(c-api) Add the WASMER_VERSION constant in C. 2020-12-11 10:51:40 +01:00
jubianchi
96a0d73ef8 fix(c-api): Remove the use of to link to Wasmer C API. 2020-11-13 21:09:04 +01:00
Ivan Enderlin
458daebe8c fix(c-api) Add -rpath to the linker only on Linux. 2020-11-13 17:04:10 +01:00
Ivan Enderlin
7cfd2ad161 fix(c-api) Use latest version of inline-c-rs and fix rpath on Linux. 2020-11-13 15:23:21 +01:00
Ivan Enderlin
637862dcdc test(c-api) Enable debug mode for C tests. 2020-11-09 15:45:17 +01:00
Ivan Enderlin
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
Ivan Enderlin
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
Ivan Enderlin
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
Ivan Enderlin
6b75648d82 test(c-api) Configure and start using inline-c-rs. 2020-11-02 15:49:52 +01:00
Nick Lewycky
1b3254cf6a Move the generated-by comment up to the first comment. 2020-10-23 11:16:30 -07:00
Nick Lewycky
e28fd7e755 Add a comment indicating what generates this file. 2020-10-23 11:10:21 -07:00
Syrus
bb1b89f4f7 Removed all usages of wasm_instance_get_vmctx_ptr 2020-10-16 21:39:23 -07:00
bors[bot]
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
Mark McCaskey
fd63ddb101 Merge branch 'master' into feature/wasmer-create-exe 2020-10-12 15:54:54 -07:00