Skip to content

Commit 16937a2

Browse files
authored
use stable aarch64 intrinsics (#50)
1 parent 295b505 commit 16937a2

5 files changed

Lines changed: 33 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
branches:
99
- master
1010

11-
env:
12-
MSRV: "1.63.0"
13-
1411
jobs:
1512
stable:
1613
name: stable
@@ -51,8 +48,11 @@ jobs:
5148
runs-on: ubuntu-latest
5249
steps:
5350
- uses: actions/checkout@v4
51+
- name: Get MSRV from Cargo.toml
52+
id: msrv
53+
run: echo "version=$(grep '^rust-version' Cargo.toml | sed 's/rust-version = "\(.*\)"/\1/')" >> $GITHUB_OUTPUT
5454
- name: Install Rust
55-
run: rustup update $MSRV && rustup default $MSRV
55+
run: rustup update ${{ steps.msrv.outputs.version }} && rustup default ${{ steps.msrv.outputs.version }}
5656
- name: Test in debug mode
5757
run: cargo test --no-fail-fast
5858
- name: Test in release mode

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repository = "https://github.com/srijs/rust-crc32fast"
1212
readme = "README.md"
1313
keywords = ["hash", "crc", "crc32", "simd", "fast"]
1414
categories = ["algorithms", "no-std"]
15+
rust-version = "1.63"
1516

1617
[dependencies]
1718
cfg-if = "1.0"

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ Note: Because runtime CPU feature detection requires OS support, the specialized
7373
This feature flag enables unstable features that are only available on the `nightly` channel. Keep in mind that when enabling this feature flag, you
7474
might experience breaking changes when updating compiler versions.
7575

76-
Currently, enabling this feature flag will make the optimized `aarch64` implementation available.
77-
7876
## License
7977

8078
This project is licensed under either of

build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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-cfg=stable_arm_crc32_intrinsics");
9+
println!("cargo:rustc-check-cfg=cfg(stable_arm_crc32_intrinsics)");
10+
}
11+
}
12+
}
13+
14+
fn minor_rustc_version() -> Option<u32> {
15+
Command::new(env::var_os("RUSTC")?)
16+
.arg("--version")
17+
.output()
18+
.ok()
19+
.and_then(|output| {
20+
std::str::from_utf8(&output.stdout).ok().and_then(|output| {
21+
output
22+
.split('.')
23+
.nth(1)
24+
.and_then(|minor_version| minor_version.parse().ok())
25+
})
26+
})
27+
}

src/specialized/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cfg_if! {
55
))] {
66
mod pclmulqdq;
77
pub use self::pclmulqdq::State;
8-
} else if #[cfg(all(feature = "nightly", target_arch = "aarch64"))] {
8+
} else if #[cfg(all(stable_arm_crc32_intrinsics, target_arch = "aarch64"))] {
99
mod aarch64;
1010
pub use self::aarch64::State;
1111
} else {

0 commit comments

Comments
 (0)