Skip to content

Commit d87be86

Browse files
committed
Restructure feature gating to fix CI warnings
1 parent 47f6b2c commit d87be86

File tree

9 files changed

+52
-43
lines changed

9 files changed

+52
-43
lines changed

Cargo.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,9 @@ gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"]
523523
gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"]
524524
pulley = ["wasmtime-cli-flags/pulley"]
525525
stack-switching = ["wasmtime/stack-switching", "wasmtime-cli-flags/stack-switching"]
526-
# `rr` only configures the base infrastructure and is not practically useful by itself
527-
# Use `rr-component` or `rr-core` for generating record/replay events for components/core wasm
528-
# respectively
529-
# Use `rr-validate` for additional validation checks over the above two features
530-
rr = ["wasmtime-cli-flags/rr"]
531-
rr-component = ["wasmtime/rr-component", "rr"]
532-
rr-core = ["wasmtime/rr-core", "rr"]
533-
rr-validate = ["wasmtime/rr-validate", "wasmtime-cli-flags/rr-validate"]
526+
rr = ["wasmtime/rr", "wasmtime-cli-flags/rr"]
527+
rr-component = ["rr", "wasmtime/rr-component"]
528+
rr-validate = ["rr", "wasmtime/rr-validate", "wasmtime-cli-flags/rr-validate"]
534529

535530
# CLI subcommands for the `wasmtime` executable. See `wasmtime $cmd --help`
536531
# for more information on each subcommand.

crates/wasmtime/Cargo.toml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,12 @@ component-model-async-bytes = [
405405
"dep:bytes",
406406
]
407407

408-
# `rr` only configures the base infrastructure and is not practically useful by itself
409-
# Use `rr-component` or `rr-core` for generating record/replay events for components/core wasm
410-
# respectively
411-
rr = ["dep:embedded-io"]
412-
# RR for components
408+
# Enables support for record/replay for components
413409
rr-component = ["component-model", "rr"]
414-
# RR for core wasm
415-
rr-core = ["rr"]
410+
# Enable support for the common base infrastructure of record/replay
411+
# By default, this supports core wasm `rr`. For components, enable `rr-component`
412+
rr = ["dep:embedded-io"]
416413

417-
# Support for validation signatures/checks during record/replay respectively.
418-
# This feature only makes sense if 'rr-component' or 'rr-core' is enabled
414+
# Enables record/replay with support for additional validation signatures/checks.
419415
rr-validate = ["rr"]
420416

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ use crate::component::matching::InstanceType;
44
use crate::component::resources::{HostResourceData, HostResourceIndex, HostResourceTables};
55
use crate::component::{Instance, ResourceType};
66
use crate::prelude::*;
7-
#[cfg(all(feature = "rr", feature = "rr-validate"))]
8-
use crate::rr::Validate;
97
#[cfg(feature = "rr-component")]
10-
use crate::rr::component_events::{MemorySliceWriteEvent, ReallocEntryEvent, ReallocReturnEvent};
11-
#[cfg(feature = "rr-component")]
12-
use crate::rr::{RREvent, RecordBuffer, Recorder, ReplayError, Replayer};
8+
use crate::rr::{
9+
RREvent, RecordBuffer, Recorder, ReplayError, Replayer,
10+
component_events::MemorySliceWriteEvent, component_events::ReallocEntryEvent,
11+
};
12+
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
13+
use crate::rr::{Validate, component_events::ReallocReturnEvent};
1314
use crate::runtime::vm::component::{
1415
CallContexts, ComponentInstance, InstanceFlags, ResourceTable, ResourceTables,
1516
};
@@ -491,7 +492,7 @@ impl<'a, T: 'static> LowerContext<'a, T> {
491492
.0
492493
.record_event(|| ReallocEntryEvent::new(old, old_size, old_align, new_size))?;
493494
let result = self.realloc_inner(old, old_size, old_align, new_size);
494-
#[cfg(feature = "rr-component")]
495+
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
495496
self.store
496497
.0
497498
.record_event_validation(|| ReallocReturnEvent::new(&result))?;
@@ -676,7 +677,8 @@ impl<'a, T: 'static> LowerContext<'a, T> {
676677
while !complete {
677678
let buf = self.store.0.replay_buffer_mut().unwrap();
678679
let event = buf.next_event()?;
679-
let _run_validate = buf.settings().validate && buf.trace_settings().add_validation;
680+
#[cfg(feature = "rr-validate")]
681+
let run_validate = buf.settings().validate && buf.trace_settings().add_validation;
680682
match event {
681683
RREvent::ComponentHostFuncReturn(e) => {
682684
// End of the lowering process
@@ -692,21 +694,21 @@ impl<'a, T: 'static> LowerContext<'a, T> {
692694
let _result =
693695
self.realloc_inner(e.old_addr, e.old_size, e.old_align, e.new_size);
694696
#[cfg(feature = "rr-validate")]
695-
if _run_validate {
697+
if run_validate {
696698
_realloc_stack.push(_result);
697699
}
698700
}
699701
// No return value to validate for lower/lower-store; store error and just check that entry happened before
700702
RREvent::ComponentLowerReturn(e) => {
701703
#[cfg(feature = "rr-validate")]
702-
if _run_validate {
704+
if run_validate {
703705
_lower_stack.pop().ok_or(ReplayError::InvalidOrdering)?;
704706
}
705707
lowering_error = e.ret().map_err(Into::into).err();
706708
}
707709
RREvent::ComponentLowerStoreReturn(e) => {
708710
#[cfg(feature = "rr-validate")]
709-
if _run_validate {
711+
if run_validate {
710712
_lower_store_stack
711713
.pop()
712714
.ok_or(ReplayError::InvalidOrdering)?;
@@ -730,21 +732,21 @@ impl<'a, T: 'static> LowerContext<'a, T> {
730732
RREvent::ComponentReallocReturn(_e) =>
731733
{
732734
#[cfg(feature = "rr-validate")]
733-
if _run_validate {
735+
if run_validate {
734736
lowering_error = _e.validate(&_realloc_stack.pop().unwrap()).err()
735737
}
736738
}
737739
RREvent::ComponentLowerEntry(_) => {
738740
// All we want here is ensuring Entry occurs before Return
739741
#[cfg(feature = "rr-validate")]
740-
if _run_validate {
742+
if run_validate {
741743
_lower_stack.push(())
742744
}
743745
}
744746
RREvent::ComponentLowerStoreEntry(_) => {
745747
// All we want here is ensuring Entry occurs before Return
746748
#[cfg(feature = "rr-validate")]
747-
if _run_validate {
749+
if run_validate {
748750
_lower_store_stack.push(())
749751
}
750752
}

crates/wasmtime/src/runtime/func.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ impl Func {
14851485
/// Convenience methods to inject record + replay logic
14861486
mod rr_hooks {
14871487
use super::*;
1488-
#[cfg(feature = "rr-core")]
1488+
#[cfg(feature = "rr")]
14891489
use crate::rr::core_events::HostFuncReturnEvent;
14901490
use wasmtime_environ::WasmFuncType;
14911491

@@ -1496,7 +1496,7 @@ mod rr_hooks {
14961496
wasm_func_type: &WasmFuncType,
14971497
store: &mut StoreOpaque,
14981498
) -> Result<()> {
1499-
#[cfg(all(feature = "rr-core", feature = "rr-validate"))]
1499+
#[cfg(all(feature = "rr", feature = "rr-validate"))]
15001500
{
15011501
// Record/replay the raw parameter args
15021502
use crate::rr::core_events::HostFuncEntryEvent;
@@ -1518,7 +1518,7 @@ mod rr_hooks {
15181518
store: &mut StoreOpaque,
15191519
) -> Result<()> {
15201520
// Record the return values
1521-
#[cfg(feature = "rr-core")]
1521+
#[cfg(feature = "rr")]
15221522
store.record_event(|| {
15231523
let func_type = wasm_func_type;
15241524
let num_results = func_type.params().len();
@@ -1535,7 +1535,7 @@ mod rr_hooks {
15351535
wasm_func_type: &WasmFuncType,
15361536
store: &mut StoreOpaque,
15371537
) -> Result<()> {
1538-
#[cfg(feature = "rr-core")]
1538+
#[cfg(feature = "rr")]
15391539
store.next_replay_event_and(|event: HostFuncReturnEvent| {
15401540
event.move_into_slice(args);
15411541
Ok(())

crates/wasmtime/src/runtime/rr/events/component_events.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl HostFuncEntryEvent {
4343
}
4444
}
4545
}
46+
#[cfg(feature = "rr-validate")]
4647
impl Validate<TypeFunc> for HostFuncEntryEvent {
4748
fn validate(&self, expect_types: &TypeFunc) -> Result<(), ReplayError> {
4849
self.log();
@@ -143,6 +144,7 @@ generic_new_result_events! {
143144
LowerStoreReturnEvent => ((), EventActionError::LowerStoreError)
144145
}
145146

147+
#[cfg(feature = "rr-validate")]
146148
impl Validate<Result<usize>> for ReallocReturnEvent {
147149
/// We can check that realloc is deterministic (as expected by the engine)
148150
fn validate(&self, expect_ret: &Result<usize>) -> Result<(), ReplayError> {

crates/wasmtime/src/runtime/rr/events/core_events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl HostFuncEntryEvent {
2323
}
2424
}
2525
}
26+
#[cfg(feature = "rr-validate")]
2627
impl Validate<CoreFuncArgTypes> for HostFuncEntryEvent {
2728
fn validate(&self, expect_types: &CoreFuncArgTypes) -> Result<(), ReplayError> {
2829
self.log();

crates/wasmtime/src/runtime/rr/events/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
12
use super::ReplayError;
23
use crate::ValRaw;
34
use crate::prelude::*;
@@ -97,6 +98,7 @@ where
9798
/// Note however that some [`Validate`] implementations are present even
9899
/// when feature `rr-validate` is disabled, when validation is needed
99100
/// for a faithful replay (e.g. [`component_events::InstantiationEvent`]).
101+
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
100102
pub trait Validate<T: ?Sized> {
101103
/// Perform a validation of the event to ensure replay consistency
102104
fn validate(&self, expect: &T) -> Result<(), ReplayError>;
@@ -110,6 +112,7 @@ pub trait Validate<T: ?Sized> {
110112
}
111113
}
112114

115+
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
113116
impl<T> Validate<T> for T
114117
where
115118
T: PartialEq + fmt::Debug,

crates/wasmtime/src/runtime/rr/mod.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ use crate::prelude::*;
1212
use core::fmt;
1313
use events::EventActionError;
1414
use serde::{Deserialize, Serialize};
15-
// Use component/core events internally even without feature flags enabled
15+
// Use component events internally even without feature flags enabled
1616
// so that [`RREvent`] has a well-defined serialization format, but export
1717
// it for other modules only when enabled
18+
#[cfg(any(feature = "rr-validate", feature = "rr-component"))]
19+
pub use events::Validate;
1820
use events::component_events as __component_events;
1921
#[cfg(feature = "rr-component")]
2022
pub use events::component_events;
21-
use events::core_events as __core_events;
22-
#[cfg(feature = "rr-core")]
23-
pub use events::core_events;
24-
pub use events::{Validate, marker_events};
23+
pub use events::{core_events, marker_events};
2524
pub use io::{RecordWriter, ReplayReader};
2625

2726
/// Encapsulation of event types comprising an [`RREvent`] sum type
@@ -93,9 +92,9 @@ rr_event! {
9392
CustomMessage(marker_events::CustomMessageEvent),
9493

9594
/// Call into host function from Core Wasm
96-
CoreHostFuncEntry(__core_events::HostFuncEntryEvent),
95+
CoreHostFuncEntry(core_events::HostFuncEntryEvent),
9796
/// Return from host function to Core Wasm
98-
CoreHostFuncReturn(__core_events::HostFuncReturnEvent),
97+
CoreHostFuncReturn(core_events::HostFuncReturnEvent),
9998

10099
// REQUIRED events for replay
101100
//
@@ -209,6 +208,7 @@ pub trait Recorder {
209208

210209
/// Record a event only when validation is requested
211210
#[inline]
211+
#[cfg(feature = "rr-validate")]
212212
fn record_event_validation<T, F>(&mut self, f: F) -> Result<()>
213213
where
214214
T: Into<RREvent>,
@@ -231,9 +231,19 @@ pub trait Replayer: Iterator<Item = RREvent> {
231231
Self: Sized;
232232

233233
/// Get settings associated with the replay process
234+
#[allow(
235+
unused,
236+
reason = "currently used only for validation resulting in \
237+
many unnecessary feature gates. will expand in the future to more features"
238+
)]
234239
fn settings(&self) -> &ReplaySettings;
235240

236241
/// Get the settings (embedded within the trace) during recording
242+
#[allow(
243+
unused,
244+
reason = "currently used only for validation resulting in \
245+
many unnecessary feature gates. will expand in the future to more features"
246+
)]
237247
fn trace_settings(&self) -> &RecordSettings;
238248

239249
// Provided Methods

crates/wasmtime/src/runtime/store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ impl StoreOpaque {
14911491
/// if validation is enabled for recording
14921492
///
14931493
/// Convenience wrapper around [`Recorder::record_event_validation`]
1494-
#[cfg(feature = "rr")]
1494+
#[cfg(feature = "rr-validate")]
14951495
#[inline(always)]
14961496
pub(crate) fn record_event_validation<T, F>(&mut self, f: F) -> Result<()>
14971497
where
@@ -1527,7 +1527,7 @@ impl StoreOpaque {
15271527
/// and if validation is enabled on replay, and run the validation check
15281528
///
15291529
/// Convenience wrapper around [`Replayer::next_event_validation`]
1530-
#[cfg(all(feature = "rr", feature = "rr-validate"))]
1530+
#[cfg(feature = "rr-validate")]
15311531
#[inline]
15321532
pub(crate) fn next_replay_event_validation<T, Y>(
15331533
&mut self,

0 commit comments

Comments
 (0)