Skip to content

Commit 66ff371

Browse files
hsbtclaude
andcommitted
Add arm-to-x86 cross-compile matrix and generalize apt setup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 523ac58 commit 66ff371

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

.github/workflows/crosscompile.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@ permissions:
2222

2323
jobs:
2424
make:
25+
name: make (${{ matrix.host }} host on ${{ matrix.build }})
2526
strategy:
2627
matrix:
2728
include:
2829
- host: aarch64-linux-gnu
2930
arch: arm64
31+
build: x86_64-linux-gnu
32+
runs-on: ubuntu-24.04
33+
file_arch: ARM aarch64
34+
- host: x86_64-linux-gnu
35+
arch: amd64
36+
build: aarch64-linux-gnu
37+
runs-on: ubuntu-24.04-arm
38+
file_arch: x86-64
3039
fail-fast: false
3140

3241
env:
3342
GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
3443

35-
runs-on: ubuntu-24.04
44+
runs-on: ${{ matrix.runs-on }}
3645

3746
if: >-
3847
${{!(false
@@ -58,17 +67,23 @@ jobs:
5867
- name: Install cross-compilation toolchain
5968
run: |
6069
sudo dpkg --add-architecture ${{ matrix.arch }}
61-
# Restrict existing sources to amd64to avoid 404 on arm64
70+
native_arch=$(dpkg --print-architecture)
71+
# Restrict existing sources to native arch
6272
sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources
63-
sudo sed -i '/^Types:/a Architectures: amd64 i386' /etc/apt/sources.list.d/ubuntu.sources
64-
# Add arm64 sources from ports.ubuntu.com
73+
sudo sed -i "/^Types:/a Architectures: ${native_arch}" /etc/apt/sources.list.d/ubuntu.sources
74+
# Add cross-arch sources
75+
if [ "${{ matrix.arch }}" = "arm64" ]; then
76+
cross_uri="http://ports.ubuntu.com/"
77+
else
78+
cross_uri="http://archive.ubuntu.com/ubuntu/"
79+
fi
6580
printf '%s\n' \
6681
"Types: deb" \
67-
"URIs: http://ports.ubuntu.com/" \
82+
"URIs: ${cross_uri}" \
6883
"Suites: noble noble-updates noble-security" \
6984
"Components: main universe" \
7085
"Architectures: ${{ matrix.arch }}" \
71-
| sudo tee /etc/apt/sources.list.d/ports-${{ matrix.arch }}.sources
86+
| sudo tee /etc/apt/sources.list.d/cross-${{ matrix.arch }}.sources
7287
sudo apt-get update -qq
7388
sudo apt-get install --no-install-recommends -qq -y \
7489
crossbuild-essential-${{ matrix.arch }} \
@@ -92,7 +107,7 @@ jobs:
92107
run: >-
93108
../src/configure -C --disable-install-doc
94109
--prefix=/usr
95-
--build=x86_64-linux-gnu
110+
--build=${{ matrix.build }}
96111
--host=${{ matrix.host }}
97112
--with-baseruby=$PWD/../baseruby/install/bin/ruby
98113
@@ -103,7 +118,7 @@ jobs:
103118
- name: Verify cross-compiled binary
104119
run: |
105120
file install/usr/bin/ruby
106-
file install/usr/bin/ruby | grep -q '${{ matrix.host }}\|aarch64'
121+
file install/usr/bin/ruby | grep -q '${{ matrix.file_arch }}'
107122
108123
- uses: ./.github/actions/slack
109124
with:

0 commit comments

Comments
 (0)