Skip to content

Commit 22c1c81

Browse files
kornelskighedo
authored andcommitted
ci: raw cross-build
The stable version of the cargo-cross tool uses an Ubuntu version with an ancient LLVM version which is too old for cbindgen, and newer cargo-cross versions are broken in other ways. So switch to building the cross-compilation environment from scratch.
1 parent 4d4d528 commit 22c1c81

1 file changed

Lines changed: 33 additions & 9 deletions

File tree

.github/workflows/stable.yml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ jobs:
212212
runs-on: ubuntu-latest
213213
strategy:
214214
matrix:
215-
target: ["aarch64-unknown-linux-gnu","armv7-unknown-linux-gnueabihf","i686-unknown-linux-gnu"]
215+
targets: [
216+
["aarch64-unknown-linux-gnu", "arm64", "aarch64-linux-gnu"],
217+
["armv7-unknown-linux-gnueabihf", "armhf", "arm-linux-gnueabihf"],
218+
["i686-unknown-linux-gnu", "i386", "i686-linux-gnu"],
219+
]
216220
# Only run on "pull_request" event for external PRs. This is to avoid
217221
# duplicate builds for PRs created from internal branches.
218222
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
@@ -226,15 +230,35 @@ jobs:
226230
uses: dtolnay/rust-toolchain@master
227231
with:
228232
toolchain: ${{ env.RUSTTOOLCHAIN }}
233+
targets: ${{ matrix.targets[0] }}
229234

230-
- name: Install cargo-binstall
231-
uses: cargo-bins/cargo-binstall@main
232-
233-
- name: Install cross
234-
run: cargo-binstall -y cross
235-
236-
- name: Run cargo test using cross
237-
run: cross test --target=${{ matrix.target }} --verbose --all-targets ${{ env.NO_BORING_OPTIONS }} --exclude qlog-dancer
235+
- name: Debian cross setup ${{ matrix.targets[1] }}
236+
run: |
237+
QEMU_PACKAGES=""
238+
if [[ "${{ matrix.targets[1] }}" != "i386" ]]; then
239+
QEMU_PACKAGES="qemu-user libc6:${{ matrix.targets[1] }}"
240+
241+
sudo dpkg --add-architecture ${{ matrix.targets[1] }}
242+
# In Ubuntu only ports have packages for other architectures
243+
THE_ANIMAL_DJ=$(lsb_release -sc)
244+
echo "
245+
deb [arch=${{ matrix.targets[1] }}] http://ports.ubuntu.com/ubuntu-ports/ ${THE_ANIMAL_DJ} main restricted universe multiverse
246+
deb [arch=${{ matrix.targets[1] }}] http://ports.ubuntu.com/ubuntu-ports/ ${THE_ANIMAL_DJ}-updates main restricted universe multiverse
247+
deb [arch=${{ matrix.targets[1] }}] http://ports.ubuntu.com/ubuntu-ports/ ${THE_ANIMAL_DJ}-security main restricted universe multiverse
248+
" | sudo tee /etc/apt/sources.list.d/cross-${{ matrix.targets[1] }}.list
249+
sudo apt-get update || true
250+
251+
echo >> $GITHUB_ENV CARGO_TARGET_$(echo ${{ matrix.targets[0] }} | tr '[:lower:]-' '[:upper:]_')_RUNNER=qemu-${{ matrix.targets[1] }}
252+
fi
253+
254+
sudo apt-get -y --no-install-recommends install crossbuild-essential-${{ matrix.targets[1] }} libclang-dev $QEMU_PACKAGES
255+
256+
echo >> $GITHUB_ENV CC=/usr/bin/${{ matrix.targets[2] }}-gcc
257+
echo >> $GITHUB_ENV CXX=/usr/bin/${{ matrix.targets[2] }}-g++
258+
echo >> $GITHUB_ENV CARGO_TARGET_$(echo ${{ matrix.targets[0] }} | tr '[:lower:]-' '[:upper:]_')_LINKER=/usr/bin/${{ matrix.targets[2] }}-gcc
259+
260+
- name: Run cargo test ${{ matrix.targets[1] }}
261+
run: cargo test --target=${{ matrix.targets[0] }} --verbose --all-targets ${{ env.NO_BORING_OPTIONS }} --exclude qlog-dancer
238262

239263
http3_test:
240264
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)