diff --git a/lib/api/src/error.rs b/lib/api/src/error.rs index 35400775b7d..75c1e806ea5 100644 --- a/lib/api/src/error.rs +++ b/lib/api/src/error.rs @@ -20,7 +20,7 @@ pub enum LinkError { /// A trap ocurred during linking. #[cfg_attr(feature = "std", error("RuntimeError occurred during linking: {0}"))] - Trap(#[source] RuntimeError), + Trap(#[cfg_attr(feature = "std", source)] RuntimeError), /// Insufficient resources available for linking. #[cfg_attr(feature = "std", error("Insufficient resources: {0}"))] Resource(String), diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index 36270943339..db04888e480 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -413,29 +413,143 @@ //! [`wasmi`]: https://github.com/wasmi-labs/wasmi #[cfg(not(any( - feature = "sys", - feature = "js", - feature = "jsc", + feature = "singlepass", + feature = "cranelift", + feature = "llvm", feature = "wamr", + feature = "wasmi", feature = "v8", - feature = "wasmi" + feature = "js", + feature = "jsc" )))] compile_error!( - "One of: `sys`, `js`, `jsc` `wamr`, `wasmi` or `v8` features must be enabled. Please, pick one." + "wasmer requires enabling at least one backend feature: `sys`, `wamr`, `wasmi`, `v8`, `js`, or `jsc`." ); +#[cfg(all( + feature = "sys", + not(any(feature = "singlepass", feature = "cranelift", feature = "llvm")) +))] +compile_error!( + "the `sys` feature requires enabling at least one compiler backend: `singlepass`, `cranelift`, or `llvm`." +); + +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] mod utils; + +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] pub use utils::*; +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] mod entities; + +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] pub use entities::memory::{location::MemoryLocation, MemoryView}; + +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] pub use entities::*; +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] mod error; + +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] pub use error::*; +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] mod backend; +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] pub use backend::*; +#[cfg(any( + feature = "cranelift", + feature = "singlepass", + feature = "llvm", + feature = "js", + feature = "jsc", + feature = "wamr", + feature = "v8", + feature = "wasmi" +))] mod vm; pub use wasmer_types::{ diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index faeeaea2fef..8ffa94129a1 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -448,7 +448,7 @@ impl Artifact { get_got_address(RelocationTarget::LibCall(wasmer_vm::LibCall::EHPersonality)), )?; - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "compiler", not(target_arch = "wasm32")))] { engine_inner.register_perfmap(&finished_functions, module_info)?; } diff --git a/lib/compiler/src/engine/inner.rs b/lib/compiler/src/engine/inner.rs index 8d1637fbadb..8ec297e4b62 100644 --- a/lib/compiler/src/engine/inner.rs +++ b/lib/compiler/src/engine/inner.rs @@ -536,7 +536,7 @@ impl EngineInner { .register_frame_info(frame_info); } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "compiler", not(target_arch = "wasm32")))] pub(crate) fn register_perfmap( &self, finished_functions: &PrimaryMap, diff --git a/lib/compiler/src/lib.rs b/lib/compiler/src/lib.rs index e949a4329ae..56c4d5a0146 100644 --- a/lib/compiler/src/lib.rs +++ b/lib/compiler/src/lib.rs @@ -32,6 +32,7 @@ compile_error!("Both the `std` and `core` features are disabled. Please enable o extern crate alloc; #[allow(unused_imports)] +#[cfg(any(feature = "std", feature = "core"))] mod lib { #[cfg(feature = "core")] pub mod std { @@ -46,18 +47,27 @@ mod lib { } } +#[cfg(any(feature = "std", feature = "core"))] mod engine; +#[cfg(any(feature = "std", feature = "core"))] mod traits; +#[cfg(any(feature = "std", feature = "core"))] pub mod object; +#[cfg(any(feature = "std", feature = "core"))] pub mod serialize; +#[cfg(any(feature = "std", feature = "core"))] pub mod types; +#[cfg(any(feature = "std", feature = "core"))] pub use crate::engine::*; +#[cfg(any(feature = "std", feature = "core"))] pub use crate::traits::*; +#[cfg(any(feature = "std", feature = "core"))] mod artifact_builders; +#[cfg(any(feature = "std", feature = "core"))] pub use self::artifact_builders::*; #[cfg(feature = "compiler")]