Skip to content

Commit e7fb793

Browse files
committed
Fix: use native ARM runners, cross-compile Linux ARM64
1 parent 8f4123f commit e7fb793

1 file changed

Lines changed: 41 additions & 11 deletions

File tree

.github/workflows/rust.yml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,42 @@ jobs:
3030
fail-fast: false # Continue other builds if one fails
3131
matrix:
3232
include:
33-
# Windows
33+
# Windows x64 (native)
3434
- os: windows-latest
3535
target: x86_64-pc-windows-msvc
3636
artifact_name: symulacja_fali.exe
3737
asset_name: symulacja_fali-windows-x64.exe
38-
- os: windows-latest
38+
cross: false
39+
# Windows ARM64 (native)
40+
- os: windows-11-arm
3941
target: aarch64-pc-windows-msvc
4042
artifact_name: symulacja_fali.exe
4143
asset_name: symulacja_fali-windows-arm64.exe
42-
# Linux
44+
cross: false
45+
# Linux x64 (native)
4346
- os: ubuntu-latest
4447
target: x86_64-unknown-linux-gnu
4548
artifact_name: symulacja_fali
4649
asset_name: symulacja_fali-linux-x64
47-
- os: ubuntu-24.04-arm
50+
cross: false
51+
# Linux ARM64 (cross-compile from x64)
52+
- os: ubuntu-latest
4853
target: aarch64-unknown-linux-gnu
4954
artifact_name: symulacja_fali
5055
asset_name: symulacja_fali-linux-arm64
51-
# macOS
56+
cross: true
57+
# macOS x64 (native)
5258
- os: macos-latest
5359
target: x86_64-apple-darwin
5460
artifact_name: symulacja_fali
5561
asset_name: symulacja_fali-macos-x64
62+
cross: false
63+
# macOS ARM64 (cross-compile, macOS runners support both)
5664
- os: macos-latest
5765
target: aarch64-apple-darwin
5866
artifact_name: symulacja_fali
5967
asset_name: symulacja_fali-macos-arm64
68+
cross: false
6069

6170
steps:
6271
- name: Checkout code
@@ -86,24 +95,45 @@ jobs:
8695
${{ runner.os }}-${{ matrix.target }}-cargo-build-
8796
8897
- name: Install dependencies (Ubuntu x64)
89-
if: matrix.os == 'ubuntu-latest'
98+
if: matrix.os == 'ubuntu-latest' && !matrix.cross
9099
run: |
91100
sudo apt-get update
92101
sudo apt-get install -y libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
93102
94-
- name: Install dependencies (Ubuntu ARM64)
95-
if: matrix.os == 'ubuntu-24.04-arm'
103+
- name: Install cross-compilation dependencies (Ubuntu ARM64)
104+
if: matrix.cross && matrix.target == 'aarch64-unknown-linux-gnu'
96105
run: |
97106
sudo apt-get update
98-
sudo apt-get install -y libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
107+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
108+
sudo dpkg --add-architecture arm64
109+
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
110+
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
111+
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
112+
sudo apt-get update
113+
sudo apt-get install -y libxcb-render0-dev:arm64 libxcb-shape0-dev:arm64 libxcb-xfixes0-dev:arm64 libxkbcommon-dev:arm64 libssl-dev:arm64
114+
115+
- name: Set up cross-compilation environment
116+
if: matrix.cross && matrix.target == 'aarch64-unknown-linux-gnu'
117+
run: |
118+
mkdir -p .cargo
119+
echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml
120+
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
121+
echo '' >> .cargo/config.toml
122+
echo '[env]' >> .cargo/config.toml
123+
echo 'PKG_CONFIG_PATH = "/usr/lib/aarch64-linux-gnu/pkgconfig"' >> .cargo/config.toml
124+
echo 'PKG_CONFIG_ALLOW_CROSS = "1"' >> .cargo/config.toml
99125
100126
- name: Build
101127
run: cargo build --release --target ${{ matrix.target }}
102128

103-
- name: Strip binary (Linux/macOS)
104-
if: runner.os != 'Windows'
129+
- name: Strip binary (Linux x64/macOS)
130+
if: runner.os != 'Windows' && !matrix.cross
105131
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
106132

133+
- name: Strip binary (Linux ARM64 cross-compiled)
134+
if: matrix.cross && matrix.target == 'aarch64-unknown-linux-gnu'
135+
run: aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
136+
107137
- name: Upload artifact
108138
uses: actions/upload-artifact@v4
109139
with:

0 commit comments

Comments
 (0)