Skip to content

Commit

Permalink
Add MSRV support and testing to this repository (#1557)
Browse files Browse the repository at this point in the history
* Add MSRV support and testing to this repository

This mirrors the support in Wasmtime, which Wasmtime depends on, to this
repository as well to ensure all various crates are tagged and CI works
similarly.

* Fix a warning on CI

* Fix compat with Rust 1.76

* Fix warnings in `wast` crate when features are disabled

* Disable tests for libdl crate
  • Loading branch information
alexcrichton authored May 13, 2024
1 parent fadf4e9 commit 777f8be
Show file tree
Hide file tree
Showing 29 changed files with 76 additions and 41 deletions.
60 changes: 28 additions & 32 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
- run: rustup update stable --no-self-update && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
name: ${{ matrix.build }}
Expand All @@ -63,8 +63,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- name: Test (no-hash-maps)
run: cargo test --workspace --locked --features no-hash-maps

Expand All @@ -73,29 +72,26 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, beta, nightly, macos, windows]
include:
- build: stable
os: ubuntu-latest
rust: stable
- build: beta
os: ubuntu-latest
- os: ubuntu-latest
rust: default
- os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
- os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable
- os: macos-latest
rust: default
- os: windows-latest
rust: default
- os: ubuntu-latest
rust: msrv
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --locked --all

test_extra_features:
Expand All @@ -105,7 +101,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable --no-self-update && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- 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 @@ -123,7 +119,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable --no-self-update && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- run: cmake -S examples -B examples/build -DCMAKE_BUILD_TYPE=Release
- run: cmake --build examples/build --config Release

Expand All @@ -134,13 +130,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust (rustup)
run: rustup update 1.77.0 --no-self-update && rustup default 1.77.0
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
toolchain: 1.77.0
- run: |
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sdk-21.0-linux.tar.gz
tar xf wasi-sdk-21.0-linux.tar.gz
export WASI_SDK_PATH=$(pwd)/wasi-sdk-21.0
rustup target add wasm32-wasi
cd crates/wit-component/dl && bash check.sh
wasm:
Expand All @@ -150,9 +146,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup target add wasm32-wasi
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- run: |
tag=v10.0.1
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/${tag}/wasmtime-${tag}-x86_64-linux.tar.xz
Expand All @@ -172,8 +166,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- run: rustup component add rustfmt
# Note that this doesn't use `cargo fmt` because that doesn't format
# modules-defined-in-macros which is in use in `wast` for example. This is
# the best alternative I can come up with at this time
Expand All @@ -186,8 +180,9 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update nightly && rustup default nightly
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
toolchain: nightly
- run: cargo install cargo-fuzz
- run: cargo fuzz build --dev -s none
- run: cargo fuzz build --dev --features wasmtime -s none
Expand All @@ -196,6 +191,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- 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 @@ -246,7 +242,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
- run: rustc ci/publish.rs
# Make sure the tree is publish-able as-is
- run: ./publish verify
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords = ["webassembly", "wasm"]
repository = "https://github.com/bytecodealliance/wasm-tools"
readme = "README.md"
exclude = ['tests/wabt', 'tests/testsuite', 'tests/snapshots', 'ci']
rust-version.workspace = true

[lints]
workspace = true
Expand All @@ -34,6 +35,9 @@ all = "allow"
[workspace.package]
edition = '2021'
version = "0.207.0"
# Current policy for wasm-tools is the same as Wasmtime which is that this
# number can be no larger than the current stable release of Rust minus 2.
rust-version = "1.76.0"

[workspace.dependencies]
anyhow = "1.0.58"
Expand Down
1 change: 1 addition & 0 deletions crates/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "Apache-2.0 WITH LLVM-exception"
readme = "./README.md"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/c-api"
publish = false
rust-version.workspace = true

[lib]
name = "wasmtools"
Expand Down
1 change: 1 addition & 0 deletions crates/fuzz-stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "fuzz-stats"
edition.workspace = true
publish = false
rust-version.workspace = true

[dependencies]
anyhow = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-compose/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wa
homepage = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-compose"
documentation = "https://docs.rs/wasm-compose"
description = "A library for composing WebAssembly components."
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-compose/example/middleware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "middleware"
version = "0.1.0"
edition = "2021"
publish = false
rust-version.workspace = true

[dependencies]
flate2 = "1.0.24"
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-compose/example/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "host"
version = "0.1.0"
edition = "2021"
publish = false
rust-version.workspace = true

[dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-compose/example/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "svc"
version = "0.1.0"
edition = "2021"
publish = false
rust-version.workspace = true

[dependencies]
cargo-component-bindings = "0.6.0"
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-encoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ documentation = "https://docs.rs/wasm-encoder"
description = """
A low-level WebAssembly encoder.
"""
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition.workspace = true
license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-metadata"
description = "Read and manipulate WebAssembly metadata"
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-mutate-stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "wasm-mutate-stats"
edition.workspace = true
publish = false
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-mutate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition.workspace = true
license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-mutate"
description = "A WebAssembly test case mutator"
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-shrink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "./README.md"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-shrink"
name = "wasm-shrink"
version.workspace = true
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-smith/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ readme = "./README.md"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-smith"
version.workspace = true
exclude = ["/benches/corpus"]
rust-version.workspace = true

[[bench]]
name = "corpus"
Expand Down
3 changes: 2 additions & 1 deletion crates/wasmparser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ A simple event-driven library for parsing WebAssembly binary files.
"""
edition.workspace = true
exclude = ["benches/*.wasm"]
rust-version.workspace = true

[lints]
workspace = true
Expand Down Expand Up @@ -46,7 +47,7 @@ default = ['std', 'validate']
std = ['indexmap/std']

# Tells the wasmparser crate to avoid using hash based maps and sets.
#
#
# Some embedded environments cannot provide a random source which is required
# to properly initialize hashmap based data structures for resilience against
# malious actors that control their inputs.
Expand Down
10 changes: 5 additions & 5 deletions crates/wasmparser/src/collections/index_map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ fn extend_works() {
for (index, (key, value)) in values.into_iter().enumerate() {
assert_get(&mut map, key, (index, value));
}
assert!(map.iter().eq(values.each_ref().map(|(k, v)| (k, v))));
assert!(map.iter_mut().eq(values.each_mut().map(|(k, v)| (&*k, v))));
assert!(map.keys().eq(values.each_ref().map(|(k, _v)| k)));
assert!(map.values().eq(values.each_ref().map(|(_k, v)| v)));
assert!(map.values_mut().eq(values.each_mut().map(|(_k, v)| v)));
assert!(map.iter().eq(values.iter().map(|(k, v)| (k, v))));
assert!(map.iter_mut().eq(values.iter_mut().map(|(k, v)| (&*k, v))));
assert!(map.keys().eq(values.iter().map(|(k, _v)| k)));
assert!(map.values().eq(values.iter().map(|(_k, v)| v)));
assert!(map.values_mut().eq(values.iter_mut().map(|(_k, v)| v)));
assert!(map.into_iter().eq(values));
}

Expand Down
1 change: 1 addition & 0 deletions crates/wasmprinter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ documentation = "https://docs.rs/wasmprinter"
description = """
Rust converter from the WebAssembly binary format to the text format.
"""
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ documentation = "https://docs.rs/wast"
description = """
Customizable Rust parsers for the WebAssembly Text formats WAT and WAST
"""
rust-version.workspace = true

[lints]
workspace = true
Expand Down
4 changes: 4 additions & 0 deletions crates/wast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,16 @@ pub mod lexer;
pub mod parser;
pub mod token;

#[cfg(feature = "wasm-module")]
mod encode;
mod error;
#[cfg(feature = "wasm-module")]
mod gensym;
#[cfg(feature = "wasm-module")]
mod names;
pub use self::error::*;

#[cfg(feature = "wasm-module")]
macro_rules! id {
($($t:tt)*) => ($($t)*)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/wast/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ use std::usize;
/// modules/components which be far trickier. For now we just say that when
/// the parser goes too deep we return an error saying there's too many
/// nested items. It would be great to not return an error here, though!
#[cfg(feature = "wasm-module")]
pub(crate) const MAX_PARENS_DEPTH: usize = 100;

/// A top-level convenience parsing function that parses a `T` from `buf` and
Expand Down Expand Up @@ -483,6 +484,7 @@ impl<'a> Parser<'a> {
}
}

#[cfg(feature = "wasm-module")]
pub(crate) fn has_meaningful_tokens(self) -> bool {
self.buf.lexer.iter(0).any(|t| match t {
Ok(token) => !matches!(
Expand Down Expand Up @@ -759,6 +761,7 @@ impl<'a> Parser<'a> {
}

/// Checks that the parser parens depth hasn't exceeded the maximum depth.
#[cfg(feature = "wasm-module")]
pub(crate) fn depth_check(&self) -> Result<()> {
if self.parens_depth() > MAX_PARENS_DEPTH {
Err(self.error("item nesting too deep"))
Expand Down
3 changes: 3 additions & 0 deletions crates/wast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl<'a> Id<'a> {
}
}

#[cfg(feature = "wasm-module")]
pub(crate) fn gensym(span: Span, gen: u32) -> Id<'a> {
Id {
name: "gensym",
Expand All @@ -95,6 +96,7 @@ impl<'a> Id<'a> {
self.span
}

#[cfg(feature = "wasm-module")]
pub(crate) fn is_gensym(&self) -> bool {
self.gen != 0
}
Expand Down Expand Up @@ -180,6 +182,7 @@ impl Index<'_> {
}
}

#[cfg(feature = "wasm-module")]
pub(crate) fn is_resolved(&self) -> bool {
matches!(self, Index::Num(..))
}
Expand Down
1 change: 1 addition & 0 deletions crates/wat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ documentation = "https://docs.rs/wat"
description = """
Rust parser for the WebAssembly Text format, WAT
"""
rust-version.workspace = true

[lints]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/wit-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ documentation = "https://docs.rs/wit-component"
description = """
Tooling for working with `*.wit` and component files together.
"""
rust-version.workspace = true

[lints]
workspace = true
Expand Down
Loading

0 comments on commit 777f8be

Please sign in to comment.