@@ -273,22 +273,48 @@ jobs:
273273 - uses : ./.github/actions/install-rust
274274 with :
275275 toolchain : ${{ matrix.rust }}
276- - uses : ./.github/workflows/cross.yml
277- with :
278- os : ${{ matrix.os }
279- target : ${{ matrix.target }}
280- libc_package : ${{ matrix.libc_package }}
281- gcc_package : ${{ matrix.gcc_package }}
282- gcc : ${{ matrix.gcc }}
283- qemu : ${{ matrix.qemu }}
284- qemu_target : ${{ matrix.qemu_target }}
285276
286277 - name : Configure Cargo target
287278 run : |
288279 echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
289280 rustup target add ${{ matrix.target }}
290281 if : matrix.target != ''
291282
283+ - name : Install cross-compilation tools
284+ run : |
285+ set -ex
286+ sudo apt-get update
287+ sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
288+ upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
289+ echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
290+ if : matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
291+
292+ - name : Install cross-compilation libraries
293+ run : |
294+ set -ex
295+ sudo apt-get update
296+ sudo apt-get install -y ${{ matrix.libc_package }}
297+ if : matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
298+
299+ - name : Install qemu
300+ run : |
301+ set -ex
302+ # Download and build qemu from source since the most recent release is
303+ # way faster at arm emulation than the current version github actions'
304+ # ubuntu image uses. Disable as much as we can to get it to build
305+ # quickly.
306+ cd
307+ curl https://download.qemu.org/qemu-6.1.0.tar.xz | tar xJf -
308+ cd qemu-6.1.0
309+ ./configure --target-list=${{ matrix.qemu_target }} --prefix=$HOME/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
310+ make -j$(nproc) install
311+
312+ # Configure Cargo for cross compilation and tell it how it can run
313+ # cross executables
314+ upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
315+ echo CARGO_TARGET_${upcase}_RUNNER=$HOME/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV
316+ if : matrix.qemu != '' && matrix.os == 'ubuntu-latest'
317+
292318 - run : |
293319 # Run the tests, and check the prebuilt release libraries.
294320 cargo test --verbose --features=all-impls,procfs,cc --release --workspace -- --nocapture
@@ -365,22 +391,48 @@ jobs:
365391 - uses : ./.github/actions/install-rust
366392 with :
367393 toolchain : ${{ matrix.rust }}
368- - uses : ./.github/workflows/cross.yml
369- with :
370- os : ${{ matrix.os }
371- target : ${{ matrix.target }}
372- libc_package : ${{ matrix.libc_package }}
373- gcc_package : ${{ matrix.gcc_package }}
374- gcc : ${{ matrix.gcc }}
375- qemu : ${{ matrix.qemu }}
376- qemu_target : ${{ matrix.qemu_target }}
377394
378395 - name : Configure Cargo target
379396 run : |
380397 echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
381398 rustup target add ${{ matrix.target }}
382399 if : matrix.target != ''
383400
401+ - name : Install cross-compilation tools
402+ run : |
403+ set -ex
404+ sudo apt-get update
405+ sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
406+ upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
407+ echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
408+ if : matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
409+
410+ - name : Install cross-compilation libraries
411+ run : |
412+ set -ex
413+ sudo apt-get update
414+ sudo apt-get install -y ${{ matrix.libc_package }}
415+ if : matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
416+
417+ - name : Install qemu
418+ run : |
419+ set -ex
420+ # Download and build qemu from source since the most recent release is
421+ # way faster at arm emulation than the current version github actions'
422+ # ubuntu image uses. Disable as much as we can to get it to build
423+ # quickly.
424+ cd
425+ curl https://download.qemu.org/qemu-6.1.0.tar.xz | tar xJf -
426+ cd qemu-6.1.0
427+ ./configure --target-list=${{ matrix.qemu_target }} --prefix=$HOME/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
428+ make -j$(nproc) install
429+
430+ # Configure Cargo for cross compilation and tell it how it can run
431+ # cross executables
432+ upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
433+ echo CARGO_TARGET_${upcase}_RUNNER=$HOME/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV
434+ if : matrix.qemu != '' && matrix.os == 'ubuntu-latest'
435+
384436 - run : |
385437 cargo test --verbose --features=all-impls,procfs --release --workspace -- --nocapture
386438 env:
0 commit comments