Skip to content

Commit

Permalink
Update Rust in CI to 1.72.0, clarify Wasmtime's MSRV (#6900)
Browse files Browse the repository at this point in the history
* Update Rust in CI to 1.72.0

* Update CI, tooling, and docs for MSRV

This commit codifies an MSRV policy for Wasmtime at "stable minus two"
meaning that the latest three releases of Rust will be supported. This
is enforced on CI with a full test suite job running on Linux x86_64
with the minimum supported Rust version. The full test suite will use
the latest stable version. A downside of this approach is that new
changes may break MSRV support on non-Linux or non-x86_64 platforms and
we won't know about it, but that's deemed a minor enough risk at this
time.

A minor fix is applied to Wasmtime's `Cargo.toml` to support Rust 1.70.0
instead of requiring Rust 1.71.0

* Fix installation of rust

* Scrape MSRV from Cargo.toml

* Cranelift is the same as Wasmtime's MSRV now, more words too

* Fix a typo
  • Loading branch information
alexcrichton authored Aug 31, 2023
1 parent 5ec7318 commit a04c493
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 16 deletions.
27 changes: 19 additions & 8 deletions .github/actions/install-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
toolchain:
description: 'Default toolchan to install'
required: false
default: '1.71.0'
default: 'default'
lockfiles:
description: 'Path glob for Cargo.lock files to use as cache keys'
required: false
Expand All @@ -14,13 +14,28 @@ inputs:
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/')
if [ "${{ inputs.toolchain }}" = "default" ]; then
echo "version=1.$((msrv+2)).0" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.toolchain }}" = "msrv" ]; then
echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT"
else
echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT"
fi
- name: Install Rust
shell: bash
run: |
rustup set profile minimal
rustup update "${{ inputs.toolchain }}" --no-self-update
rustup default "${{ inputs.toolchain }}"
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.
Expand All @@ -31,11 +46,7 @@ runs:
EOF
# Deny warnings on CI to keep our code warning-free as it lands in-tree.
# Don't do this on nightly though, since there's a fair amount of
# warning churn there.
if [[ "${{ inputs.toolchain }}" != nightly* ]]; then
echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV"
fi
echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV"
if [[ "${{ runner.os }}" = "macOS" ]]; then
cat >> "$GITHUB_ENV" <<EOF
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

# Install targets in order to build various tests throughout the repo
- run: rustup target add wasm32-wasi wasm32-unknown-unknown ${{ matrix.target }}
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ exclude = [
version = "13.0.0"
authors = ["The Wasmtime Project Developers"]
edition = "2021"
rust-version = "1.71.0"
# Wasmtime's current policy is that this number can be no larger than the
# current stable release of Rust minus 2.
rust-version = "1.70.0"

[workspace.dependencies]
wasmtime-wmemcheck = { path = "crates/wmemcheck", version = "=13.0.0" }
Expand Down
15 changes: 15 additions & 0 deletions ci/build-test-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@ const names = fs.readFileSync(process.argv[3]).toString();
// on CI.
// * `isa` - changes to `cranelift/codegen/src/$isa` will automatically run this
// test suite.
// * `rust` - the Rust version to install, and if unset this'll be set to
// `default`
const array = [
{
"os": "ubuntu-latest",
"name": "Test Linux x86_64",
"filter": "linux-x64",
"isa": "x64"
},
{
"os": "ubuntu-latest",
"name": "Test MSRV on Linux x86_64",
"filter": "linux-x64",
"isa": "x64",
"rust": "msrv",
},
{
"os": "macos-latest",
"name": "Test macOS x86_64",
Expand Down Expand Up @@ -90,6 +99,12 @@ const array = [
}
];

for (let config of array) {
if (config.rust === undefined) {
config.rust = 'default';
}
}

function myFilter(item) {
if (item.isa && names.includes(`cranelift/codegen/src/isa/${item.isa}`)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ component-model = [
"dep:encoding_rs",
]

wmemcheck = ["wasmtime-runtime/wmemcheck", "wasmtime-cranelift/wmemcheck"]
wmemcheck = ["wasmtime-runtime/wmemcheck", "wasmtime-cranelift?/wmemcheck"]
15 changes: 9 additions & 6 deletions docs/contributing-coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ your editor.

### Minimum Supported `rustc` Version

Wasmtime supports the current stable version of Rust.
Wasmtime and Cranelift support the latest three stable releases of Rust. This
means that if the latest version of Rust is 1.72.0 then Wasmtime supports Rust
1.70.0, 1.71.0, and 1.72.0. CI will test by default with 1.72.0 and there will
be one job running the full test suite on Linux x86\_64 on 1.70.0.

Cranelift supports stable Rust, and follows the [Rust Update Policy for
Firefox].
Some of the CI jobs depend on nightly Rust, for example to run rustdoc with
nightly features, however these use pinned versions in CI that are updated
periodically and the general repository does not depend on nightly features.

Some of the developer scripts depend on nightly Rust, for example to run
clippy and other tools, however we avoid depending on these for the main
build.
Updating Wasmtime's MSRV is done by editing the `rust-version` field in the
workspace root's `Cargo.toml`

[Rust Update Policy for Firefox]: https://wiki.mozilla.org/Rust_Update_Policy_for_Firefox#Schedule

0 comments on commit a04c493

Please sign in to comment.