From 481462e6cff4a6adcad86c2769b4ed8457d56293 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 with AES-NI but no AVX, and without AES-NI. --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++++--- mk/cargo.sh | 10 ++++++++++ mk/install-build-tools.sh | 8 ++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ca2079aa0..8f7b30b0df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -550,7 +550,7 @@ jobs: - aarch64-unknown-linux-gnu # Has assembly - arm-unknown-linux-gnueabi # Has assembly - armv7-unknown-linux-gnueabihf # Has assembly - - i686-unknown-linux-gnu # Has assembly + # - i686-unknown-linux-gnu # Has assembly; handled specially below. - powerpc-unknown-linux-gnu # No assembly 32-bit big-endian with flags - powerpc64-unknown-linux-gnu # No assembly 64-bit big-endian with flags - powerpc64le-unknown-linux-gnu # No assembly 64-bit little-endian with flags @@ -599,6 +599,17 @@ jobs: # https://github.com/rust-lang/rust/issues/79556 and # https://github.com/rust-lang/rust/issues/79555 are fixed. - target: i686-unknown-linux-gnu + cpu_model: # default + features: --features=std + mode: # debug + rust_channel: nightly + host_os: ubuntu-22.04 + + - target: i686-unknown-linux-gnu + cpu_model: Conroe-v1 + features: --features=std + mode: # debug + rust_channel: nightly host_os: ubuntu-22.04 - target: powerpc-unknown-linux-gnu @@ -619,6 +630,20 @@ jobs: - target: x86_64-apple-darwin host_os: macos-13 + - target: x86_64-unknown-linux-gnu + cpu_model: Conroe-v1 + features: --features=std + mode: # debug + rust_channel: nightly + host_os: ubuntu-22.04 + + - target: x86_64-unknown-linux-gnu + cpu_model: Denverton-v2 + features: --features=std + mode: # debug + rust_channel: nightly + host_os: ubuntu-22.04 + - target: x86_64-unknown-linux-musl host_os: ubuntu-22.04 @@ -630,7 +655,7 @@ jobs: with: persist-credentials: false - - run: RING_COVERAGE=1 mk/install-build-tools.sh +${{ matrix.rust_channel }} --target=${{ matrix.target }} + - run: RING_CPU_MODEL=${{ matrix.cpu_model }} RING_COVERAGE=1 mk/install-build-tools.sh +${{ matrix.rust_channel }} --target=${{ matrix.target }} shell: sh - if: ${{ contains(matrix.host_os, 'windows') }} @@ -638,7 +663,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 9b565c0628..13906aee88 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