Skip to content

Commit a4a07cf

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 bf31ac2 commit a4a07cf

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
@@ -209,7 +209,11 @@ jobs:
209209
runs-on: ubuntu-latest
210210
strategy:
211211
matrix:
212-
target: ["aarch64-unknown-linux-gnu","armv7-unknown-linux-gnueabihf","i686-unknown-linux-gnu"]
212+
targets: [
213+
["aarch64-unknown-linux-gnu", "arm64", "aarch64-linux-gnu"],
214+
["armv7-unknown-linux-gnueabihf", "armhf", "arm-linux-gnueabihf"],
215+
["i686-unknown-linux-gnu", "i386", "i686-linux-gnu"],
216+
]
213217
# Only run on "pull_request" event for external PRs. This is to avoid
214218
# duplicate builds for PRs created from internal branches.
215219
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
@@ -223,15 +227,35 @@ jobs:
223227
uses: dtolnay/rust-toolchain@master
224228
with:
225229
toolchain: ${{ env.RUSTTOOLCHAIN }}
230+
targets: ${{ matrix.targets[0] }}
226231

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

236260
http3_test:
237261
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)