| 1 |
use std::{env, process::Command}; |
| 2 |
|
| 3 |
fn main() { |
| 4 |
if let Some(minor_version) = minor_rustc_version() { |
| 5 |
// rustc 1.80 stabilized ARM CRC32 intrinsics: |
| 6 |
// https://doc.rust-lang.org/nightly/core/arch/aarch64/fn.__crc32d.html |
| 7 |
if minor_version >= 80 { |
| 8 |
println!("cargo:rustc-check-cfg=cfg(stable_arm_crc32_intrinsics)"); |
| 9 |
println!("cargo:rustc-check-cfg=cfg(stable_vpclmulqdq)"); |
| 10 |
println!("cargo:rustc-cfg=stable_arm_crc32_intrinsics"); |
| 11 |
} |
| 12 |
|
| 13 |
// rustc 1.89 stabilized the x86 VPCLMULQDQ intrinsics (256-bit AVX2 and 512-bit AVX-512): |
| 14 |
// https://doc.rust-lang.org/core/arch/x86_64/fn._mm256_clmulepi64_epi128.html |
| 15 |
// Gating the wide fold paths on this keeps the crate MSRV unchanged on older toolchains. |
| 16 |
if minor_version >= 89 { |
| 17 |
println!("cargo:rustc-cfg=stable_vpclmulqdq"); |
| 18 |
} |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
fn minor_rustc_version() -> Option<u32> { |
| 23 |
Command::new(env::var_os("RUSTC")?) |
| 24 |
.arg("--version") |
| 25 |
.output() |
| 26 |
.ok() |
| 27 |
.and_then(|output| { |
| 28 |
std::str::from_utf8(&output.stdout).ok().and_then(|output| { |
| 29 |
output |
| 30 |
.split('.') |
| 31 |
.nth(1) |
| 32 |
.and_then(|minor_version| minor_version.parse().ok()) |
| 33 |
}) |
| 34 |
}) |
| 35 |
} |