Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[219] Fix tests on nightly #2006

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/actions/install-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 'Install Rust toolchain'
description: 'Install a rust toolchain'

inputs:
toolchain:
description: 'Default toolchan to install'
required: false
default: 'default'
msrv_range:
description: 'Versions later-than-latest-Rust the MSRV supports'
required: false
default: '2'

runs:
using: composite
steps:
- name: Install Rust
shell: bash
id: select
run: |
# Determine MSRV as N in `1.N.0` by looking at the `rust-version`
# located in the root `Cargo.toml`.
msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/')
range=${{ inputs.msrv_range }}

if [ "${{ inputs.toolchain }}" = "default" ]; then
echo "version=1.$((msrv+range)).0" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.toolchain }}" = "msrv" ]; then
echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-pinned-nightly" ]; then
echo "version=nightly-2025-01-09" >> "$GITHUB_OUTPUT"
else
echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT"
fi

- name: Install Rust
shell: bash
run: |
rustup set profile minimal
rustup update "${{ steps.select.outputs.version }}" --no-self-update
rustup default "${{ steps.select.outputs.version }}"

# Save disk space by avoiding incremental compilation. Also turn down
# debuginfo from 2 to 0 to help save disk space.
cat >> "$GITHUB_ENV" <<EOF
CARGO_INCREMENTAL=0
CARGO_PROFILE_DEV_DEBUG=0
CARGO_PROFILE_TEST_DEBUG=0
EOF

# Deny warnings on CI to keep our code warning-free as it lands in-tree.
echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV"

if [[ "${{ runner.os }}" = "macOS" ]]; then
cat >> "$GITHUB_ENV" <<EOF
CARGO_PROFILE_DEV_SPLIT_DEBUGINFO=unpacked
CARGO_PROFILE_TEST_SPLIT_DEBUGINFO=unpacked
EOF
fi

- name: Require semicolons in WIT
shell: bash
run: echo WIT_REQUIRE_SEMICOLONS=1 >> "$GITHUB_ENV"
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
name: ${{ matrix.build }}
Expand All @@ -63,7 +63,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- name: Test (no-hash-maps)
run: cargo test --workspace --locked --features no-hash-maps

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --locked --all ${{ matrix.flags }}
Expand All @@ -115,7 +115,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: cargo test --locked -p wasmparser --benches
- run: cargo test --locked -p wasm-encoder --all-features
- run: cargo test -p wasm-smith --features wasmparser
Expand All @@ -134,7 +134,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: cmake -S examples -B examples/build -DCMAKE_BUILD_TYPE=Release
- run: cmake --build examples/build --config Release

Expand All @@ -145,7 +145,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: 1.79.0
- run: rustup target add wasm32-wasip1
Expand All @@ -162,7 +162,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasip1
- run: |
tag=v10.0.1
Expand All @@ -183,7 +183,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup component add rustfmt
- run: printf "\n" > playground/component/src/bindings.rs
# Note that this doesn't use `cargo fmt` because that doesn't format
Expand All @@ -198,7 +198,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: nightly
- run: cargo install cargo-fuzz
Expand All @@ -209,7 +209,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup target add x86_64-unknown-none
- run: cargo check --benches -p wasm-smith
- run: cargo check --no-default-features
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup component add clippy
- run: cargo clippy --workspace --all-targets --exclude dl --exclude component

Expand All @@ -292,7 +292,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustc ci/publish.rs
# Make sure we can bump version numbers for the next release
- run: ./publish bump
Expand Down
11 changes: 9 additions & 2 deletions crates/wit-parser/src/sizealign.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::{
cmp::Ordering,
num::NonZeroUsize,
ops::{Add, AddAssign},
};

use crate::{FlagsRepr, Int, Resolve, Type, TypeDef, TypeDefKind};

/// Architecture specific alignment
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Eq, PartialEq, Clone, Copy)]
pub enum Alignment {
/// This represents 4 byte alignment on 32bit and 8 byte alignment on 64bit architectures
Pointer,
Expand All @@ -29,11 +30,17 @@ impl std::fmt::Debug for Alignment {
}
}

impl PartialOrd for Alignment {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for Alignment {
/// Needed for determining the max alignment of an object from its parts.
/// The ordering is: Bytes(1) < Bytes(2) < Bytes(4) < Pointer < Bytes(8)
/// as a Pointer is either four or eight byte aligned, depending on the architecture
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(Alignment::Pointer, Alignment::Pointer) => std::cmp::Ordering::Equal,
(Alignment::Pointer, Alignment::Bytes(b)) => {
Expand Down