Skip to content

Commit 8c407e0

Browse files
authored
Merge pull request #1255 from afonso360/abi-checker
Add abi-checker to y.rs and run it on CI
2 parents 57818ce + 69c6749 commit 8c407e0

File tree

7 files changed

+118
-1
lines changed

7 files changed

+118
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ perf.data.old
1919
/regex
2020
/simple-raytracer
2121
/portable-simd
22+
/abi-checker

build_system/abi_checker.rs

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use super::build_sysroot;
2+
use super::config;
3+
use super::utils::spawn_and_wait;
4+
use build_system::SysrootKind;
5+
use std::env;
6+
use std::path::Path;
7+
use std::process::Command;
8+
9+
pub(crate) fn run(
10+
channel: &str,
11+
sysroot_kind: SysrootKind,
12+
target_dir: &Path,
13+
cg_clif_build_dir: &Path,
14+
host_triple: &str,
15+
target_triple: &str,
16+
) {
17+
if !config::get_bool("testsuite.abi-checker") {
18+
eprintln!("[SKIP] abi-checker");
19+
return;
20+
}
21+
22+
if host_triple != target_triple {
23+
eprintln!("[SKIP] abi-checker (cross-compilation not supported)");
24+
return;
25+
}
26+
27+
eprintln!("Building sysroot for abi-checker");
28+
build_sysroot::build_sysroot(
29+
channel,
30+
sysroot_kind,
31+
target_dir,
32+
cg_clif_build_dir,
33+
host_triple,
34+
target_triple,
35+
);
36+
37+
eprintln!("Running abi-checker");
38+
let mut abi_checker_path = env::current_dir().unwrap();
39+
abi_checker_path.push("abi-checker");
40+
env::set_current_dir(abi_checker_path.clone()).unwrap();
41+
42+
let build_dir = abi_checker_path.parent().unwrap().join("build");
43+
let cg_clif_dylib_path = build_dir.join(if cfg!(windows) { "bin" } else { "lib" }).join(
44+
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
45+
);
46+
47+
let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
48+
49+
let mut cmd = Command::new("cargo");
50+
cmd.arg("run");
51+
cmd.arg("--target");
52+
cmd.arg(target_triple);
53+
cmd.arg("--");
54+
cmd.arg("--pairs");
55+
cmd.args(pairs);
56+
cmd.arg("--add-rustc-codegen-backend");
57+
cmd.arg(format!("cgclif:{}", cg_clif_dylib_path.display()));
58+
59+
spawn_and_wait(cmd);
60+
}

build_system/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::process;
44

55
use self::utils::is_ci;
66

7+
mod abi_checker;
78
mod build_backend;
89
mod build_sysroot;
910
mod config;
@@ -141,6 +142,15 @@ pub fn main() {
141142
&host_triple,
142143
&target_triple,
143144
);
145+
146+
abi_checker::run(
147+
channel,
148+
sysroot_kind,
149+
&target_dir,
150+
&cg_clif_build_dir,
151+
&host_triple,
152+
&target_triple,
153+
);
144154
}
145155
Command::Build => {
146156
build_sysroot::build_sysroot(

build_system/prepare.rs

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ pub(crate) fn prepare() {
1414
eprintln!("[INSTALL] hyperfine");
1515
Command::new("cargo").arg("install").arg("hyperfine").spawn().unwrap().wait().unwrap();
1616

17+
clone_repo_shallow_github(
18+
"abi-checker",
19+
"Gankra",
20+
"abi-checker",
21+
"a2232d45f202846f5c02203c9f27355360f9a2ff",
22+
);
23+
apply_patches("abi-checker", Path::new("abi-checker"));
24+
1725
clone_repo_shallow_github(
1826
"rand",
1927
"rust-random",

clean_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set -e
33

44
rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version}
55
rm -rf target/ build/ perf.data{,.old} y.bin
6-
rm -rf rand/ regex/ simple-raytracer/ portable-simd/
6+
rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/

config.txt

+2
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ test.libcore
4848
test.regex-shootout-regex-dna
4949
test.regex
5050
test.portable-simd
51+
52+
testsuite.abi-checker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 1a315ba225577dbbd1f449d9609f16f984f68708 Mon Sep 17 00:00:00 2001
2+
From: Afonso Bordado <[email protected]>
3+
Date: Fri, 12 Aug 2022 22:51:58 +0000
4+
Subject: [PATCH] Disable abi-checker tests
5+
6+
---
7+
src/report.rs | 14 ++++++++++++++
8+
1 file changed, 14 insertions(+)
9+
10+
diff --git a/src/report.rs b/src/report.rs
11+
index 7346f5e..8347762 100644
12+
--- a/src/report.rs
13+
+++ b/src/report.rs
14+
@@ -45,6 +45,20 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
15+
//
16+
// THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES
17+
18+
+ // Currently MSVC has some broken ABI issues. Furthermore, they cause
19+
+ // a STATUS_ACCESS_VIOLATION, so we can't even run them. Ensure that they compile and link.
20+
+ if cfg!(windows) && (test.test_name == "bool" || test.test_name == "ui128") {
21+
+ result.run = Link;
22+
+ result.check = Pass(Link);
23+
+ }
24+
+
25+
+ // structs is broken in the current release of cranelift for aarch64.
26+
+ // It has been fixed for cranelift 0.88: https://github.com/bytecodealliance/wasmtime/pull/4634
27+
+ if cfg!(target_arch = "aarch64") && test.test_name == "structs" {
28+
+ result.run = Link;
29+
+ result.check = Pass(Link);
30+
+ }
31+
+
32+
// END OF VENDOR RESERVED AREA
33+
//
34+
//
35+
--
36+
2.34.1

0 commit comments

Comments
 (0)