Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Miscellaneous feature-related build fixes. (#12719)

Piotr Sikorafe6f7a40b607
diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml
index a77f986ec7..abc14cda02 100644
--- a/crates/wasmtime/Cargo.toml
+++ b/crates/wasmtime/Cargo.toml
@@ -379,7 +379,7 @@ reexport-wasmparser = []
# Enables instances of the traits defined in the wasm-wave crate, which
# provides a human-readable text format for component values.
-wave = ["dep:wasm-wave", 'component-model']
+wave = ["dep:wasm-wave", "component-model", "std"]
# For platforms that Wasmtime does not have support for Wasmtime will disable
# the use of virtual memory by default, for example allocating linear memories
@@ -402,7 +402,13 @@ custom-sync-primitives = []
# Off-by-default support to profile the Pulley interpreter. This has a
# performance hit, even when not profiling, so it's disabled by default at
# compile time.
-profile-pulley = ['anyhow', 'pulley', 'profiling', 'pulley-interpreter/profile']
+profile-pulley = [
+ "anyhow",
+ "profiling",
+ "pulley",
+ "pulley-interpreter/interp",
+ "pulley-interpreter/profile",
+]
# Enables support for the Component Model Async ABI, along with `future`,
# `stream`, and `error-context` types.
diff --git a/crates/wasmtime/build.rs b/crates/wasmtime/build.rs
index c80e4bf505..c5c3b63850 100644
--- a/crates/wasmtime/build.rs
+++ b/crates/wasmtime/build.rs
@@ -26,7 +26,9 @@ fn main() {
&& (supported_os || cfg!(feature = "custom-native-signals"))
&& has_host_compiler_backend;
let has_virtual_memory = supported_os || cfg!(feature = "custom-virtual-memory");
- let has_custom_sync = !cfg!(feature = "std") && cfg!(feature = "custom-sync-primitives");
+ let has_custom_sync = !cfg!(feature = "std")
+ && cfg!(feature = "custom-sync-primitives")
+ && cfg!(feature = "runtime");
custom_cfg("has_native_signals", has_native_signals);
custom_cfg("has_virtual_memory", has_virtual_memory);
diff --git a/crates/wasmtime/src/profiling_agent/pulley.rs b/crates/wasmtime/src/profiling_agent/pulley.rs
index ef374aeea4..2a8da3e9b2 100644
--- a/crates/wasmtime/src/profiling_agent/pulley.rs
+++ b/crates/wasmtime/src/profiling_agent/pulley.rs
@@ -35,6 +35,7 @@
use crate::ToWasmtimeResult as _;
use crate::prelude::*;
use crate::profiling_agent::ProfilingAgent;
+#[cfg(feature = "runtime")]
use crate::vm::Interpreter;
use pulley_interpreter::profile::{ExecutingPc, Recorder, Samples};
use std::mem;
@@ -141,6 +142,7 @@ impl ProfilingAgent for PulleyAgent {
/// Registers a new interpreter coming online. Interpreters, with
/// `pulley-profile` enabled, store a shadow program counter updated on each
/// instruction which we can read from a different thread.
+ #[cfg(feature = "runtime")]
fn register_interpreter(&self, interpreter: &Interpreter) {
let pc = interpreter.pulley().executing_pc();
self.state
diff --git a/crates/wasmtime/src/runtime/vm/mmap_vec.rs b/crates/wasmtime/src/runtime/vm/mmap_vec.rs
index b00888efbc..db1d5d86c3 100644
--- a/crates/wasmtime/src/runtime/vm/mmap_vec.rs
+++ b/crates/wasmtime/src/runtime/vm/mmap_vec.rs
@@ -303,16 +303,17 @@ impl MmapVec {
crate::bail!("Cannot clone an externally-owned code memory.");
}
#[cfg(has_virtual_memory)]
+ #[allow(
+ unused_variables,
+ reason = "`mmap` and `len` only used with `std` feature"
+ )]
MmapVec::Mmap { mmap, len } => {
+ #[cfg(feature = "std")]
if let Some(original_file) = mmap.original_file() {
let mmap = Mmap::from_file(original_file.clone())?;
- Ok(MmapVec::Mmap { mmap, len: *len })
- } else {
- MmapVec::from_slice_with_alignment(
- &self[..],
- crate::runtime::vm::host_page_size(),
- )
+ return Ok(MmapVec::Mmap { mmap, len: *len });
}
+ MmapVec::from_slice_with_alignment(&self[..], crate::runtime::vm::host_page_size())
}
}
}
diff --git a/pulley/Cargo.toml b/pulley/Cargo.toml
index 8e4b46c189..58ed092fa4 100644
--- a/pulley/Cargo.toml
+++ b/pulley/Cargo.toml
@@ -40,4 +40,4 @@ all-features = true
[[example]]
name = "profiler-html"
-required-features = ["profile"]
+required-features = ["disas", "interp", "profile"]
diff --git a/pulley/src/lib.rs b/pulley/src/lib.rs
index 40d7122206..dba201017d 100644
--- a/pulley/src/lib.rs
+++ b/pulley/src/lib.rs
@@ -1392,7 +1392,7 @@ pub mod disas;
pub mod encode;
#[cfg(feature = "interp")]
pub mod interp;
-#[cfg(feature = "profile")]
+#[cfg(all(feature = "profile", feature = "interp"))]
pub mod profile;
#[cfg(all(not(feature = "profile"), feature = "interp"))]
mod profile_disabled;
@@ -1411,7 +1411,7 @@ pub use op::*;
pub mod opcode;
pub use opcode::*;
-#[cfg(any(feature = "encode", feature = "decode"))]
+#[cfg(feature = "decode")]
pub(crate) unsafe fn unreachable_unchecked() -> ! {
#[cfg(debug_assertions)]
unreachable!();