Skip to content

Commit 1f8a8a3

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 2dfb45e commit 1f8a8a3

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

.github/workflows/stable.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ jobs:
221221
runs-on: ubuntu-latest
222222
strategy:
223223
matrix:
224-
target: ["aarch64-unknown-linux-gnu","armv7-unknown-linux-gnueabihf","i686-unknown-linux-gnu"]
224+
targets:
225+
- ["aarch64-unknown-linux-gnu", "arm64", "aarch64-linux-gnu"]
226+
- ["armv7-unknown-linux-gnueabihf", "armhf", "arm-linux-gnueabihf"]
227+
- ["i686-unknown-linux-gnu", "i386", "i686-linux-gnu"]
225228
# Only run on "pull_request" event for external PRs. This is to avoid
226229
# duplicate builds for PRs created from internal branches.
227230
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
@@ -235,15 +238,35 @@ jobs:
235238
uses: dtolnay/rust-toolchain@master
236239
with:
237240
toolchain: ${{ env.RUSTTOOLCHAIN }}
241+
targets: ${{ matrix.targets[0] }}
238242

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

248271
http3_test:
249272
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)