diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10b6526 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ahash-0.7.6.crate diff --git a/ahash-fix-metadata-auto.diff b/ahash-fix-metadata-auto.diff new file mode 100644 index 0000000..c88dd79 --- /dev/null +++ b/ahash-fix-metadata-auto.diff @@ -0,0 +1,22 @@ +--- ahash-0.7.6/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ ahash-0.7.6/Cargo.toml 1970-01-01T00:00:01+00:00 +@@ -90,7 +90,7 @@ + version = "0.9" + + [features] +-compile-time-rng = ["const-random"] ++compile-time-rng = [] + default = ["std"] + std = [] + [target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.const-random] +@@ -107,10 +107,3 @@ + version = "1.8" + features = ["alloc"] + default-features = false +-[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.const-random] +-version = "0.1.12" +-optional = true +- +-[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.serde] +-version = "1.0.117" +-optional = true diff --git a/ahash-fix-metadata.diff b/ahash-fix-metadata.diff new file mode 100644 index 0000000..9f25fcb --- /dev/null +++ b/ahash-fix-metadata.diff @@ -0,0 +1,11 @@ +--- ahash-0.7.6/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ ahash-0.7.6/Cargo.toml 2022-12-15T14:59:12.837183+00:00 +@@ -63,8 +63,6 @@ + name = "map" + path = "tests/map_tests.rs" + harness = false +-[dev-dependencies.criterion] +-version = "0.3.2" + + [dev-dependencies.fnv] + version = "1.0.5" diff --git a/ahash-no-criterion.diff b/ahash-no-criterion.diff new file mode 100644 index 0000000..4f8f425 --- /dev/null +++ b/ahash-no-criterion.diff @@ -0,0 +1,183 @@ +--- a/tests/map_tests.rs ++++ b/tests/map_tests.rs +@@ -1,6 +1,5 @@ + use std::hash::{BuildHasher, Hash, Hasher}; + +-use criterion::*; + use fxhash::FxHasher; + + use ahash::{AHasher, CallHasher, RandomState}; +@@ -188,16 +187,3 @@ fn fxhash_vec(b: &Vec) -> u6 + } + total + } +- +-fn bench_ahash_words(c: &mut Criterion) { +- let words = gen_word_pairs(); +- c.bench_function("aes_words", |b| b.iter(|| black_box(ahash_vec(&words)))); +-} +- +-fn bench_fx_words(c: &mut Criterion) { +- let words = gen_word_pairs(); +- c.bench_function("fx_words", |b| b.iter(|| black_box(fxhash_vec(&words)))); +-} +- +-criterion_main!(benches); +-criterion_group!(benches, bench_ahash_words, bench_fx_words,); +--- a/tests/bench.rs ++++ /dev/null +@@ -1,154 +0,0 @@ +-use ahash::{CallHasher, RandomState}; +-use criterion::*; +-use fxhash::FxHasher; +-use std::collections::hash_map::DefaultHasher; +-use std::hash::{Hash, Hasher}; +- +-#[cfg(any( +- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), +- all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "crypto", not(miri), feature = "stdsimd") +-))] +-fn aeshash(b: &H) -> u64 { +- let build_hasher = RandomState::with_seeds(1, 2, 3, 4); +- H::get_hash(b, &build_hasher) +-} +-#[cfg(not(any( +- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), +- all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "crypto", not(miri), feature = "stdsimd") +-)))] +-fn aeshash(_b: &H) -> u64 { +- panic!("aes must be enabled") +-} +- +-#[cfg(not(any( +- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), +- all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "crypto", not(miri), feature = "stdsimd") +-)))] +-fn fallbackhash(b: &H) -> u64 { +- let build_hasher = RandomState::with_seeds(1, 2, 3, 4); +- H::get_hash(b, &build_hasher) +-} +-#[cfg(any( +- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), +- all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "crypto", not(miri), feature = "stdsimd") +-))] +-fn fallbackhash(_b: &H) -> u64 { +- panic!("aes must be disabled") +-} +- +-fn fnvhash(b: &H) -> u64 { +- let mut hasher = fnv::FnvHasher::default(); +- b.hash(&mut hasher); +- hasher.finish() +-} +- +-fn siphash(b: &H) -> u64 { +- let mut hasher = DefaultHasher::default(); +- b.hash(&mut hasher); +- hasher.finish() +-} +- +-fn fxhash(b: &H) -> u64 { +- let mut hasher = FxHasher::default(); +- b.hash(&mut hasher); +- hasher.finish() +-} +- +-fn seahash(b: &H) -> u64 { +- let mut hasher = seahash::SeaHasher::default(); +- b.hash(&mut hasher); +- hasher.finish() +-} +- +-const STRING_LENGTHS: [u32; 12] = [1, 3, 4, 7, 8, 15, 16, 24, 33, 68, 132, 1024]; +- +-fn gen_strings() -> Vec { +- STRING_LENGTHS +- .iter() +- .map(|len| { +- let mut string = String::default(); +- for pos in 1..=*len { +- let c = (48 + (pos % 10) as u8) as char; +- string.push(c); +- } +- string +- }) +- .collect() +-} +- +-const U8_VALUE: u8 = 123; +-const U16_VALUE: u16 = 1234; +-const U32_VALUE: u32 = 12345678; +-const U64_VALUE: u64 = 1234567890123456; +-const U128_VALUE: u128 = 12345678901234567890123456789012; +- +-fn bench_ahash(c: &mut Criterion) { +- let mut group = c.benchmark_group("aeshash"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(aeshash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(aeshash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(aeshash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(aeshash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(aeshash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(aeshash(s)))); +-} +- +-fn bench_fallback(c: &mut Criterion) { +- let mut group = c.benchmark_group("fallback"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fallbackhash(s)))); +-} +- +-fn bench_fx(c: &mut Criterion) { +- let mut group = c.benchmark_group("fx"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fxhash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fxhash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fxhash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fxhash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fxhash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fxhash(s)))); +-} +- +-fn bench_fnv(c: &mut Criterion) { +- let mut group = c.benchmark_group("fnv"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fnvhash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fnvhash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fnvhash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fnvhash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fnvhash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fnvhash(s)))); +-} +- +-fn bench_sea(c: &mut Criterion) { +- let mut group = c.benchmark_group("sea"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(seahash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(seahash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(seahash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(seahash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(seahash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(seahash(s)))); +-} +- +-fn bench_sip(c: &mut Criterion) { +- let mut group = c.benchmark_group("sip"); +- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(siphash(s)))); +- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(siphash(s)))); +- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(siphash(s)))); +- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(siphash(s)))); +- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(siphash(s)))); +- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(siphash(s)))); +-} +- +-criterion_main!(benches); +-criterion_group!( +- benches, +- bench_ahash, +- bench_fallback, +- bench_fx, +- bench_fnv, +- bench_sea, +- bench_sip +-); diff --git a/rust-ahash0.7.spec b/rust-ahash0.7.spec new file mode 100644 index 0000000..0fc92c0 --- /dev/null +++ b/rust-ahash0.7.spec @@ -0,0 +1,125 @@ +# Generated by rust2rpm 23 +%bcond_without check +%global debug_package %{nil} + +%global crate ahash + +Name: rust-ahash0.7 +Version: 0.7.6 +Release: %autorelease +Summary: Non-cryptographic hash function using AES-NI for high performance + +License: MIT OR Apache-2.0 +URL: https://crates.io/crates/ahash +Source: %{crates_source} +# Automatically generated patch to strip foreign dependencies +Patch: ahash-fix-metadata-auto.diff +# Manually created patch for downstream crate metadata changes +# - remove criterion dependency +Patch: ahash-fix-metadata.diff +# Remove benchmark tests that use criterion +Patch: ahash-no-criterion.diff + +BuildRequires: rust-packaging >= 21 + +%global _description %{expand: +Non-cryptographic hash function using AES-NI for high performance.} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch + +%description devel %{_description} + +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%files devel +%license %{crate_instdir}/LICENSE-APACHE +%license %{crate_instdir}/LICENSE-MIT +%doc %{crate_instdir}/FAQ.md +%doc %{crate_instdir}/README.md +%{crate_instdir}/ + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel %{_description} + +This package contains library source intended for building other packages which +use the "default" feature of the "%{crate}" crate. + +%files -n %{name}+default-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+compile-time-rng-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+compile-time-rng-devel %{_description} + +This package contains library source intended for building other packages which +use the "compile-time-rng" feature of the "%{crate}" crate. + +%files -n %{name}+compile-time-rng-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+const-random-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+const-random-devel %{_description} + +This package contains library source intended for building other packages which +use the "const-random" feature of the "%{crate}" crate. + +%files -n %{name}+const-random-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+serde-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+serde-devel %{_description} + +This package contains library source intended for building other packages which +use the "serde" feature of the "%{crate}" crate. + +%files -n %{name}+serde-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+std-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+std-devel %{_description} + +This package contains library source intended for building other packages which +use the "std" feature of the "%{crate}" crate. + +%files -n %{name}+std-devel +%ghost %{crate_instdir}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p1 +%cargo_prep + +%generate_buildrequires +%cargo_generate_buildrequires + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..a6e8233 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (ahash-0.7.6.crate) = 61354688b6fb096359faefb6f34be958cd2215d56b88c22c737d24183eaad433f811bc9e64f927e4852c87d2799c22fda82b55cfbef2ed6357ff74f0c4ffec68