Repository: mozilla/cbindgen (language: rust)

Issue:
Adding arm64 builds in releases?
Hi!

Would you mind adding arm64 ubuntu builds in releases?

Regards


Discussion / hints:
I'd take a patch, as I don't have a machine to test them :)

Fix patch:
diff --git a/.github/workflows/cbindgen.yml b/.github/workflows/cbindgen.yml
index b36c2511b..090dc64ea 100644
--- a/.github/workflows/cbindgen.yml
+++ b/.github/workflows/cbindgen.yml
@@ -14,7 +14,7 @@ on:
 jobs:
   rustfmt-clippy:
 
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-24.04
 
     steps:
     - uses: actions/checkout@v3
@@ -41,14 +41,44 @@ jobs:
         cargo +${{steps.msrv.outputs.name}} test nonexistent-test --verbose
 
   build:
+    runs-on: ubuntu-24.04
 
-    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        arch: [amd64, arm64]
+        include:
+          - arch: arm64
+            env:
+              CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
+              CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc-11
 
     steps:
     - uses: actions/checkout@v3
 
+    - name: Setup environment variables for cross compiling
+      if: matrix.arch != 'amd64'
+      run: |
+        echo CARGO_BUILD_TARGET=${{matrix.env.CARGO_BUILD_TARGET}} >> ${GITHUB_ENV}
+        echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{matrix.env.CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER}} >> ${GITHUB_ENV}
+
+    - name: Install cross linker and emulator
+      if: matrix.arch == 'arm64'
+      run: |
+        # Only works on noble (and later?)
+        sudo sed -i '/^Components/a Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources
+        echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc) main multiverse universe" | sudo tee -a /etc/apt/sources.list.d/ports.list
+        echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-security main multiverse universe" | sudo tee -a  /etc/apt/sources.list.d/ports.list
+        echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-backports main multiverse universe" | sudo tee -a  /etc/apt/sources.list.d/ports.list
+        echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-updates main multiverse universe" | sudo tee -a  /etc/apt/sources.list.d/ports.list
+
+        sudo dpkg --add-architecture arm64
+        sudo apt-get update
+        sudo apt-get install -y qemu-user gcc-11-aarch64-linux-gnu libc6:arm64
+
     - name: Install stable Rust
       uses: dtolnay/rust-toolchain@stable
+      with:
+        targets: ${{matrix.env.CARGO_BUILD_TARGET}}
 
     - name: Install Python
       uses: actions/setup-python@v4
@@ -77,6 +107,8 @@ jobs:
 
     - name: Install nightly Rust
       uses: dtolnay/rust-toolchain@nightly
+      with:
+        targets: ${{matrix.env.CARGO_BUILD_TARGET}}
 
     - name: Test
       env:


Test patch: