From 399626b08603eedb8c304707c13493ab6a456f29 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 25 Jul 2024 14:46:25 -0700 Subject: [PATCH 1/2] CI: Check that Pulley builds for `no_std` targets --- .github/workflows/main.yml | 5 +++-- pulley/src/decode.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14ed47a85931..d65f46a23a9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -433,6 +433,7 @@ jobs: - run: rustup target add x86_64-unknown-none - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model - run: cargo check --target x86_64-unknown-none -p cranelift-control --no-default-features + - run: cargo check --target x86_64-unknown-none -p pulley-interpreter --features encode,decode,disas,interp # Check that wasmtime compiles with panic=abort since there's some `#[cfg]` # for specifically panic=abort there. @@ -817,7 +818,7 @@ jobs: if: failure() && github.event_name != 'pull_request' env: GH_TOKEN: ${{ github.token }} - + build-preview1-component-adapter-provider: name: Build wasi-preview1-component-adapter-provider needs: build-preview1-component-adapter @@ -830,7 +831,7 @@ jobs: - uses: ./.github/actions/build-adapter-provider with: run-id: ${{ github.run_id }} - + # common logic to cancel the entire run if this job fails - run: gh run cancel ${{ github.run_id }} diff --git a/pulley/src/decode.rs b/pulley/src/decode.rs index 9d609ca44f8c..dcc219836240 100644 --- a/pulley/src/decode.rs +++ b/pulley/src/decode.rs @@ -402,7 +402,7 @@ impl Decoder { V: OpVisitor> + ExtendedOpVisitor, { let mut decoder = Decoder::new(); - let mut results = vec![]; + let mut results = Vec::new(); while !visitor.bytecode().as_slice().is_empty() { results.push(decoder.decode_one(visitor)?); From f3559a00b139bb69f16a328f32edf4d86fbd105f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 25 Jul 2024 15:31:05 -0700 Subject: [PATCH 2/2] CI: Test Pulley on 32-bit targets This adds CI testing for Pulley on the following 32-bit targets: * `i686-unknown-linux-gnu` * `armv7-unknown-linux-gnueabihf` The previous commit added checks that Pulley builds for `no_std` targets. Our existing test sharding means that it is already tested on a big-endian platform (`s390x-unknown-linux-gnu`) as well as on different OSes (Linux, Windows, and macOS). So altogether we are now testing a pretty wide range of portability dimensions for Pulley in CI: * 32- vs. 64-bit architectures * `std` vs. `no_std` * Little- vs. big-endian * Linux vs. Windows vs. macOS I think our CI coverage for Pulley is in a pretty good place now! Co-Authored-By: Alex Crichton --- .github/workflows/main.yml | 22 +++++++++++++------- ci/build-test-matrix.js | 41 +++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d65f46a23a9b..7ff86f17b328 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -605,22 +605,30 @@ jobs: - run: cargo fetch --locked - - uses: actions/cache@v4 - with: - path: ${{ runner.tool_cache }}/qemu - key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patchcpuinfo - if: matrix.target != '' && matrix.os == 'ubuntu-latest' - name: Install cross-compilation tools run: | set -ex + sudo apt-get update sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build # Configure Cargo for cross compilation and tell it how it can run # cross executables upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') - echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV + if: matrix.gcc != '' + + - uses: actions/cache@v4 + with: + path: ${{ runner.tool_cache }}/qemu + key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patchcpuinfo + if: matrix.qemu != '' + - name: Install qemu + run: | + set -ex + + upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') + echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV # QEMU emulation is not always the speediest, so total testing time # goes down if we build the libs in release mode when running tests. @@ -644,7 +652,7 @@ jobs: ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache}}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs ninja -C build install touch ${{ runner.tool_cache }}/qemu/built - if: matrix.gcc != '' + if: matrix.qemu != '' # Record some CPU details; this is helpful information if tests fail due # to CPU-specific features. diff --git a/ci/build-test-matrix.js b/ci/build-test-matrix.js index 18692260ed14..f1236ed9f311 100644 --- a/ci/build-test-matrix.js +++ b/ci/build-test-matrix.js @@ -121,7 +121,27 @@ const FULL_MATRIX = [ "name": "Test Linux riscv64", "filter": "linux-riscv64", "isa": "riscv64", - } + }, + { + "name": "Test Pulley on i686-unknown-linux-gnu", + "32-bit": true, + "os": "ubuntu-latest", + "target": "i686-unknown-linux-gnu", + "gcc_package": "gcc-i686-linux-gnu", + "gcc": "i686-linux-gnu-gcc", + "filter": "pulley", + }, + { + "name": "Test Pulley on armv7-unknown-linux-gnueabihf", + "32-bit": true, + "os": "ubuntu-latest", + "target": "armv7-unknown-linux-gnueabihf", + "gcc_package": "gcc-arm-linux-gnueabihf", + "gcc": "arm-linux-gnueabihf-gcc", + "qemu": "qemu-arm -L /usr/arm-linux-gnueabihf -E LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib", + "qemu_target": "arm-linux-user", + "filter": "pulley", + }, ]; /// Get the workspace's full list of member crates. @@ -198,6 +218,20 @@ async function shard(configs) { // created above. const sharded = []; for (const config of configs) { + // Special case 32-bit configs. Only Pulley runs on 32-bit targets. + if (config["32-bit"] === true) { + sharded.push(Object.assign( + {}, + config, + { + bucket: members + .map(c => c.indexOf("pulley") !== -1 ? `--package ${c}` : `--exclude ${c}`) + .join(" "), + } + )); + continue; + } + for (const bucket of buckets) { sharded.push(Object.assign( {}, @@ -255,6 +289,11 @@ async function main() { return config.isa !== undefined; } + // If any Pulley source file was modified, then run Pulley-specific configs. + if (names.includes("pulley") && config.filter == "pulley") { + return true; + } + // If the commit explicitly asks for this test config, then include it. if (config.filter && commits.includes(`prtest:${config.filter}`)) { return true;