Skip to content

Commit 3b49a07

Browse files
committed
fix test runner for armv7
1 parent 1fe46bd commit 3b49a07

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

Diff for: crates/intrinsic-test/src/argument.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl ArgumentList {
226226
ty = arg.to_c_type(),
227227
name = arg.name,
228228
load = if arg.is_simd() {
229-
arg.ty.get_load_function(target)
229+
arg.ty.get_load_function(armv7_p64)
230230
} else {
231231
"*".to_string()
232232
},
@@ -258,7 +258,7 @@ impl ArgumentList {
258258
name = arg.name,
259259
vals_name = arg.rust_vals_array_name(),
260260
load = if arg.is_simd() {
261-
arg.ty.get_load_function("__")
261+
arg.ty.get_load_function(false)
262262
} else {
263263
"*".to_string()
264264
},

Diff for: crates/intrinsic-test/src/main.rs

+39-20
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ fn main() {{
201201
{passes}
202202
}}
203203
"#,
204-
target_arch = if target.starts_with("aarch64") {
205-
"aarch64"
206-
} else {
204+
target_arch = if target.contains("v7") {
207205
"arm"
206+
} else {
207+
"aarch64"
208208
},
209209
arglists = intrinsic
210210
.arguments
@@ -226,10 +226,10 @@ fn compile_c(
226226
cxx_toolchain_dir: Option<&str>,
227227
) -> bool {
228228
let flags = std::env::var("CPPFLAGS").unwrap_or("".into());
229-
let arch_flags = if target.starts_with("aarch64") {
230-
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
231-
} else {
229+
let arch_flags = if target.contains("v7") {
232230
"-march=armv8.6-a+crypto+crc+dotprod"
231+
} else {
232+
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
233233
};
234234

235235
let intrinsic_name = &intrinsic.name;
@@ -394,7 +394,6 @@ path = "{intrinsic}/main.rs""#,
394394

395395
/* If there has been a linker explicitly set from the command line then
396396
* we want to set it via setting it in the RUSTFLAGS*/
397-
let mut rust_flags = "-Cdebuginfo=0".to_string();
398397

399398
let cargo_command = format!(
400399
"cargo {toolchain} build --target {target} --release",
@@ -403,12 +402,12 @@ path = "{intrinsic}/main.rs""#,
403402
);
404403

405404
let mut command = Command::new("sh");
406-
407405
command
408406
.current_dir("rust_programs")
409407
.arg("-c")
410408
.arg(cargo_command);
411409

410+
let mut rust_flags = "-Cdebuginfo=0".to_string();
412411
if let Some(linker) = linker {
413412
rust_flags.push_str(" -C linker=");
414413
rust_flags.push_str(linker);
@@ -418,6 +417,7 @@ path = "{intrinsic}/main.rs""#,
418417
}
419418

420419
command.env("RUSTFLAGS", rust_flags);
420+
println!("{:?}", command);
421421
let output = command.output();
422422

423423
if let Ok(output) = output {
@@ -552,8 +552,8 @@ fn main() {
552552
std::process::exit(3);
553553
}
554554

555-
if let Some(ref _toolchain) = toolchain {
556-
if !compare_outputs(&intrinsics, &c_runner, target) {
555+
if let Some(ref toolchain) = toolchain {
556+
if !compare_outputs(&intrinsics, toolchain, &c_runner, target) {
557557
std::process::exit(1)
558558
}
559559
}
@@ -565,7 +565,12 @@ enum FailureReason {
565565
Difference(String, String, String),
566566
}
567567

568-
fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> bool {
568+
fn compare_outputs(
569+
intrinsics: &Vec<Intrinsic>,
570+
toolchain: &str,
571+
runner: &str,
572+
target: &str,
573+
) -> bool {
569574
let intrinsics = intrinsics
570575
.par_iter()
571576
.filter_map(|intrinsic| {
@@ -578,15 +583,29 @@ fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> b
578583
))
579584
.output();
580585

581-
let rust = Command::new("sh")
582-
.arg("-c")
583-
.arg(format!(
584-
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
585-
runner = runner,
586-
target = target,
587-
intrinsic = intrinsic.name,
588-
))
589-
.output();
586+
let rust = if target != "aarch64_be-none-linux-gnu" {
587+
Command::new("sh")
588+
.current_dir("rust_programs")
589+
.arg("-c")
590+
.arg(format!(
591+
"cargo {toolchain} run --target {target} --bin {intrinsic} --release",
592+
intrinsic = intrinsic.name,
593+
toolchain = toolchain,
594+
target = target
595+
))
596+
.env("RUSTFLAGS", "-Cdebuginfo=0")
597+
.output()
598+
} else {
599+
Command::new("sh")
600+
.arg("-c")
601+
.arg(format!(
602+
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
603+
runner = runner,
604+
target = target,
605+
intrinsic = intrinsic.name,
606+
))
607+
.output()
608+
};
590609

591610
let (c, rust) = match (c, rust) {
592611
(Ok(c), Ok(rust)) => (c, rust),

Diff for: crates/intrinsic-test/src/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ impl IntrinsicType {
375375
}
376376

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

0 commit comments

Comments
 (0)