-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysutils/dua-cli: make this build on aarch64eb.
This is done by avoiding attempts at using neon / SIMD in big-endian mode by patching some of the vendored crates. Neon / SIMD is known to be problematical in rust, ref. rust-lang/stdarch#1484, even though the CPU itself supports it. I've also tried reporting the memchr fixes upstream, ref. BurntSushi/memchr#162 So far not yet adopted. Zerocopy has also received a pull request: google/zerocopy#1795
- Loading branch information
Showing
6 changed files
with
266 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
sysutils/dua-cli/patches/patch-.._vendor_memchr-2.7.4_src_arch_aarch64_mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$NetBSD: patch-.._vendor_memchr-2.7.4_src_arch_aarch64_mod.rs,v 1.1 2024/10/02 17:49:02 he Exp $ | ||
|
||
Make this build on big-endian aarch64. | ||
|
||
--- ../vendor/memchr-2.7.4/src/arch/aarch64/mod.rs.orig 2024-10-01 22:42:20.721140485 +0000 | ||
+++ ../vendor/memchr-2.7.4/src/arch/aarch64/mod.rs | ||
@@ -2,6 +2,8 @@ | ||
Vector algorithms for the `aarch64` target. | ||
*/ | ||
|
||
+#[cfg(target_endian = "little")] | ||
pub mod neon; | ||
|
||
+#[cfg(target_endian = "little")] | ||
pub(crate) mod memchr; |
128 changes: 128 additions & 0 deletions
128
sysutils/dua-cli/patches/patch-.._vendor_memchr-2.7.4_src_memchr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
$NetBSD: patch-.._vendor_memchr-2.7.4_src_memchr.rs,v 1.1 2024/10/02 17:49:02 he Exp $ | ||
|
||
Make this build on big-endian aarch64. | ||
|
||
--- ../vendor/memchr-2.7.4/src/memchr.rs.orig 2024-10-01 22:37:24.143489357 +0000 | ||
+++ ../vendor/memchr-2.7.4/src/memchr.rs | ||
@@ -518,14 +518,14 @@ unsafe fn memchr_raw( | ||
{ | ||
crate::arch::wasm32::memchr::memchr_raw(needle, start, end) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memchr_raw(needle, start, end) | ||
} | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::One::new(needle).find_raw(start, end) | ||
@@ -551,14 +551,14 @@ unsafe fn memrchr_raw( | ||
{ | ||
crate::arch::wasm32::memchr::memrchr_raw(needle, start, end) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memrchr_raw(needle, start, end) | ||
} | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::One::new(needle).rfind_raw(start, end) | ||
@@ -585,14 +585,14 @@ unsafe fn memchr2_raw( | ||
{ | ||
crate::arch::wasm32::memchr::memchr2_raw(needle1, needle2, start, end) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memchr2_raw(needle1, needle2, start, end) | ||
} | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::Two::new(needle1, needle2) | ||
@@ -620,7 +620,7 @@ unsafe fn memrchr2_raw( | ||
{ | ||
crate::arch::wasm32::memchr::memrchr2_raw(needle1, needle2, start, end) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memrchr2_raw( | ||
needle1, needle2, start, end, | ||
@@ -629,7 +629,7 @@ unsafe fn memrchr2_raw( | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::Two::new(needle1, needle2) | ||
@@ -662,7 +662,7 @@ unsafe fn memchr3_raw( | ||
needle1, needle2, needle3, start, end, | ||
) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memchr3_raw( | ||
needle1, needle2, needle3, start, end, | ||
@@ -671,7 +671,7 @@ unsafe fn memchr3_raw( | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::Three::new(needle1, needle2, needle3) | ||
@@ -704,7 +704,7 @@ unsafe fn memrchr3_raw( | ||
needle1, needle2, needle3, start, end, | ||
) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::memrchr3_raw( | ||
needle1, needle2, needle3, start, end, | ||
@@ -713,7 +713,7 @@ unsafe fn memrchr3_raw( | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::Three::new(needle1, needle2, needle3) | ||
@@ -736,14 +736,14 @@ unsafe fn count_raw(needle: u8, start: * | ||
{ | ||
crate::arch::wasm32::memchr::count_raw(needle, start, end) | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
crate::arch::aarch64::memchr::count_raw(needle, start, end) | ||
} | ||
#[cfg(not(any( | ||
target_arch = "x86_64", | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
crate::arch::all::memchr::One::new(needle).count_raw(start, end) |
78 changes: 78 additions & 0 deletions
78
sysutils/dua-cli/patches/patch-.._vendor_memchr-2.7.4_src_memmem_searcher.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
$NetBSD: patch-.._vendor_memchr-2.7.4_src_memmem_searcher.rs,v 1.1 2024/10/02 17:49:02 he Exp $ | ||
|
||
Make this build on big-endian aarch64. | ||
|
||
--- ../vendor/memchr-2.7.4/src/memmem/searcher.rs.orig 2024-10-01 22:46:23.364125524 +0000 | ||
+++ ../vendor/memchr-2.7.4/src/memmem/searcher.rs | ||
@@ -3,7 +3,7 @@ use crate::arch::all::{ | ||
rabinkarp, twoway, | ||
}; | ||
|
||
-#[cfg(target_arch = "aarch64")] | ||
+#[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
use crate::arch::aarch64::neon::packedpair as neon; | ||
#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))] | ||
use crate::arch::wasm32::simd128::packedpair as simd128; | ||
@@ -129,7 +129,7 @@ impl Searcher { | ||
Searcher::twoway(needle, rabinkarp, prestrat) | ||
} | ||
} | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
{ | ||
if let Some(pp) = neon::Finder::with_pair(needle, pair) { | ||
if do_packed_search(needle) { | ||
@@ -152,7 +152,7 @@ impl Searcher { | ||
#[cfg(not(any( | ||
all(target_arch = "x86_64", target_feature = "sse2"), | ||
all(target_arch = "wasm32", target_feature = "simd128"), | ||
- target_arch = "aarch64" | ||
+ all(target_arch = "aarch64", target_endian = "little") | ||
)))] | ||
{ | ||
if prefilter.is_none() { | ||
@@ -253,7 +253,7 @@ union SearcherKind { | ||
avx2: crate::arch::x86_64::avx2::packedpair::Finder, | ||
#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))] | ||
simd128: crate::arch::wasm32::simd128::packedpair::Finder, | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
neon: crate::arch::aarch64::neon::packedpair::Finder, | ||
} | ||
|
||
@@ -421,7 +421,7 @@ unsafe fn searcher_kind_simd128( | ||
/// # Safety | ||
/// | ||
/// Callers must ensure that the `searcher.kind.neon` union field is set. | ||
-#[cfg(target_arch = "aarch64")] | ||
+#[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
unsafe fn searcher_kind_neon( | ||
searcher: &Searcher, | ||
_prestate: &mut PrefilterState, | ||
@@ -686,7 +686,7 @@ impl Prefilter { | ||
} | ||
|
||
/// Return a prefilter using a aarch64 neon vector algorithm. | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
#[inline] | ||
fn neon(finder: neon::Finder, needle: &[u8]) -> Prefilter { | ||
trace!("building aarch64 neon prefilter"); | ||
@@ -763,7 +763,7 @@ union PrefilterKind { | ||
avx2: crate::arch::x86_64::avx2::packedpair::Finder, | ||
#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))] | ||
simd128: crate::arch::wasm32::simd128::packedpair::Finder, | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
neon: crate::arch::aarch64::neon::packedpair::Finder, | ||
} | ||
|
||
@@ -852,7 +852,7 @@ unsafe fn prefilter_kind_simd128( | ||
/// # Safety | ||
/// | ||
/// Callers must ensure that the `strat.kind.neon` union field is set. | ||
-#[cfg(target_arch = "aarch64")] | ||
+#[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
unsafe fn prefilter_kind_neon( | ||
strat: &Prefilter, | ||
haystack: &[u8], |
15 changes: 15 additions & 0 deletions
15
sysutils/dua-cli/patches/patch-.._vendor_memchr-2.7.4_src_vector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$NetBSD: patch-.._vendor_memchr-2.7.4_src_vector.rs,v 1.1 2024/10/02 17:49:02 he Exp $ | ||
|
||
Make this build on big-endian aarch64. | ||
|
||
--- ../vendor/memchr-2.7.4/src/vector.rs.orig 2024-10-01 22:43:45.510956667 +0000 | ||
+++ ../vendor/memchr-2.7.4/src/vector.rs | ||
@@ -289,7 +289,7 @@ mod x86avx2 { | ||
} | ||
} | ||
|
||
-#[cfg(target_arch = "aarch64")] | ||
+#[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
mod aarch64neon { | ||
use core::arch::aarch64::*; | ||
|
24 changes: 24 additions & 0 deletions
24
sysutils/dua-cli/patches/patch-.._vendor_zerocopy-0.7.35_src_lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$NetBSD: patch-.._vendor_zerocopy-0.7.35_src_lib.rs,v 1.1 2024/10/02 17:49:02 he Exp $ | ||
|
||
Make this build on big-endian aarch64. | ||
|
||
--- ../vendor/zerocopy-0.7.35/src/lib.rs.orig 2024-10-01 22:31:58.027833427 +0000 | ||
+++ ../vendor/zerocopy-0.7.35/src/lib.rs | ||
@@ -3736,7 +3736,7 @@ mod simd { | ||
powerpc64, powerpc64, vector_bool_long, vector_double, vector_signed_long, vector_unsigned_long | ||
); | ||
simd_arch_mod!( | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
aarch64, aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t, | ||
int8x8x3_t, int8x8x4_t, int8x16_t, int8x16x2_t, int8x16x3_t, int8x16x4_t, int16x4_t, | ||
int16x8_t, int32x2_t, int32x4_t, int64x1_t, int64x2_t, poly8x8_t, poly8x8x2_t, poly8x8x3_t, | ||
@@ -8026,7 +8026,7 @@ mod tests { | ||
vector_signed_long, | ||
vector_unsigned_long | ||
); | ||
- #[cfg(target_arch = "aarch64")] | ||
+ #[cfg(all(target_arch = "aarch64", target_endian = "little"))] | ||
#[rustfmt::skip] | ||
test_simd_arch_mod!( | ||
aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t, |