diff --git a/CHANGELOG.md b/CHANGELOG.md index d2100f48355..b05cfe471c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C - [#2946](https://github.com/wasmerio/wasmer/pull/2946) Remove dylib,staticlib engines in favor of a single Universal engine - [#2949](https://github.com/wasmerio/wasmer/pull/2949) Switch back to using custom LLVM builds on CI - #2892 Renamed `get_native_function` to `get_typed_function`, marked former as deprecated. -- [#2869](https://github.com/wasmerio/wasmer/pull/2869) Removed Artifact, Engine traits. Renamed UniversalArtifact to Artifact, and UniversalEngine to Engine. +- [#3029](https://github.com/wasmerio/wasmer/pull/3029) Removed Artifact, Engine traits. Renamed UniversalArtifact to Artifact, and UniversalEngine to Engine. ### Fixed - [#2963](https://github.com/wasmerio/wasmer/pull/2963) Remove accidental dependency on libwayland and libxcb in ClI diff --git a/Makefile b/Makefile index 7161f529a32..34a7b0e184b 100644 --- a/Makefile +++ b/Makefile @@ -355,11 +355,11 @@ check-wasmer: $(CARGO_BINARY) check $(CARGO_TARGET) --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer check-wasmer-wasm: - $(CARGO_BINARY) check --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift,universal --bin wasmer-compiler + $(CARGO_BINARY) check --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler check-capi: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) check $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml \ - --no-default-features --features wat,universal,wasi,middlewares $(capi_compiler_features) + --no-default-features --features wat,compilation,wasi,middlewares $(capi_compiler_features) build-wasmer: $(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer @@ -371,7 +371,7 @@ bench: $(CARGO_BINARY) bench $(CARGO_TARGET) $(compiler_features) build-wasmer-wasm: - $(CARGO_BINARY) build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift,universal --bin wasmer-compiler + $(CARGO_BINARY) build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler # For best results ensure the release profile looks like the following # in Cargo.toml: @@ -421,46 +421,46 @@ build-docs-capi: capi-setup # when generating the documentation, we rename it to its # crate's name. Then we restore the lib's name. sed "$(SEDI)" -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,cranelift,wasi + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compilation,cranelift,wasi sed "$(SEDI)" -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml build-capi: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,wasi,middlewares $(capi_compiler_features) + --no-default-features --features wat,compilation,wasi,middlewares $(capi_compiler_features) build-capi-singlepass: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,singlepass,wasi,middlewares + --no-default-features --features wat,compilation,singlepass,wasi,middlewares build-capi-singlepass-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,singlepass,wasi,middlewares + --no-default-features --features wat,compilation,singlepass,wasi,middlewares build-capi-cranelift: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,cranelift,wasi,middlewares + --no-default-features --features wat,compilation,cranelift,wasi,middlewares build-capi-cranelift-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,cranelift,wasi,middlewares + --no-default-features --features wat,compilation,cranelift,wasi,middlewares build-capi-llvm: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,llvm,wasi,middlewares + --no-default-features --features wat,compilation,llvm,wasi,middlewares build-capi-llvm-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,llvm,wasi,middlewares + --no-default-features --features wat,compilation,llvm,wasi,middlewares # Headless (we include the minimal to be able to run) build-capi-headless-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features universal,wasi + --no-default-features --features compilation,wasi build-capi-headless-all: capi-setup RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features universal,wasi + --no-default-features --features compilation,wasi build-capi-headless-ios: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo lipo --manifest-path lib/c-api/Cargo.toml --release \ @@ -520,7 +520,7 @@ test-capi: build-capi package-capi $(foreach compiler_engine,$(capi_compilers_en test-capi-crate-%: WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) $(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,universal,wasi,middlewares $(capi_compiler_features) -- --nocapture + --no-default-features --features wat,compilation,wasi,middlewares $(capi_compiler_features) -- --nocapture test-capi-integration-%: # Test the Wasmer C API tests for C @@ -713,4 +713,4 @@ install-local: package test-minimal-versions: rm -f Cargo.lock - cargo +nightly build --tests -Z minimal-versions --all-features \ No newline at end of file + cargo +nightly build --tests -Z minimal-versions --all-features diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 4b9b5a6c24b..5845d2563e9 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -89,7 +89,7 @@ core = ["hashbrown"] # Features for `sys`. sys = [] -sys-default = ["sys", "wat", "default-universal"] +sys-default = ["sys", "wat", "default-cranelift", "default-engine_compilation"] # - Compilers. compiler = [ "sys", @@ -104,16 +104,16 @@ default-cranelift = ["default-compiler", "cranelift"] default-llvm = ["default-compiler", "llvm"] # - Engines. engine = ["sys"] -universal = [ +engine_compilation = [ "engine", "wasmer-compiler/engine_compilation" ] default-engine = [] -default-universal = [ +default-engine_compilation = [ "default-engine", - "universal", + "engine_compilation", ] # - Deprecated features. -jit = ["universal"] +jit = ["engine_compilation"] # Features for `js`. js = ["wasm-bindgen", "js-sys"] @@ -124,4 +124,4 @@ wasm-types-polyfill = ["js", "wasmparser"] js-serializable-module = [] [package.metadata.docs.rs] -features = ["compiler", "core", "cranelift", "default-compiler", "default-engine", "engine", "jit", "native", "singlepass", "sys", "sys-default", "universal"] +features = ["compiler", "core", "cranelift", "default-compiler", "default-engine", "engine", "jit", "native", "singlepass", "sys", "sys-default", "engine_compilation"] diff --git a/lib/api/README.md b/lib/api/README.md index 51b209344ad..46a016fb8ab 100644 --- a/lib/api/README.md +++ b/lib/api/README.md @@ -45,12 +45,7 @@ fn main() -> anyhow::Result<()> { Wasmer is not only fast, but also designed to be *highly customizable*: -* **Pluggable engines** — An engine is responsible to drive the - compilation process and to store the generated executable code - somewhere, either: - * in-memory (with [`wasmer-engine-universal`]), - -* **Pluggable compilers** — A compiler is used by an engine to +* **Pluggable compilers** — A compiler is used by the engine to transform WebAssembly into executable code: * [`wasmer-compiler-singlepass`] provides a fast compilation-time but an unoptimized runtime speed, @@ -94,7 +89,6 @@ more](https://wasmerio.github.io/wasmer/crates/doc/wasmer/). Made with ❤️ by the Wasmer team, for the community -[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal [`wasmer-compiler-singlepass`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-singlepass [`wasmer-compiler-cranelift`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-cranelift [`wasmer-compiler-llvm`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-llvm diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index 6a4686033ff..300362667dc 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -73,12 +73,7 @@ //! //! Wasmer is not only fast, but also designed to be *highly customizable*: //! -//! * **Pluggable engines** — An engine is responsible to drive the -//! compilation process and to store the generated executable code -//! somewhere, either: -//! * in-memory (with [`wasmer-engine-universal`]), -//! -//! * **Pluggable compilers** — A compiler is used by an engine to +//! * **Pluggable compilers** — A compiler is used by the engine to //! transform WebAssembly into executable code: //! * [`wasmer-compiler-singlepass`] provides a fast compilation-time //! but an unoptimized runtime speed, @@ -243,15 +238,15 @@ //! - [`wasmer-wasi`] for running Wasm modules compiled to the WASI ABI. //! //! The Wasmer project has two major abstractions: -//! 1. [Engines][wasmer-engine], +//! 1. [Engine][wasmer-compiler], //! 2. [Compilers][wasmer-compiler]. //! //! These two abstractions have multiple options that can be enabled //! with features. //! -//! ## Engines +//! ## Engine //! -//! An engine is a system that uses a compiler to make a WebAssembly +//! The engine is a system that uses a compiler to make a WebAssembly //! module executable. //! //! ## Compilers @@ -311,10 +306,10 @@ #![cfg_attr(feature = "wat", doc = "(enabled),")] #![cfg_attr(not(feature = "wat"), doc = "(disabled),")] //! enables `wasmer` to parse the WebAssembly text format, -//! - `universal` -#![cfg_attr(feature = "universal", doc = "(enabled),")] -#![cfg_attr(not(feature = "universal"), doc = "(disabled),")] -//! enables [the Universal engine][`wasmer-engine-universal`]. +//! - `compilation` +#![cfg_attr(feature = "compilation", doc = "(enabled),")] +#![cfg_attr(not(feature = "compilation"), doc = "(disabled),")] +//! enables compilation with the wasmer engine. //! //! The features that set defaults come in sets that are mutually exclusive. //! @@ -331,13 +326,6 @@ #![cfg_attr(feature = "default-singlepass", doc = "(enabled),")] #![cfg_attr(not(feature = "default-singlepass"), doc = "(disabled),")] //! set Wasmer's Singlepass compiler as the default. -//! -//! The next set is the default engine set: -//! - `default-universal` -#![cfg_attr(feature = "default-universal", doc = "(enabled),")] -#![cfg_attr(not(feature = "default-universal"), doc = "(disabled),")] -//! set the Universal engine as the default. -//! #![cfg_attr( feature = "js", doc = "## Features for the `js` feature group (enabled)" @@ -414,8 +402,6 @@ //! [`wasmer-cache`]: https://docs.rs/wasmer-cache/ //! [wasmer-compiler]: https://docs.rs/wasmer-compiler/ //! [`wasmer-emscripten`]: https://docs.rs/wasmer-emscripten/ -//! [wasmer-engine]: https://docs.rs/wasmer-engine/ -//! [`wasmer-engine-universal`]: https://docs.rs/wasmer-engine-universal/ //! [`wasmer-compiler-singlepass`]: https://docs.rs/wasmer-compiler-singlepass/ //! [`wasmer-compiler-llvm`]: https://docs.rs/wasmer-compiler-llvm/ //! [`wasmer-compiler-cranelift`]: https://docs.rs/wasmer-compiler-cranelift/ diff --git a/lib/api/src/sys/mod.rs b/lib/api/src/sys/mod.rs index bfe10cdf586..9c02858aab8 100644 --- a/lib/api/src/sys/mod.rs +++ b/lib/api/src/sys/mod.rs @@ -93,7 +93,7 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel}; #[cfg(feature = "llvm")] pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM}; -#[cfg(feature = "universal")] +#[cfg(feature = "engine_compilation")] pub use wasmer_compiler::{Artifact, Backend, Engine}; /// Version number of this crate. diff --git a/lib/api/src/sys/store.rs b/lib/api/src/sys/store.rs index ff21d5dabf8..b455927837b 100644 --- a/lib/api/src/sys/store.rs +++ b/lib/api/src/sys/store.rs @@ -14,7 +14,7 @@ use wasmer_vm::StoreObjects; /// wrap the actual context in a box. pub(crate) struct StoreInner { pub(crate) objects: StoreObjects, - pub(crate) engine: Arc, + pub(crate) engine: Engine, pub(crate) tunables: Box, pub(crate) trap_handler: Option>>, } @@ -31,7 +31,7 @@ pub(crate) struct StoreInner { /// Spec: pub struct Store { pub(crate) inner: Box, - engine: Arc, + engine: Engine, trap_handler: Arc>>>>, } @@ -80,7 +80,7 @@ impl Store { } /// Returns the [`Engine`]. - pub fn engine(&self) -> &Arc { + pub fn engine(&self) -> &Engine { &self.engine } @@ -144,7 +144,7 @@ impl Default for Store { #[allow(unreachable_code, unused_mut)] fn get_engine(mut config: impl CompilerConfig + 'static) -> Engine { cfg_if::cfg_if! { - if #[cfg(feature = "default-universal")] { + if #[cfg(feature = "engine_compilation")] { wasmer_compiler::Backend::new(config) .engine() } else { @@ -198,7 +198,7 @@ impl<'a> StoreRef<'a> { } /// Returns the [`Engine`]. - pub fn engine(&self) -> &Arc { + pub fn engine(&self) -> &Engine { &self.inner.engine } @@ -231,7 +231,7 @@ impl<'a> StoreMut<'a> { } /// Returns the [`Engine`]. - pub fn engine(&self) -> &Arc { + pub fn engine(&self) -> &Engine { &self.inner.engine } diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index d09fd9b93c6..aebcab09deb 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -48,7 +48,7 @@ inline-c = "0.1.5" default = [ "wat", "cranelift", - "universal", + "compilation", "wasi", "middlewares", ] @@ -58,7 +58,7 @@ middlewares = [ "compiler", "wasmer-middlewares", ] -universal = [ +compilation = [ "wasmer-compiler/engine_compilation", "compiler", ] @@ -79,7 +79,7 @@ llvm = [ ] # Deprecated features. -jit = ["universal"] +jit = ["compilation"] # TODO: Port this feature. #emscripten = ["wasmer-emscripten"] diff --git a/lib/c-api/build.rs b/lib/c-api/build.rs index 329c360bc98..0a8c744a6ef 100644 --- a/lib/c-api/build.rs +++ b/lib/c-api/build.rs @@ -140,7 +140,7 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) { pre_header = PRE_HEADER ); - map_feature_as_c_define!("universal", UNIVERSAL_FEATURE_AS_C_DEFINE, pre_header); + map_feature_as_c_define!("compilation", UNIVERSAL_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("compiler", COMPILER_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("wasi", WASI_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("middlewares", MIDDLEWARES_FEATURE_AS_C_DEFINE, pre_header); diff --git a/lib/c-api/src/wasm_c_api/engine.rs b/lib/c-api/src/wasm_c_api/engine.rs index 72d26ceb878..6d0e4b076e2 100644 --- a/lib/c-api/src/wasm_c_api/engine.rs +++ b/lib/c-api/src/wasm_c_api/engine.rs @@ -11,8 +11,7 @@ use super::unstable::middlewares::wasmer_middleware_t; use super::unstable::target_lexicon::wasmer_target_t; use crate::error::update_last_error; use cfg_if::cfg_if; -use std::sync::Arc; -#[cfg(feature = "universal")] +#[cfg(feature = "compilation")] use wasmer_compiler::{Backend, Engine}; /// Kind of compilers that can be used by the engines. @@ -69,7 +68,7 @@ pub enum wasmer_engine_t { impl Default for wasmer_engine_t { fn default() -> Self { cfg_if! { - if #[cfg(feature = "universal")] { + if #[cfg(feature = "compilation")] { Self::UNIVERSAL } else { compile_error!("Please enable one of the engines") @@ -262,13 +261,13 @@ pub extern "C" fn wasm_config_set_engine(config: &mut wasm_config_t, engine: was /// cbindgen:ignore #[repr(C)] pub struct wasm_engine_t { - pub(crate) inner: Arc, + pub(crate) inner: Engine, } #[cfg(feature = "compiler")] use wasmer_api::CompilerConfig; -#[cfg(all(feature = "compiler", any(feature = "universal", feature = "dylib")))] +#[cfg(all(feature = "compiler", any(feature = "compilation", feature = "dylib")))] fn get_default_compiler_config() -> Box { cfg_if! { if #[cfg(feature = "cranelift")] { @@ -284,7 +283,7 @@ fn get_default_compiler_config() -> Box { } cfg_if! { - if #[cfg(all(feature = "universal", feature = "compiler"))] { + if #[cfg(all(feature = "compilation", feature = "compiler"))] { /// Creates a new Universal engine with the default compiler. /// /// # Example @@ -295,10 +294,10 @@ cfg_if! { #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { let compiler_config: Box = get_default_compiler_config(); - let engine: Arc = Arc::new(Backend::new(compiler_config).engine()); + let engine: Engine = Backend::new(compiler_config).engine(); Box::new(wasm_engine_t { inner: engine }) } - } else if #[cfg(feature = "universal")] { + } else if #[cfg(feature = "compilation")] { /// Creates a new headless Universal engine. /// /// # Example @@ -308,7 +307,7 @@ cfg_if! { /// cbindgen:ignore #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { - let engine: Arc = Arc::new(Backend::headless().engine()); + let engine: Engine = Backend::headless().engine(); Box::new(wasm_engine_t { inner: engine }) } } else { @@ -321,7 +320,7 @@ cfg_if! { /// cbindgen:ignore #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { - unimplemented!("No engine attached; You might want to recompile `wasmer_c_api` with for example `--feature universal`"); + unimplemented!("No engine attached; You might want to recompile `wasmer_c_api` with for example `--feature compilation`"); } } } @@ -418,10 +417,10 @@ pub extern "C" fn wasm_engine_new_with_config( compiler_config.canonicalize_nans(true); } - #[cfg(not(feature = "universal"))] - return return_with_error("Wasmer has not been compiled with the `universal` feature."); - #[cfg(feature = "universal")] - let inner: Arc = + #[cfg(not(feature = "compilation"))] + return return_with_error("Wasmer has not been compiled with the `compilation` feature."); + #[cfg(feature = "compilation")] + let inner: Engine = { let mut builder = Backend::new(compiler_config); @@ -433,13 +432,13 @@ pub extern "C" fn wasm_engine_new_with_config( builder = builder.features(features.inner); } - Arc::new(builder.engine()) + builder.engine() }; Some(Box::new(wasm_engine_t { inner })) } else { - let inner: Arc = + let inner: Engine = cfg_if! { - if #[cfg(feature = "universal")] { + if #[cfg(feature = "compilation")] { let mut builder = Backend::headless(); if let Some(target) = config.target { @@ -450,9 +449,9 @@ pub extern "C" fn wasm_engine_new_with_config( builder = builder.features(features.inner); } - Arc::new(builder.engine()) + builder.engine() } else { - return return_with_error("Wasmer has not been compiled with the `universal` feature."); + return return_with_error("Wasmer has not been compiled with the `compilation` feature."); } }; Some(Box::new(wasm_engine_t { inner })) diff --git a/lib/c-api/src/wasm_c_api/mod.rs b/lib/c-api/src/wasm_c_api/mod.rs index 5ec333e320a..d04bfe66e25 100644 --- a/lib/c-api/src/wasm_c_api/mod.rs +++ b/lib/c-api/src/wasm_c_api/mod.rs @@ -62,6 +62,7 @@ mod macros; /// ``` /// /// To configure the engine, see the [`wasm_config_new`][engine::wasm_config_new]. +#[cfg(feature = "compilation")] pub mod engine; /// cbindgen:ignore diff --git a/lib/c-api/src/wasm_c_api/store.rs b/lib/c-api/src/wasm_c_api/store.rs index d6bd5415ef5..7a3b9b67c09 100644 --- a/lib/c-api/src/wasm_c_api/store.rs +++ b/lib/c-api/src/wasm_c_api/store.rs @@ -34,7 +34,7 @@ pub unsafe extern "C" fn wasm_store_new( engine: Option<&wasm_engine_t>, ) -> Option> { let engine = engine?; - let store = Store::new_with_engine(&*engine.inner); + let store = Store::new_with_engine(&engine.inner); Some(Box::new(wasm_store_t { inner: StoreRef { diff --git a/lib/c-api/src/wasm_c_api/unstable/engine.rs b/lib/c-api/src/wasm_c_api/unstable/engine.rs index e1ea2324c8c..ec61e56a355 100644 --- a/lib/c-api/src/wasm_c_api/unstable/engine.rs +++ b/lib/c-api/src/wasm_c_api/unstable/engine.rs @@ -161,7 +161,7 @@ pub extern "C" fn wasmer_is_headless() -> bool { /// compiled library. #[no_mangle] pub extern "C" fn wasmer_is_engine_available(engine: wasmer_engine_t) -> bool { - matches!(engine, wasmer_engine_t::UNIVERSAL if cfg!(feature = "universal")) + matches!(engine, wasmer_engine_t::UNIVERSAL if cfg!(feature = "compilation")) } #[cfg(test)] @@ -234,7 +234,7 @@ mod tests { fn test_wasmer_is_engine_available() { set_var( "UNIVERSAL", - if cfg!(feature = "universal") { + if cfg!(feature = "compilation") { "1" } else { "0" diff --git a/lib/cli-compiler/Cargo.toml b/lib/cli-compiler/Cargo.toml index 680b50e372c..85252f94d96 100644 --- a/lib/cli-compiler/Cargo.toml +++ b/lib/cli-compiler/Cargo.toml @@ -48,11 +48,8 @@ unix_mode = "0.1.3" [features] # Don't add the compiler features in default, please add them on the Makefile # since we might want to autoconfigure them depending on the availability on the host. -default = [ - "universal", -] +default = [] engine = [] -universal = [] compiler = [ "wasmer-compiler/translator", ] @@ -66,4 +63,4 @@ cranelift = [ ] debug = ["fern", "log"] disable-all-logging = [] -jit = ["universal"] +jit = [] diff --git a/lib/cli-compiler/README.md b/lib/cli-compiler/README.md index 512321d19bf..a1aacb1614c 100644 --- a/lib/cli-compiler/README.md +++ b/lib/cli-compiler/README.md @@ -6,13 +6,11 @@ This crate is the Wasmer Compiler only CLI. ## Features The Compiler only Wasmer supports the following features: -* `universal` (default): support for the [Universal engine]. * `wasi` (default): support for [WASI]. * `experimental-io-devices`: support for experimental IO devices in WASI. * `emscripten` (default): support for [Emscripten]. * `singlepass`: support for the [Singlepass compiler]. -[Universal engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal/ [WASI]: https://github.com/wasmerio/wasmer/tree/master/lib/wasi/ [Emscripten]: https://github.com/wasmerio/wasmer/tree/master/lib/emscripten/ [Singlepass compiler]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-singlepass/ @@ -30,5 +28,5 @@ wasmer-compiler -V Compile a WebAssembly file: ```bash -wasmer-compiler compile myfile.wasm -o myfile.wasmu --singlepass --universal +wasmer-compiler compile myfile.wasm -o myfile.wasmu --singlepass ``` diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index ecf45c929b7..8294e4056c3 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -64,6 +64,7 @@ default = [ "cache", "wasi", "emscripten", + "compilation", ] cache = ["wasmer-cache"] cache-blake3-pure = ["wasmer-cache/blake3-pure"] @@ -74,6 +75,9 @@ wat = ["wasmer/wat"] compiler = [ "wasmer-compiler/translator", ] +compilation = [ + "wasmer-compiler/engine_compilation", +] experimental-io-devices = [ "wasmer-wasi-experimental-io-devices", "wasi" diff --git a/lib/cli/src/store.rs b/lib/cli/src/store.rs index 6bfa5227a7c..26f0e69ac37 100644 --- a/lib/cli/src/store.rs +++ b/lib/cli/src/store.rs @@ -14,6 +14,8 @@ use structopt::StructOpt; use wasmer::*; #[cfg(feature = "compiler")] use wasmer_compiler::CompilerConfig; +#[cfg(feature = "compilation")] +use wasmer_compiler::Engine; #[derive(Debug, Clone, StructOpt, Default)] /// The compiler options @@ -104,10 +106,11 @@ impl CompilerOptions { pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> { let (compiler_config, compiler_type) = self.get_compiler_config()?; let engine = self.get_engine(target, compiler_config)?; - let store = Store::new_with_engine(&*engine); + let store = Store::new_with_engine(&engine); Ok((store, compiler_type)) } + #[cfg(feature = "compilation")] fn get_engine( &self, target: Target, @@ -313,10 +316,11 @@ impl StoreOptions { pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> { let (compiler_config, compiler_type) = self.compiler.get_compiler_config()?; let engine = self.get_engine_with_compiler(target, compiler_config)?; - let store = Store::new_with_engine(&*engine); + let store = Store::new_with_engine(&engine); Ok((store, compiler_type)) } + #[cfg(feature = "compilation")] fn get_engine_with_compiler( &self, target: Target, @@ -331,15 +335,16 @@ impl StoreOptions { // If we don't have a compiler, but we have an engine #[cfg(not(feature = "compiler"))] impl StoreOptions { - fn get_engine_headless(&self) -> Result> { - let engine: Arc = Arc::new(wasmer_compiler::Backend::headless().engine()); + #[cfg(feature = "compilation")] + fn get_engine_headless(&self) -> Result { + let engine: Engine = wasmer_compiler::Backend::headless().engine(); Ok(engine) } /// Get the store (headless engine) pub fn get_store(&self) -> Result<(Store, CompilerType)> { let engine = self.get_engine_headless()?; - let store = Store::new_with_engine(&*engine); + let store = Store::new_with_engine(&engine); Ok((store, CompilerType::Headless)) } } diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index 928affe5ff8..1409ecde6f5 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -1,7 +1,7 @@ //! Define `Artifact`, based on `ArtifactBuild` //! to allow compiling and instantiating to be done as separate steps. -use crate::engine::engine::{Engine, EngineInner}; +use crate::engine::inner::{Engine, EngineInner}; use crate::engine::link::link_module; use crate::ArtifactBuild; use crate::ArtifactCreate; diff --git a/lib/compiler/src/engine/engine.rs b/lib/compiler/src/engine/inner.rs similarity index 99% rename from lib/compiler/src/engine/engine.rs rename to lib/compiler/src/engine/inner.rs index 1e82e5e82e7..ee263594d40 100644 --- a/lib/compiler/src/engine/engine.rs +++ b/lib/compiler/src/engine/inner.rs @@ -155,8 +155,8 @@ impl Engine { } /// Clone the engine - pub fn cloned(&self) -> Arc { - Arc::new(self.clone()) + pub fn cloned(&self) -> Self { + self.clone() } } diff --git a/lib/compiler/src/engine/mod.rs b/lib/compiler/src/engine/mod.rs index 20b6a9c5353..d78d521d6cb 100644 --- a/lib/compiler/src/engine/mod.rs +++ b/lib/compiler/src/engine/mod.rs @@ -12,7 +12,7 @@ mod backend; #[cfg(feature = "translator")] mod code_memory; #[cfg(feature = "translator")] -mod engine; +mod inner; #[cfg(feature = "translator")] mod link; #[cfg(feature = "translator")] @@ -30,6 +30,6 @@ pub use self::backend::Backend; #[cfg(feature = "translator")] pub use self::code_memory::CodeMemory; #[cfg(feature = "translator")] -pub use self::engine::Engine; +pub use self::inner::Engine; #[cfg(feature = "translator")] pub use self::link::link_module; diff --git a/lib/object/README.md b/lib/object/README.md index 99e9c86204d..aee56b3b269 100644 --- a/lib/object/README.md +++ b/lib/object/README.md @@ -3,8 +3,7 @@ The Wasmer Native Object crate aims at cross-generating native objects for various platforms. -This crate is the foundation of [the `wasmer-engine-dylib` -crate](../engine-dylib/). Given a compilation result, i.e. the result +Given a compilation result, i.e. the result of `wasmer_compiler::Compiler::compile_module`, this crate exposes functions to create an `Object` file for a given target. It is a useful thin layer on top of [the `object` diff --git a/lib/vm/README.md b/lib/vm/README.md index f534f97cd93..e15c595799b 100644 --- a/lib/vm/README.md +++ b/lib/vm/README.md @@ -1,14 +1,13 @@ # `wasmer-vm` [![Build Status](https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square)](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [![Join Wasmer Slack](https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square)](https://slack.wasmer.io) [![MIT License](https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square)](https://github.com/wasmerio/wasmer/blob/master/LICENSE) -This crate contains the Wasmer VM runtime library, supporting the Wasm ABI used by any [`wasmer-engine`] implementation. +This crate contains the Wasmer VM runtime library, supporting the Wasm ABI used by wasmer. The Wasmer runtime is modular by design, and provides several libraries where each of them provides a specific set of features. This `wasmer-vm` library contains the low-level foundation for the runtime itself. -It provides all the APIs the -[`wasmer-engine`](https://crates.io/crates/wasmer-engine) needs to operate, +It provides all the APIs wasmer needs to operate, from the `instance`, to `memory`, `probestack`, signature registry, `trap`, `table`, `VMContext`, `libcalls` etc. @@ -17,7 +16,7 @@ directly. The `wasmer` crate provides types that embed types from `wasmer-vm` with a higher-level API. -[`wasmer-engine`]: https://crates.io/crates/wasmer-engine +[`wasmer`]: https://crates.io/crates/wasmer ### Acknowledgments diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index e2a12fffe23..1a454143c80 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -49,7 +49,7 @@ tracing-wasm = "0.2" default = ["sys-default"] sys = ["wasmer/sys"] -sys-default = ["wasmer/wat", "wasmer/default-universal", "sys", "logging", "host-fs", "sys-poll", "host-vnet" ] +sys-default = ["wasmer/wat", "wasmer/default-engine_compilation", "sys", "logging", "host-fs", "sys-poll", "host-vnet" ] sys-poll = [] js = ["wasmer/js", "mem-fs", "wasmer-vfs/no-time", "getrandom/js", "chrono"]