I'm trying to provide a workaround for known-badly-performing Rust versions by using feature(link_llvm_intrinsics) (permitted via RUSTC_BOOTSTRAP on stable compiler builds) but only if a Cargo feature is enabled and only on x86 and x86_64.
That is, I want this:
#![cfg_attr(all(feature = "simd-accel", rustversion::since(1.96), rustversion::before(1.99), any(target_arch = "x86", target_arch = "x86_64")), feature(link_llvm_intrinsics))]
...but it doesn't work.
Is there a way to make that combination of conditions work?
It turns out that Rust 1.100 removes feature(abi_unadjusted), so the feature declarations for the workaround really need to go behind a version check.
I ended up adding build.rs with:
fn main() {
println!("cargo::rustc-check-cfg=cfg(slow_mm_packus_epi16)");
if rustversion::cfg!(all(since(1.96), before(1.99))) {
println!("cargo:rustc-cfg=slow_mm_packus_epi16");
}
}
and then in lib.rs:
#![cfg_attr(
all(slow_mm_packus_epi16, feature = "simd-accel", target_feature = "sse2"),
feature(link_llvm_intrinsics)
)]
#![cfg_attr(
all(slow_mm_packus_epi16, feature = "simd-accel", target_feature = "sse2"),
feature(abi_unadjusted)
)]
#![cfg_attr(
all(slow_mm_packus_epi16, feature = "simd-accel", target_feature = "sse2"),
feature(simd_ffi)
)]
It would be nice to have something better. Last time this particular crate had a build.rs, some antivirus product had a false positive about it.