fix test runner for armv7

This commit is contained in:
James Barford-Evans 2025-02-11 15:36:05 +00:00 committed by Amanieu d'Antras
parent 443d1cdbf0
commit bec322f990
3 changed files with 44 additions and 25 deletions

View file

@ -226,7 +226,7 @@ impl ArgumentList {
ty = arg.to_c_type(),
name = arg.name,
load = if arg.is_simd() {
arg.ty.get_load_function(target)
arg.ty.get_load_function(armv7_p64)
} else {
"*".to_string()
},
@ -258,7 +258,7 @@ impl ArgumentList {
name = arg.name,
vals_name = arg.rust_vals_array_name(),
load = if arg.is_simd() {
arg.ty.get_load_function("__")
arg.ty.get_load_function(false)
} else {
"*".to_string()
},

View file

@ -201,10 +201,10 @@ fn main() {{
{passes}
}}
"#,
target_arch = if target.starts_with("aarch64") {
"aarch64"
} else {
target_arch = if target.contains("v7") {
"arm"
} else {
"aarch64"
},
arglists = intrinsic
.arguments
@ -226,10 +226,10 @@ fn compile_c(
cxx_toolchain_dir: Option<&str>,
) -> bool {
let flags = std::env::var("CPPFLAGS").unwrap_or("".into());
let arch_flags = if target.starts_with("aarch64") {
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
} else {
let arch_flags = if target.contains("v7") {
"-march=armv8.6-a+crypto+crc+dotprod"
} else {
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
};
let intrinsic_name = &intrinsic.name;
@ -394,7 +394,6 @@ path = "{intrinsic}/main.rs""#,
/* If there has been a linker explicitly set from the command line then
* we want to set it via setting it in the RUSTFLAGS*/
let mut rust_flags = "-Cdebuginfo=0".to_string();
let cargo_command = format!(
"cargo {toolchain} build --target {target} --release",
@ -403,12 +402,12 @@ path = "{intrinsic}/main.rs""#,
);
let mut command = Command::new("sh");
command
.current_dir("rust_programs")
.arg("-c")
.arg(cargo_command);
let mut rust_flags = "-Cdebuginfo=0".to_string();
if let Some(linker) = linker {
rust_flags.push_str(" -C linker=");
rust_flags.push_str(linker);
@ -418,6 +417,7 @@ path = "{intrinsic}/main.rs""#,
}
command.env("RUSTFLAGS", rust_flags);
println!("{:?}", command);
let output = command.output();
if let Ok(output) = output {
@ -552,8 +552,8 @@ fn main() {
std::process::exit(3);
}
if let Some(ref _toolchain) = toolchain {
if !compare_outputs(&intrinsics, &c_runner, target) {
if let Some(ref toolchain) = toolchain {
if !compare_outputs(&intrinsics, toolchain, &c_runner, target) {
std::process::exit(1)
}
}
@ -565,7 +565,12 @@ enum FailureReason {
Difference(String, String, String),
}
fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> bool {
fn compare_outputs(
intrinsics: &Vec<Intrinsic>,
toolchain: &str,
runner: &str,
target: &str,
) -> bool {
let intrinsics = intrinsics
.par_iter()
.filter_map(|intrinsic| {
@ -578,15 +583,29 @@ fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> b
))
.output();
let rust = Command::new("sh")
.arg("-c")
.arg(format!(
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
runner = runner,
target = target,
intrinsic = intrinsic.name,
))
.output();
let rust = if target != "aarch64_be-none-linux-gnu" {
Command::new("sh")
.current_dir("rust_programs")
.arg("-c")
.arg(format!(
"cargo {toolchain} run --target {target} --bin {intrinsic} --release",
intrinsic = intrinsic.name,
toolchain = toolchain,
target = target
))
.env("RUSTFLAGS", "-Cdebuginfo=0")
.output()
} else {
Command::new("sh")
.arg("-c")
.arg(format!(
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
runner = runner,
target = target,
intrinsic = intrinsic.name,
))
.output()
};
let (c, rust) = match (c, rust) {
(Ok(c), Ok(rust)) => (c, rust),

View file

@ -375,9 +375,9 @@ impl IntrinsicType {
}
/// Determines the load function for this type.
pub fn get_load_function(&self, target: &str) -> String {
pub fn get_load_function(&self, armv7_p64_workaround: bool) -> String {
match self {
IntrinsicType::Ptr { child, .. } => child.get_load_function(target),
IntrinsicType::Ptr { child, .. } => child.get_load_function(armv7_p64_workaround),
IntrinsicType::Type {
kind: k,
bit_len: Some(bl),
@ -397,7 +397,7 @@ impl IntrinsicType {
TypeKind::Int => "s",
TypeKind::Float => "f",
// The ACLE doesn't support 64-bit polynomial loads on Armv7
TypeKind::Poly => if target.starts_with("armv7") && *bl == 64 {"s"} else {"p"},
TypeKind::Poly => if armv7_p64_workaround && *bl == 64 {"s"} else {"p"},
x => todo!("get_load_function TypeKind: {:#?}", x),
},
size = bl,