Skip to content

Commit 6e9048b

Browse files
committed
override run-time detection on mips msa tests
1 parent 4f3e060 commit 6e9048b

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

crates/simd-test-macro/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ pub fn simd_test(
5757
.expect(&format!("failed to parse name: {}", name.clone().as_str()));
5858

5959
let target = env::var("TARGET").expect("TARGET environment variable not set");
60+
let mut force_test = false;
6061
let macro_test = match target.split('-').next()
6162
.expect(&format!("target triple contained no \"-\": {}", target)) {
6263
"i686" | "x86_64" | "i586" => "is_x86_feature_detected",
6364
"arm" => "is_arm_feature_detected",
64-
"aarch64" => "is_aarch64_feature_detected",
65+
"aarch64" => "is_aarch64_feature_detected",
6566
"powerpc64" => "is_powerpc64_feature_detected",
66-
"mips64" | "mips64el" => "is_mips64_feature_detected",
67+
"mips64" | "mips64el" => {
68+
// On MIPS CI run-time feature detection always returns false due to
69+
// this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
70+
//
71+
// This is a workaround to force the MIPS tests to always run on CI.
72+
force_test = true;
73+
"is_mips64_feature_detected"
74+
},
6775
t => panic!("unknown target: {}", t),
6876
};
6977
let macro_test = proc_macro2::Term::intern(macro_test);
@@ -85,7 +93,7 @@ pub fn simd_test(
8593
#[allow(non_snake_case)]
8694
#[test]
8795
fn #name() {
88-
if #cfg_target_features {
96+
if #force_test | (#cfg_target_features) {
8997
return unsafe { #name() };
9098
} else {
9199
::stdsimd_test::assert_skip_test_ok(stringify!(#name));

stdsimd/arch/detect/linux/auxvec.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub fn auxv() -> Result<AuxVec, ()> {
7373
return Ok(AuxVec { hwcap });
7474
}
7575
}
76+
7677
// Targets with AT_HWCAP and AT_HWCAP2:
7778
#[cfg(any(target_arch = "arm", target_arch = "powerpc64"))] {
7879
if let Ok(hwcap2) = getauxval(AT_HWCAP2) {
@@ -104,7 +105,6 @@ fn getauxval(key: usize) -> Result<usize, ()> {
104105
"getauxval\0".as_ptr() as *const _,
105106
);
106107
if ptr.is_null() {
107-
eprintln!("getauxval was not linked");
108108
return Err(());
109109
}
110110

@@ -127,7 +127,7 @@ fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
127127
{
128128
let raw: &mut [u8; 64 * mem::size_of::<usize>()] =
129129
unsafe { mem::transmute(&mut buf) };
130-
file.read(raw).map_err(|e| { eprintln!("error reading /proc/self/auxv: {}", e); ()})?;
130+
file.read(raw).map_err(|_| ())?;
131131
}
132132
auxv_from_buf(&buf)
133133
}
@@ -168,8 +168,6 @@ fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
168168
compile_error!("this function is not implemented for this target");
169169
}
170170

171-
eprintln!("error couldn't find key AT_HWCAP in file buffer");
172-
173171
Err(())
174172
}
175173

@@ -212,6 +210,9 @@ mod tests {
212210
}
213211

214212

213+
// FIXME: on mips64 getauxval returns 0, and /proc/self/auxv
214+
// does not always contain the AT_HWCAP key under qemu.
215+
#[cfg(not(target_arch = "mips64"))]
215216
#[test]
216217
fn auxv_crate() {
217218
let v = auxv();

0 commit comments

Comments
 (0)