about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-08-13 08:34:55 +0200
committerGitHub <noreply@github.com>2022-08-13 08:34:55 +0200
commit8c407e0fb4ba7fc4cc50e6a6d0352ec7f94d450b (patch)
treefc0828a7f388bb97e9a1aa6b7a7264a530057eb2
parent57818ce82464e7e071418abab0f284e995cf8c44 (diff)
parent69c6749aee93ee3c5dd3b9b394eef612d48dd6cd (diff)
downloadrust-8c407e0fb4ba7fc4cc50e6a6d0352ec7f94d450b.tar.gz
rust-8c407e0fb4ba7fc4cc50e6a6d0352ec7f94d450b.zip
Merge pull request #1255 from afonso360/abi-checker
Add abi-checker to y.rs and run it on CI
-rw-r--r--.gitignore1
-rw-r--r--build_system/abi_checker.rs60
-rw-r--r--build_system/mod.rs10
-rw-r--r--build_system/prepare.rs8
-rwxr-xr-xclean_all.sh2
-rw-r--r--config.txt2
-rw-r--r--patches/0029-abi-checker-Disable-failing-tests.patch36
7 files changed, 118 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 38dd5b26063..6fd3e4443de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ perf.data.old
 /regex
 /simple-raytracer
 /portable-simd
+/abi-checker
diff --git a/build_system/abi_checker.rs b/build_system/abi_checker.rs
new file mode 100644
index 00000000000..67dbd0a38a4
--- /dev/null
+++ b/build_system/abi_checker.rs
@@ -0,0 +1,60 @@
+use super::build_sysroot;
+use super::config;
+use super::utils::spawn_and_wait;
+use build_system::SysrootKind;
+use std::env;
+use std::path::Path;
+use std::process::Command;
+
+pub(crate) fn run(
+    channel: &str,
+    sysroot_kind: SysrootKind,
+    target_dir: &Path,
+    cg_clif_build_dir: &Path,
+    host_triple: &str,
+    target_triple: &str,
+) {
+    if !config::get_bool("testsuite.abi-checker") {
+        eprintln!("[SKIP] abi-checker");
+        return;
+    }
+
+    if host_triple != target_triple {
+        eprintln!("[SKIP] abi-checker (cross-compilation not supported)");
+        return;
+    }
+
+    eprintln!("Building sysroot for abi-checker");
+    build_sysroot::build_sysroot(
+        channel,
+        sysroot_kind,
+        target_dir,
+        cg_clif_build_dir,
+        host_triple,
+        target_triple,
+    );
+
+    eprintln!("Running abi-checker");
+    let mut abi_checker_path = env::current_dir().unwrap();
+    abi_checker_path.push("abi-checker");
+    env::set_current_dir(abi_checker_path.clone()).unwrap();
+
+    let build_dir = abi_checker_path.parent().unwrap().join("build");
+    let cg_clif_dylib_path = build_dir.join(if cfg!(windows) { "bin" } else { "lib" }).join(
+        env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
+    );
+
+    let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
+
+    let mut cmd = Command::new("cargo");
+    cmd.arg("run");
+    cmd.arg("--target");
+    cmd.arg(target_triple);
+    cmd.arg("--");
+    cmd.arg("--pairs");
+    cmd.args(pairs);
+    cmd.arg("--add-rustc-codegen-backend");
+    cmd.arg(format!("cgclif:{}", cg_clif_dylib_path.display()));
+
+    spawn_and_wait(cmd);
+}
diff --git a/build_system/mod.rs b/build_system/mod.rs
index 88c4150dbba..c3706dc6f82 100644
--- a/build_system/mod.rs
+++ b/build_system/mod.rs
@@ -4,6 +4,7 @@ use std::process;
 
 use self::utils::is_ci;
 
+mod abi_checker;
 mod build_backend;
 mod build_sysroot;
 mod config;
@@ -141,6 +142,15 @@ pub fn main() {
                 &host_triple,
                 &target_triple,
             );
+
+            abi_checker::run(
+                channel,
+                sysroot_kind,
+                &target_dir,
+                &cg_clif_build_dir,
+                &host_triple,
+                &target_triple,
+            );
         }
         Command::Build => {
             build_sysroot::build_sysroot(
diff --git a/build_system/prepare.rs b/build_system/prepare.rs
index 7e0fd182d98..d23b7f00dcf 100644
--- a/build_system/prepare.rs
+++ b/build_system/prepare.rs
@@ -15,6 +15,14 @@ pub(crate) fn prepare() {
     Command::new("cargo").arg("install").arg("hyperfine").spawn().unwrap().wait().unwrap();
 
     clone_repo_shallow_github(
+        "abi-checker",
+        "Gankra",
+        "abi-checker",
+        "a2232d45f202846f5c02203c9f27355360f9a2ff",
+    );
+    apply_patches("abi-checker", Path::new("abi-checker"));
+
+    clone_repo_shallow_github(
         "rand",
         "rust-random",
         "rand",
diff --git a/clean_all.sh b/clean_all.sh
index ea1f8c1e892..62e52bd1958 100755
--- a/clean_all.sh
+++ b/clean_all.sh
@@ -3,4 +3,4 @@ set -e
 
 rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version}
 rm -rf target/ build/ perf.data{,.old} y.bin
-rm -rf rand/ regex/ simple-raytracer/ portable-simd/
+rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/
diff --git a/config.txt b/config.txt
index 5e4d230776d..2264d301d59 100644
--- a/config.txt
+++ b/config.txt
@@ -48,3 +48,5 @@ test.libcore
 test.regex-shootout-regex-dna
 test.regex
 test.portable-simd
+
+testsuite.abi-checker
diff --git a/patches/0029-abi-checker-Disable-failing-tests.patch b/patches/0029-abi-checker-Disable-failing-tests.patch
new file mode 100644
index 00000000000..526366a7598
--- /dev/null
+++ b/patches/0029-abi-checker-Disable-failing-tests.patch
@@ -0,0 +1,36 @@
+From 1a315ba225577dbbd1f449d9609f16f984f68708 Mon Sep 17 00:00:00 2001
+From: Afonso Bordado <afonso360@users.noreply.github.com>
+Date: Fri, 12 Aug 2022 22:51:58 +0000
+Subject: [PATCH] Disable abi-checker tests
+
+---
+ src/report.rs | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/src/report.rs b/src/report.rs
+index 7346f5e..8347762 100644
+--- a/src/report.rs
++++ b/src/report.rs
+@@ -45,6 +45,20 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
+     //
+     // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES
+
++    // Currently MSVC has some broken ABI issues. Furthermore, they cause
++    // a STATUS_ACCESS_VIOLATION, so we can't even run them. Ensure that they compile and link.
++    if cfg!(windows) && (test.test_name == "bool" || test.test_name == "ui128") {
++        result.run = Link;
++        result.check = Pass(Link);
++    }
++
++    // structs is broken in the current release of cranelift for aarch64.
++    // It has been fixed for cranelift 0.88: https://github.com/bytecodealliance/wasmtime/pull/4634
++    if cfg!(target_arch = "aarch64") && test.test_name == "structs" {
++        result.run = Link;
++        result.check = Pass(Link);
++    }
++
+     // END OF VENDOR RESERVED AREA
+     //
+     //
+--
+2.34.1