From 6156a17a3d60e492fb479fe1acf5a082dab8b6cf Mon Sep 17 00:00:00 2001 From: pizzacat83 <17941141+pizzacat83@users.noreply.github.com> Date: Sun, 7 Dec 2025 18:23:22 +0900 Subject: [PATCH 1/2] fix(benches): add cfg guards for configurator features The benches modules were unconditionally importing from the configurator module, which is only available when at least one of the elf, pe, or bzimage features is enabled. This caused compilation failures when building with --no-default-features or other feature combinations that don't enable any loader features. Added appropriate #[cfg(any(feature = "..."))] guards to all benchmark modules and a no-op fallback benchmark function for when no configurator features are enabled. Fixes #215 Signed-off-by: pizzacat83 <17941141+pizzacat83@users.noreply.github.com> --- benches/fdt.rs | 3 +++ benches/main.rs | 24 ++++++++++++++++++++---- benches/x86_64/mod.rs | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/benches/fdt.rs b/benches/fdt.rs index 8e46c6b..8187824 100644 --- a/benches/fdt.rs +++ b/benches/fdt.rs @@ -4,6 +4,9 @@ // found in the LICENSE-BSD-3-Clause file. // // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause + +#![cfg(any(feature = "elf", feature = "pe", feature = "bzimage"))] + extern crate criterion; extern crate linux_loader; extern crate vm_memory; diff --git a/benches/main.rs b/benches/main.rs index acc435c..f4c76e3 100644 --- a/benches/main.rs +++ b/benches/main.rs @@ -11,16 +11,32 @@ extern crate vm_memory; use criterion::{criterion_group, criterion_main, Criterion}; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(all( + any(target_arch = "x86", target_arch = "x86_64"), + any(feature = "elf", feature = "pe", feature = "bzimage") +))] mod x86_64; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(all( + any(target_arch = "x86", target_arch = "x86_64"), + any(feature = "elf", feature = "pe", feature = "bzimage") +))] use x86_64::*; -#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] +#[cfg(all( + any(target_arch = "aarch64", target_arch = "riscv64"), + any(feature = "elf", feature = "pe", feature = "bzimage") +))] mod fdt; -#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] +#[cfg(all( + any(target_arch = "aarch64", target_arch = "riscv64"), + any(feature = "elf", feature = "pe", feature = "bzimage") +))] pub use fdt::*; +// No-op benchmark when configurator module is not available +#[cfg(not(any(feature = "elf", feature = "pe", feature = "bzimage")))] +fn criterion_benchmark(_c: &mut Criterion) {} + criterion_group! { name = benches; config = Criterion::default().sample_size(500); diff --git a/benches/x86_64/mod.rs b/benches/x86_64/mod.rs index 9cfa5c0..0697b70 100644 --- a/benches/x86_64/mod.rs +++ b/benches/x86_64/mod.rs @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#![cfg(any(feature = "elf", feature = "pe", feature = "bzimage"))] extern crate linux_loader; extern crate vm_memory; From c0c98eca971bb3f8f69fe47aa03f49a53b588120 Mon Sep 17 00:00:00 2001 From: pizzacat83 <17941141+pizzacat83@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:08:17 +0900 Subject: [PATCH 2/2] ci: build all targets in custom build tests Add --all-targets flag to all custom build test commands to ensure benchmarks, tests, and examples are compiled in addition to the library. Signed-off-by: pizzacat83 <17941141+pizzacat83@users.noreply.github.com> --- .buildkite/custom-tests.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/custom-tests.json b/.buildkite/custom-tests.json index c00d988..ae30790 100644 --- a/.buildkite/custom-tests.json +++ b/.buildkite/custom-tests.json @@ -2,21 +2,21 @@ "tests": [ { "test_name": "build-gnu-bzimage", - "command": "cargo build --release --features bzimage", + "command": "cargo build --release --features bzimage --all-targets", "platform": [ "x86_64" ] }, { "test_name": "build-musl-bzimage", - "command": "cargo build --release --features bzimage --target {target_platform}-unknown-linux-musl", + "command": "cargo build --release --features bzimage --target {target_platform}-unknown-linux-musl --all-targets", "platform": [ "x86_64" ] }, { "test_name": "build-no-default-features", - "command": "cargo build --release --no-default-features", + "command": "cargo build --release --no-default-features --all-targets", "platform": [ "x86_64", "aarch64"