Skip to content

Commit fe6f7a4

Browse files
authored
Miscellaneous feature-related build fixes. (bytecodealliance#12719)
Most found with cargo-all-features. Signed-off-by: Piotr Sikora <code@piotrsikora.dev>
1 parent 3588749 commit fe6f7a4

6 files changed

Lines changed: 23 additions & 12 deletions

File tree

crates/wasmtime/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ reexport-wasmparser = []
379379

380380
# Enables instances of the traits defined in the wasm-wave crate, which
381381
# provides a human-readable text format for component values.
382-
wave = ["dep:wasm-wave", 'component-model']
382+
wave = ["dep:wasm-wave", "component-model", "std"]
383383

384384
# For platforms that Wasmtime does not have support for Wasmtime will disable
385385
# the use of virtual memory by default, for example allocating linear memories
@@ -402,7 +402,13 @@ custom-sync-primitives = []
402402
# Off-by-default support to profile the Pulley interpreter. This has a
403403
# performance hit, even when not profiling, so it's disabled by default at
404404
# compile time.
405-
profile-pulley = ['anyhow', 'pulley', 'profiling', 'pulley-interpreter/profile']
405+
profile-pulley = [
406+
"anyhow",
407+
"profiling",
408+
"pulley",
409+
"pulley-interpreter/interp",
410+
"pulley-interpreter/profile",
411+
]
406412

407413
# Enables support for the Component Model Async ABI, along with `future`,
408414
# `stream`, and `error-context` types.

crates/wasmtime/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ fn main() {
2626
&& (supported_os || cfg!(feature = "custom-native-signals"))
2727
&& has_host_compiler_backend;
2828
let has_virtual_memory = supported_os || cfg!(feature = "custom-virtual-memory");
29-
let has_custom_sync = !cfg!(feature = "std") && cfg!(feature = "custom-sync-primitives");
29+
let has_custom_sync = !cfg!(feature = "std")
30+
&& cfg!(feature = "custom-sync-primitives")
31+
&& cfg!(feature = "runtime");
3032

3133
custom_cfg("has_native_signals", has_native_signals);
3234
custom_cfg("has_virtual_memory", has_virtual_memory);

crates/wasmtime/src/profiling_agent/pulley.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use crate::ToWasmtimeResult as _;
3636
use crate::prelude::*;
3737
use crate::profiling_agent::ProfilingAgent;
38+
#[cfg(feature = "runtime")]
3839
use crate::vm::Interpreter;
3940
use pulley_interpreter::profile::{ExecutingPc, Recorder, Samples};
4041
use std::mem;
@@ -141,6 +142,7 @@ impl ProfilingAgent for PulleyAgent {
141142
/// Registers a new interpreter coming online. Interpreters, with
142143
/// `pulley-profile` enabled, store a shadow program counter updated on each
143144
/// instruction which we can read from a different thread.
145+
#[cfg(feature = "runtime")]
144146
fn register_interpreter(&self, interpreter: &Interpreter) {
145147
let pc = interpreter.pulley().executing_pc();
146148
self.state

crates/wasmtime/src/runtime/vm/mmap_vec.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,17 @@ impl MmapVec {
303303
crate::bail!("Cannot clone an externally-owned code memory.");
304304
}
305305
#[cfg(has_virtual_memory)]
306+
#[allow(
307+
unused_variables,
308+
reason = "`mmap` and `len` only used with `std` feature"
309+
)]
306310
MmapVec::Mmap { mmap, len } => {
311+
#[cfg(feature = "std")]
307312
if let Some(original_file) = mmap.original_file() {
308313
let mmap = Mmap::from_file(original_file.clone())?;
309-
Ok(MmapVec::Mmap { mmap, len: *len })
310-
} else {
311-
MmapVec::from_slice_with_alignment(
312-
&self[..],
313-
crate::runtime::vm::host_page_size(),
314-
)
314+
return Ok(MmapVec::Mmap { mmap, len: *len });
315315
}
316+
MmapVec::from_slice_with_alignment(&self[..], crate::runtime::vm::host_page_size())
316317
}
317318
}
318319
}

pulley/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ all-features = true
4040

4141
[[example]]
4242
name = "profiler-html"
43-
required-features = ["profile"]
43+
required-features = ["disas", "interp", "profile"]

pulley/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ pub mod disas;
13921392
pub mod encode;
13931393
#[cfg(feature = "interp")]
13941394
pub mod interp;
1395-
#[cfg(feature = "profile")]
1395+
#[cfg(all(feature = "profile", feature = "interp"))]
13961396
pub mod profile;
13971397
#[cfg(all(not(feature = "profile"), feature = "interp"))]
13981398
mod profile_disabled;
@@ -1411,7 +1411,7 @@ pub use op::*;
14111411
pub mod opcode;
14121412
pub use opcode::*;
14131413

1414-
#[cfg(any(feature = "encode", feature = "decode"))]
1414+
#[cfg(feature = "decode")]
14151415
pub(crate) unsafe fn unreachable_unchecked() -> ! {
14161416
#[cfg(debug_assertions)]
14171417
unreachable!();

0 commit comments

Comments
 (0)