|
| 1 | +## Summary |
| 2 | +SIMD benchmarks fail to compile due to unconditional imports of conditionally-compiled functions and missing `required-features` declaration. |
| 3 | + |
| 4 | +## Environment |
| 5 | +- **Product/Service**: WebARKitLib-rs |
| 6 | +- **Crate**: `crates/core` |
| 7 | +- **Component**: Benchmarks (`simd_bench`) |
| 8 | + |
| 9 | +## Reproduction Steps |
| 10 | +1. Run `cargo bench --features simd` |
| 11 | +2. Observe compilation error in `crates/core/benches/simd_bench.rs` |
| 12 | + |
| 13 | +## Expected Behavior |
| 14 | +Benchmarks compile and run successfully when `--features simd` is enabled, comparing scalar and SIMD implementations. |
| 15 | + |
| 16 | +## Actual Behavior |
| 17 | +Compilation fails with `error[E0432]: unresolved imports` for SIMD functions: |
| 18 | +- `box_filter_h_simd_x86` |
| 19 | +- `box_filter_v_simd_x86` |
| 20 | +- `rgba_to_gray_simd_x86` |
| 21 | +- `dot_product_simd_x86` |
| 22 | + |
| 23 | +## Error Details |
| 24 | +``` |
| 25 | +error[E0432]: unresolved imports `webarkitlib_rs::image_proc::box_filter_h_simd_x86`, ... |
| 26 | + --> crates\core\benches\simd_bench.rs:39:26 |
| 27 | +
|
| 28 | +note: found an item that was configured out |
| 29 | + --> crates\core\src\ar\image_proc.rs:576:15 |
| 30 | +``` |
| 31 | + |
| 32 | +The functions are gated behind `#[cfg(all(feature = "simd-image", target_arch = "x86_64", target_feature = "sse4.1"))]`. |
| 33 | + |
| 34 | +## Root Cause |
| 35 | +1. **Missing `required-features`**: The `simd_bench` benchmark in `Cargo.toml` didn't declare `required-features = ["simd-x86-sse41"]`, so cargo wouldn't ensure the feature is enabled when building the benchmark. |
| 36 | +2. **Unconditional imports**: The benchmark's top-level imports tried to import SIMD functions unconditionally, but they're only compiled when the `target_feature = "sse4.1"` cfg is true. |
| 37 | + |
| 38 | +## Impact |
| 39 | +**Medium** - Benchmarks cannot be run with SIMD features enabled, blocking performance testing of optimized implementations. |
| 40 | + |
| 41 | +## Solution |
| 42 | +1. Added `required-features = ["simd-x86-sse41"]` to the `simd_bench` configuration in `Cargo.toml` |
| 43 | +2. Made SIMD function imports conditional using `#[cfg(all(target_arch = "x86_64", target_feature = "sse4.1"))]` guards in `simd_bench.rs` |
| 44 | + |
| 45 | +## Files Modified |
| 46 | +- `crates/core/Cargo.toml` — Added required-features to simd_bench |
| 47 | +- `crates/core/benches/simd_bench.rs` — Made SIMD imports conditional |
| 48 | + |
| 49 | +## Additional Context |
| 50 | +The benchmark code already had conditional compilation guards around SIMD function calls (lines 54, 73, 105), but the imports at the top were unconditional, causing the mismatch. |
0 commit comments