about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/main.yml10
-rw-r--r--build_system/build_sysroot.rs8
-rw-r--r--build_system/tests.rs9
3 files changed, 23 insertions, 4 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 625084e3b08..babadc4d467 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -42,6 +42,10 @@ jobs:
           - os: ubuntu-latest
             env:
               TARGET_TRIPLE: aarch64-unknown-linux-gnu
+          # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
+          - os: ubuntu-latest
+            env:
+              TARGET_TRIPLE: s390x-unknown-linux-gnu
 
     steps:
     - uses: actions/checkout@v3
@@ -79,6 +83,12 @@ jobs:
         sudo apt-get update
         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
 
+    - name: Install s390x toolchain and qemu
+      if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
+      run: |
+        sudo apt-get update
+        sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
+
     - name: Prepare dependencies
       run: |
         git config --global user.email "user@example.com"
diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs
index 35c972e6b38..cbbf09b9b97 100644
--- a/build_system/build_sysroot.rs
+++ b/build_system/build_sysroot.rs
@@ -119,10 +119,10 @@ pub(crate) fn build_sysroot(
 
             if host_triple != target_triple {
                 // When cross-compiling it is often necessary to manually pick the right linker
-                let linker = if target_triple == "aarch64-unknown-linux-gnu" {
-                    Some("aarch64-linux-gnu-gcc")
-                } else {
-                    None
+                let linker = match target_triple {
+                    "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu-gcc"),
+                    "s390x-unknown-linux-gnu" => Some("s390x-linux-gnu-gcc"),
+                    _ => None,
                 };
                 build_clif_sysroot_for_triple(
                     dirs,
diff --git a/build_system/tests.rs b/build_system/tests.rs
index 99a8e5b3220..1c372736ed6 100644
--- a/build_system/tests.rs
+++ b/build_system/tests.rs
@@ -526,6 +526,15 @@ impl TestRunner {
                         "/usr/aarch64-linux-gnu".to_owned(),
                     ];
                 }
+                "s390x-unknown-linux-gnu" => {
+                    // We are cross-compiling for s390x. Use the correct linker and run tests in qemu.
+                    rustflags = format!("-Clinker=s390x-linux-gnu-gcc{}", rustflags);
+                    runner = vec![
+                        "qemu-s390x".to_owned(),
+                        "-L".to_owned(),
+                        "/usr/s390x-linux-gnu".to_owned(),
+                    ];
+                }
                 "x86_64-pc-windows-gnu" => {
                     // We are cross-compiling for Windows. Run tests in wine.
                     runner = vec!["wine".to_owned()];