diff --git a/benches/main.rs b/benches/main.rs index acc435c..49c48c8 100644 --- a/benches/main.rs +++ b/benches/main.rs @@ -11,15 +11,37 @@ extern crate vm_memory; use criterion::{criterion_group, criterion_main, Criterion}; +// Include architecture-specific benchmark modules. +// These modules are now expected to define a function (e.g., `benchmarks`) +// that will be called by the main `criterion_benchmark` function. #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] mod x86_64; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -use x86_64::*; #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] mod fdt; -#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] -pub use fdt::*; + +// Define the main benchmark function which dispatches to architecture-specific benchmarks. +// This centralizes the benchmark entry point and allows for more robust +// #[cfg] handling for 'all-features' compilation scenarios. +// If specific features cause conflicts for certain architectures, +// additional `#[cfg(feature = "...")]` guards can be added here +// around the calls to `x86_64::benchmarks` or `fdt::benchmarks`, +// or within the respective `x86_64` or `fdt` modules themselves. +fn criterion_benchmark(c: &mut Criterion) { + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + // The x86_64 module is expected to provide a `benchmarks` function. + x86_64::benchmarks(c); + + #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] + // The fdt module is expected to provide a `benchmarks` function. + fdt::benchmarks(c); + + // If no architecture-specific benchmarks are enabled (e.g., for an unsupported + // target_arch or if specific feature combinations disable benchmarks), + // this function will simply do nothing. This ensures that `criterion_benchmark` + // always exists and compiles, preventing "undefined function" errors from the + // `criterion_group!` macro during `all-features` and `all-targets` builds. +} criterion_group! { name = benches; @@ -29,4 +51,4 @@ criterion_group! { criterion_main! { benches -} +} \ No newline at end of file diff --git a/src/loader_gen/x86_64/mod.rs b/src/loader_gen/x86_64/mod.rs index 0d1a6c5..88fdf4e 100644 --- a/src/loader_gen/x86_64/mod.rs +++ b/src/loader_gen/x86_64/mod.rs @@ -19,10 +19,11 @@ // Hide the autogenerated documentation for bindgen'ed sources. #[doc(hidden)] +#[cfg(feature = "elf")] pub mod bootparam; #[cfg(feature = "elf")] pub mod elf; #[cfg(feature = "elf")] -pub mod start_info; +pub mod start_info; \ No newline at end of file