From 430846df59cd521f4a294cc79084307b490a636b Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 19 Jun 2024 16:22:26 -0700 Subject: [PATCH] Use QEMU to test CPUs without AES-NI. --- .github/workflows/ci.yml | 14 +++++++++++++- mk/cargo.sh | 10 ++++++++++ mk/install-build-tools.sh | 8 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ca2079aa0..d617dbc3b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -601,6 +601,12 @@ jobs: - target: i686-unknown-linux-gnu host_os: ubuntu-22.04 + - target: i686-unknown-linux-gnu + mode: # debug + rust_channel: nightly + host_os: ubuntu-22.04 + cpu_model: Conroe-v1 + - target: powerpc-unknown-linux-gnu host_os: ubuntu-22.04 @@ -619,6 +625,12 @@ jobs: - target: x86_64-apple-darwin host_os: macos-13 + - target: x86_64-unknown-linux-gnu + mode: # debug + rust_channel: nightly + host_os: ubuntu-22.04 + cpu_model: Conroe-v1 + - target: x86_64-unknown-linux-musl host_os: ubuntu-22.04 @@ -638,7 +650,7 @@ jobs: - if: ${{ !contains(matrix.host_os, 'windows') }} run: | - RING_COVERAGE=1 mk/cargo.sh +${{ matrix.rust_channel }} test -vv --target=${{ matrix.target }} ${{ matrix.cargo_options }} ${{ matrix.features }} ${{ matrix.mode }} + RING_CPU_MODEL=${{ matrix.cpu_model }} RING_COVERAGE=1 mk/cargo.sh +${{ matrix.rust_channel }} test -vv --target=${{ matrix.target }} ${{ matrix.cargo_options }} ${{ matrix.features }} ${{ matrix.mode }} - uses: briansmith/codecov-codecov-action@v4 with: diff --git a/mk/cargo.sh b/mk/cargo.sh index e259171a1b..ab3f9f05ee 100755 --- a/mk/cargo.sh +++ b/mk/cargo.sh @@ -31,6 +31,8 @@ qemu_powerpc64le="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" qemu_riscv64="qemu-riscv64 -L /usr/riscv64-linux-gnu" qemu_s390x="qemu-s390x -L /usr/s390x-linux-gnu" qemu_sparc64="qemu-sparc64 -L /usr/sparc64-linux-gnu" +qemu_x86="qemu-i386" +qemu_x86_64="qemu-x86_64" # Avoid putting the Android tools in `$PATH` because there are tools in this # directory like `clang` that would conflict with the same-named tools that may @@ -110,6 +112,9 @@ case $target in i686-unknown-linux-gnu) use_clang=1 export CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version + if [ -n "${RING_CPU_MODEL-}" ]; then + export CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER="$qemu_x86 -cpu ${RING_CPU_MODEL}" + fi ;; i686-unknown-linux-musl) use_clang=1 @@ -176,6 +181,11 @@ case $target in export CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc export CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_sparc64" ;; + x86_64-unknown-linux-gnu) + if [ -n "${RING_CPU_MODEL-}" ]; then + export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_x86_64 -cpu ${RING_CPU_MODEL}" + fi + ;; x86_64-unknown-linux-musl) use_clang=1 # XXX: Work around https://github.com/rust-lang/rust/issues/79555. diff --git a/mk/install-build-tools.sh b/mk/install-build-tools.sh index bbe6104c88..81fd9ed1ba 100755 --- a/mk/install-build-tools.sh +++ b/mk/install-build-tools.sh @@ -98,6 +98,9 @@ i686-unknown-linux-gnu) install_packages \ gcc-multilib \ libc6-dev-i386 + if [ -n "${RING_CPU_MODEL-}" ]; then + install_packages qemu-user + fi ;; i686-unknown-linux-musl|x86_64-unknown-linux-musl) use_clang=1 @@ -183,6 +186,11 @@ wasm32-wasi) https://github.com/briansmith/ring-toolchain \ target/tools/linux-x86_64 ;; +x86_64-unknown-linux-gnu) + if [ -n "${RING_CPU_MODEL-}" ]; then + install_packages qemu-user + fi + ;; *) ;; esac