Skip to content

Commit

Permalink
Merge #2851
Browse files Browse the repository at this point in the history
2851: Feat/wasmer wasm alt r=Amanieu a=ptitSeb

# Description
Abiility to build wasmer compile engine as WebAssembly, using a new CLI program `wasmer-compiler-cli`.
This is done with following steps:
 * New wasmer-engine-universal-artifact (extracted from wasmer-engine-universal), that handle only compilation and serialization.
 * wasmer-engine-universal will uses this crate to create the artifact binary.
 * wasmer-compiler-cli uses this crate for offline compilation.

Co-authored-by: ptitSeb <[email protected]>
  • Loading branch information
bors[bot] and ptitSeb authored May 3, 2022
2 parents 1329c71 + 0c7ea79 commit c164c16
Show file tree
Hide file tree
Showing 82 changed files with 2,888 additions and 1,048 deletions.
59 changes: 56 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"lib/cache",
"lib/c-api",
"lib/cli",
"lib/cli-compiler",
"lib/compiler",
"lib/compiler-cranelift",
"lib/compiler-singlepass",
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ifneq ($(ENABLE_LLVM), 0)
endif
endif

exclude_tests := --exclude wasmer-c-api --exclude wasmer-cli
exclude_tests := --exclude wasmer-c-api --exclude wasmer-cli --exclude wasmer-compiler-cli
# Is failing to compile in Linux for some reason
exclude_tests += --exclude wasmer-wasi-experimental-io-devices
# We run integration tests separately (it requires building the c-api)
Expand Down Expand Up @@ -379,6 +379,9 @@ build-wasmer-debug:
bench:
cargo bench $(compiler_features)

build-wasmer-wasm:
cargo build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,universal --bin wasmer-compiler

# For best results ensure the release profile looks like the following
# in Cargo.toml:
# [profile.release]
Expand Down
1 change: 1 addition & 0 deletions lib/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ edition = "2018"
# Shared dependencies.
[dependencies]
# - Mandatory shared dependencies.
wasmer-artifact = { path = "../artifact", version = "=2.2.1" }
indexmap = { version = "1.6", features = ["serde-1"] }
cfg-if = "1.0"
thiserror = "1.0"
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod resolver;
mod store;
mod trap;
mod types;
mod utils;
mod wasm_bindgen_polyfill;

/// Implement [`WasmerEnv`] for your type with `#[derive(WasmerEnv)]`.
Expand Down Expand Up @@ -75,8 +74,8 @@ pub use crate::js::types::{
TableType, Val, ValType,
};
pub use crate::js::types::{Val as Value, ValType as Type};
pub use crate::js::utils::is_wasm;

pub use wasmer_types::is_wasm;
pub use wasmer_types::{
Atomically, Bytes, ExportIndex, GlobalInit, LocalFunctionIndex, MemoryView, Pages, ValueType,
WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod ptr;
mod store;
mod tunables;
mod types;
mod utils;

/// Implement [`WasmerEnv`] for your type with `#[derive(WasmerEnv)]`.
///
Expand Down Expand Up @@ -45,7 +44,6 @@ pub use crate::sys::types::{
TableType, Val, ValType,
};
pub use crate::sys::types::{Val as Value, ValType as Type};
pub use crate::sys::utils::is_wasm;
pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple, HOST};
#[cfg(feature = "compiler")]
pub use wasmer_compiler::{
Expand All @@ -59,6 +57,7 @@ pub use wasmer_engine::{
ChainableNamedResolver, DeserializeError, Engine, Export, FrameInfo, LinkError, NamedResolver,
NamedResolverChain, Resolver, RuntimeError, SerializeError, Tunables,
};
pub use wasmer_types::is_wasm;
#[cfg(feature = "experimental-reference-types-extern-ref")]
pub use wasmer_types::ExternRef;
pub use wasmer_types::{
Expand Down
4 changes: 0 additions & 4 deletions lib/api/src/sys/utils.rs

This file was deleted.

22 changes: 22 additions & 0 deletions lib/artifact/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "wasmer-artifact"
version = "2.2.1"
description = "Wasmer Artifact abstraction"
categories = ["wasm"]
keywords = ["wasm", "webassembly", "engine"]
authors = ["Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
license = "MIT OR Apache-2.0 WITH LLVM-exception "
readme = "README.md"
edition = "2018"

[dependencies]
wasmer-types = { path = "../types", version = "=2.2.1" }
wasmer-compiler = { path = "../compiler", version = "=2.2.1" }
loupe = "0.1"
thiserror = "1.0"
enumset = "1.0"

[badges]
maintenance = { status = "actively-developed" }

20 changes: 20 additions & 0 deletions lib/artifact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `wasmer-artifact` [![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 is the general abstraction for creating Artifacts in Wasmer.

### Acknowledgments

This project borrowed some of the code of the trap implementation from
the [`wasmtime-api`], the code since then has evolved significantly.

Please check [Wasmer `ATTRIBUTIONS`] to further see licenses and other
attributions of the project.


[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal
[`wasmer-engine-dylib`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-dylib
[`wasmer-engine-staticlib`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-staticlib
[`wasmer-engine-dummy`]: https://github.com/wasmerio/wasmer/tree/master/tests/lib/engine-dummy
[`wasmtime-api`]: https://crates.io/crates/wasmtime
[Wasmer `ATTRIBUTIONS`]: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
Loading

0 comments on commit c164c16

Please sign in to comment.