This patch does several things.
1. For the crate `wasmer-c-api`, the library name is modified from
`wasmer_c_api` to `wasmer` in `Cargo.toml`. That way, the new
library files are named `libwasmer.*` rather than
`libwasmer_c_api.*`. That's the primaly goal of this patch. The
rest is a consequence of this point. Why do we want that? Because
the `build.rs` script of the `wasmer-c-api` crate will configure
the `soname` (on Linux), the `install_name` + `current_version` +
`compatibility_version` (on macOS), and the `out-implib` +
`output-def` (on Windows) for a library named `libwasmer`, which is
the name we provide in the Wasmer package for the Wasmer
libraries. If we want everything to be testable, we cannot use
`libwasmer` in `soname` for a file named `libwasmer_c_api` for
example. If we rename the file when packaging (as it's done prior
this patch), we would need to re-update all those information in
the `Makefile`. It implies to duplicate the code in 2 places. So
let's do things right directly and only once: We want the library
to be named `libwasmer`, let's do that.
2. For the crate `wasmer-c-api`, since the library name has been
renamed to `wasmer`, it creates a conflict with the `wasmer` crate
which is a dependency. Consequently, this patch also updates the
`Cargo.toml` file to modifiy the dependency name with the special
`package` attribute (see
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml
to learn more). So now, the `wasmer` refers to the `wasmer_c_api`
crate, and `wasmer-api` refers to the `wasmer` crate.
3. The code of the `wasmer-c-api` crate is updated accordingly. The
`WasmerEnv` derive procedural macro fails because it expects a
crate named `wasmer` (which is now `wasmer_api`), so we implement
the `WasmerEnv` trait by hand.
4. The patch updates the `build.rs` script of the `wasmer-c-api`
crate:
1. In the `build_cdylib_link_arg` function: The dependency to the
`cdylib-link-lines` crate has been removed because the output is
not exactly the one we expect. So we compute all the
`cargo:rustc-cdylib-link-arg=…` lines by hand. The version number
no longer appears in the library file name for example.
2. In the `build_inline_c_env_vars` function: Values passed to
`LDFLAGS` have been updated to be `libwasmer` rather than
`libwasmer_c_api`.
3. A new `shared_object_dir` helper function has been created
because it's used in `build_inline_c_env_vars` and in
`build_cdylib_link_arg`.
5. The `Makefile` has been updated:
1. In `package-capi`, we no longer rename `libwasmer_c_api` to
`libwasmer` since the name is correctly defined since the
beginning now.
Calling `install_name_tool` on macOS is no longer required since
`install_name` is correctly set by the linker in the `build.rs`
script of `wasmer-c-api`.
2. In `package-docs`, some stuffs have been fixed, like the
`SOURCE_VERSION` variable that didn't exist, so removed, or the
`mkdir` command that was incorrect etc.
3. In `build-docs`, the `wasmer-c-api` crate is excluded from the
list of crates to generate the documentation for. Mostly because
the `build-docs-capi` recipe exists, and we must use it to
generate the documentation of `wasmer-c-api` now.
4. In `build-docs-capi`, we generate the documentation for the
`wasmer-c-api` crate. But `rustdoc` uses the library name for the
directory name in the `target/doc/` directory. Since the library
name is now `wasmer`, it creates a conflict with the `wasmer`
crate. Consequently, we update the library name by using `sed` on
the `Cargo.toml` file before running `cargo doc`, to finally
restore `Cargo.toml` as it was previously.
Until this patch, our C API comes in 2 flavors: `deprecated` and
`wasm_c_api`. With the coming 2.x version of Wasmer, we would like to
remove the `deprecated` API, and keep the `wasm_c_api` only.
This patch removes the `deprecated` API from the `wasmer-c-api`
crate. It also cleans up the `Makefile` and the documentation
system. Previously, the documentation for the `deprecated` API was
relying on Doxygen, which was one new dependency the user had to
install. For the `wasm_c_api`, it relies on `rustdoc`, which is way
better because all examples are run and tested as part of our test
suite.
This clean up also removes the need to deal with `system-libffi` both
in the crate itself and in the `Makefile`, which was an edge case for
macOS on aarch64, and a needle in the foot for some of our users.
Finally, the `build.rs` is now simplified because we no longer need to
exclude symbols from one header to another. It also means that we only
provide the `wasmer_wasm.h` header file now; the `wasmer.h` and
`wasmer.hh` headers are removed.
compiler-llvm now uses the experimental.constrained intrinsics to ensure
correct behavior on FP operations when full-canonicalization is
disabled.
This patch requires TheDan64/inkwell#247
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#1482Closes#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>
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.
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.
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.