diff --git a/lib/environ/Cargo.toml b/lib/environ/Cargo.toml index 7681f8bb6e..8de7232bdf 100644 --- a/lib/environ/Cargo.toml +++ b/lib/environ/Cargo.toml @@ -15,6 +15,11 @@ cranelift-entity = "0.24.0" cranelift-wasm = "0.24.0" memoffset = "0.2.1" +[features] +default = ["std"] +std = ["cranelift-codegen/std", "cranelift-wasm/std"] +core = ["cranelift-codegen/core", "cranelift-wasm/core"] + [badges] maintenance = { status = "experimental" } travis-ci = { repository = "CraneStation/wasmtime" } diff --git a/lib/environ/src/compilation.rs b/lib/environ/src/compilation.rs index 55a84eddfa..d6d82d6644 100644 --- a/lib/environ/src/compilation.rs +++ b/lib/environ/src/compilation.rs @@ -9,6 +9,8 @@ use cranelift_codegen::Context; use cranelift_entity::{EntityRef, PrimaryMap}; use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator}; use environ::{get_func_name, ModuleTranslation}; +use std::string::{String, ToString}; +use std::vec::Vec; /// The result of compiling a WebAssemby module's functions. #[derive(Debug)] diff --git a/lib/environ/src/environ.rs b/lib/environ/src/environ.rs index 295b69ff07..122c8f84d0 100644 --- a/lib/environ/src/environ.rs +++ b/lib/environ/src/environ.rs @@ -13,6 +13,8 @@ use cranelift_wasm::{ }; use module::{DataInitializer, Export, LazyContents, Module, TableElements}; use std::mem; +use std::string::String; +use std::vec::Vec; use vmcontext; /// Compute a `ir::ExternalName` for a given wasm function index. diff --git a/lib/environ/src/lib.rs b/lib/environ/src/lib.rs index 4ad0c82ad6..7701756069 100644 --- a/lib/environ/src/lib.rs +++ b/lib/environ/src/lib.rs @@ -3,13 +3,9 @@ //! the translation the base addresses of regions of memory that will hold the globals, tables and //! linear memories. -#![deny( - missing_docs, - trivial_numeric_casts, - unused_extern_crates, - unstable_features -)] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces)] +#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr( feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")) @@ -31,12 +27,17 @@ use_self ) )] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(feature = "std"), feature(alloc))] extern crate cranelift_codegen; extern crate cranelift_entity; extern crate cranelift_wasm; #[macro_use] extern crate memoffset; +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; mod compilation; mod environ; @@ -46,3 +47,10 @@ mod vmcontext; pub use compilation::{compile_module, Compilation, Relocation, RelocationTarget, Relocations}; pub use environ::{ModuleEnvironment, ModuleTranslation}; pub use module::{DataInitializer, Module, TableElements}; + +#[cfg(not(feature = "std"))] +mod std { + pub use alloc::{string, vec}; + pub use core::*; + pub use core::{i32, str, u32}; +} diff --git a/lib/environ/src/module.rs b/lib/environ/src/module.rs index 3e0391e04a..c9bed3266c 100644 --- a/lib/environ/src/module.rs +++ b/lib/environ/src/module.rs @@ -7,6 +7,8 @@ use cranelift_wasm::{ TableIndex, }; use std::collections::HashMap; +use std::string::String; +use std::vec::Vec; /// A WebAssembly table initializer. #[derive(Clone, Debug)] diff --git a/lib/execute/Cargo.toml b/lib/execute/Cargo.toml index f98a3ecaed..6938ebf9bf 100644 --- a/lib/execute/Cargo.toml +++ b/lib/execute/Cargo.toml @@ -7,6 +7,7 @@ description = "JIT-style execution for WebAsssembly code in Cranelift" categories = ["wasm"] repository = "https://github.com/CraneStation/wasmtime" license = "Apache-2.0 WITH LLVM-exception" +readme = "README.md" [dependencies] cranelift-codegen = "0.24.0" @@ -15,3 +16,12 @@ cranelift-wasm = "0.24.0" region = "1.0.0" wasmtime-environ = { path = "../environ" } memmap = "0.7.0" + +[features] +default = ["std"] +std = ["cranelift-codegen/std", "cranelift-wasm/std"] +core = ["cranelift-codegen/core", "cranelift-wasm/core", "wasmtime-environ/core"] + +[badges] +maintenance = { status = "experimental" } +travis-ci = { repository = "CraneStation/wasmtime" } diff --git a/lib/execute/README.md b/lib/execute/README.md new file mode 100644 index 0000000000..13fb3d6a1d --- /dev/null +++ b/lib/execute/README.md @@ -0,0 +1,4 @@ +This is the `wasmtime-execute` crate, which contains wasm runtime support, +supporting the wasm ABI defined by [`wasmtime-environ`]. + +[`wasmtime-environ`]: https://crates.io/crates/wasmtime-environ diff --git a/lib/execute/src/execute.rs b/lib/execute/src/execute.rs index 1fd1092c59..cecc05fc17 100644 --- a/lib/execute/src/execute.rs +++ b/lib/execute/src/execute.rs @@ -8,6 +8,8 @@ use region::protect; use region::Protection; use std::mem::transmute; use std::ptr::{self, write_unaligned}; +use std::string::String; +use std::vec::Vec; use wasmtime_environ::{ compile_module, Compilation, Module, ModuleTranslation, Relocation, RelocationTarget, }; diff --git a/lib/execute/src/instance.rs b/lib/execute/src/instance.rs index d9d214a7d2..36ade34767 100644 --- a/lib/execute/src/instance.rs +++ b/lib/execute/src/instance.rs @@ -6,6 +6,7 @@ use cranelift_entity::EntityRef; use cranelift_entity::PrimaryMap; use cranelift_wasm::{GlobalIndex, MemoryIndex, TableIndex}; use memory::LinearMemory; +use std::vec::Vec; use wasmtime_environ::{Compilation, DataInitializer, Module, TableElements}; /// An Instance of a WebAssemby module. diff --git a/lib/execute/src/lib.rs b/lib/execute/src/lib.rs index 3bf2646cd4..f5adfa6ab4 100644 --- a/lib/execute/src/lib.rs +++ b/lib/execute/src/lib.rs @@ -1,12 +1,8 @@ //! JIT-style runtime for WebAssembly using Cranelift. -#![deny( - missing_docs, - trivial_numeric_casts, - unused_extern_crates, - unstable_features -)] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces)] +#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr( feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")) @@ -28,6 +24,8 @@ use_self ) )] +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(feature = "std"), feature(alloc))] extern crate cranelift_codegen; extern crate cranelift_entity; @@ -35,6 +33,9 @@ extern crate cranelift_wasm; extern crate memmap; extern crate region; extern crate wasmtime_environ; +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; mod execute; mod instance; @@ -42,3 +43,10 @@ mod memory; pub use execute::{compile_and_link_module, execute}; pub use instance::Instance; + +#[cfg(not(feature = "std"))] +mod std { + pub use alloc::{string, vec}; + pub use core::*; + pub use core::{i32, str, u32}; +}