From 58437431a69126b0d9f14a1601a2a57d6acf5eab Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 07:55:02 -0700 Subject: [PATCH 1/9] Use stable Rust on CI to test the x64 backend This commit leverages the newly-released 1.51.0 compiler to test the new backend on Windows and Linux with a stable compiler instead of a nightly compiler. This isolates the nightly build to just the nightly documentation generation and fuzzing, both of which rely on nightly for the best results right now. --- .github/workflows/main.yml | 17 +++-------------- Cargo.toml | 1 + ci/run-experimental-x64-ci.sh | 22 ++-------------------- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 520014269c6a..49af971e50b3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,11 +73,9 @@ jobs: - uses: actions/checkout@v2 with: submodules: true - # Note that we use nightly Rust for the doc_cfg feature (enabled via `nightlydoc` above) - # This version is an older nightly for the new x64 backend (see below) - uses: ./.github/actions/install-rust with: - toolchain: nightly-2020-12-26 + toolchain: nightly - run: cargo doc --no-deps --all --exclude wasmtime-cli --exclude test-programs --exclude cranelift-codegen-meta - run: cargo doc --package cranelift-codegen-meta --document-private-items - uses: actions/upload-artifact@v1 @@ -321,10 +319,7 @@ jobs: RUST_BACKTRACE: 1 # Perform all tests (debug mode) for `wasmtime` with the experimental x64 - # backend. This runs on an older nightly of Rust (because of issues with - # unifying Cargo features on stable) on Ubuntu such that it's new enough - # to build Wasmtime, but old enough where the -Z options being used - # haven't been stabilized yet. + # backend. test_x64: name: Test x64 new backend runs-on: ubuntu-latest @@ -334,7 +329,7 @@ jobs: submodules: true - uses: ./.github/actions/install-rust with: - toolchain: nightly-2020-12-26 + toolchain: stable - uses: ./.github/actions/define-llvm-env # Install wasm32 targets in order to build various tests throughout the @@ -345,7 +340,6 @@ jobs: # Run the x64 CI script. - run: ./ci/run-experimental-x64-ci.sh env: - CARGO_VERSION: "+nightly-2020-12-26" RUST_BACKTRACE: 1 # Perform tests on the new x64 backend on Windows as well. @@ -357,8 +351,6 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - with: - toolchain: nightly-2020-11-29 - uses: ./.github/actions/define-llvm-env - name: Install libclang @@ -378,7 +370,6 @@ jobs: # Run the x64 CI script. - run: ./ci/run-experimental-x64-ci.sh env: - CARGO_VERSION: "+nightly-2020-11-29" RUST_BACKTRACE: 1 # Build and test the wasi-nn module. @@ -390,8 +381,6 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - with: - toolchain: nightly - run: rustup target add wasm32-wasi - uses: ./.github/actions/install-openvino - run: ./ci/run-wasi-nn-example.sh diff --git a/Cargo.toml b/Cargo.toml index 5cc273d1f30f..ac377cbe0cd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ anyhow = "1.0.19" opt-level = 0 [workspace] +resolver = '2' members = [ "cranelift", "crates/bench-api", diff --git a/ci/run-experimental-x64-ci.sh b/ci/run-experimental-x64-ci.sh index e978bbd93484..27c6e9c94f30 100755 --- a/ci/run-experimental-x64-ci.sh +++ b/ci/run-experimental-x64-ci.sh @@ -1,24 +1,7 @@ #!/bin/bash -# Use the Nightly variant of the compiler to properly unify the -# experimental_x64 feature across all crates. Once the feature has stabilized -# and become the default, we can remove this. -CARGO_VERSION=${CARGO_VERSION:-"+nightly"} - -# Some WASI tests seem to have an issue on Windows with symlinks if we run them -# with this particular invocation. It's unclear why (nightly toolchain?) but -# we're moving to the new backend by default soon enough, and all tests seem to -# work with the main test setup, so let's just work around this by skipping -# the tests for now. -MINGW_EXTRA="" -if [ `uname -o` == "Msys" ]; then - MINGW_EXTRA="-- --skip wasi_cap_std_sync" -fi - -cargo $CARGO_VERSION \ +cargo test \ --locked \ - -Zfeatures=all -Zpackage-features \ - test \ --features test-programs/test_programs \ --features experimental_x64 \ --all \ @@ -32,5 +15,4 @@ cargo $CARGO_VERSION \ --exclude peepmatic-runtime \ --exclude peepmatic-test \ --exclude peepmatic-souper \ - --exclude lightbeam \ - $MINGW_EXTRA + --exclude lightbeam From 57fa848e00908de8c72f12d7624b3018f573d76a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 08:54:12 -0700 Subject: [PATCH 2/9] Use updated stable in book build job --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 49af971e50b3..a86b583312c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,6 +48,7 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + - run: rustup update stable && rustup default stable - run: | set -e curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.4.4/mdbook-v0.4.4-x86_64-unknown-linux-gnu.tar.gz | tar xzf - From 541e6b5e08337872370098ba29e646f64d2902e6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 08:54:28 -0700 Subject: [PATCH 3/9] Run rustfmt for new stable --- crates/jit/src/unwind/systemv.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/jit/src/unwind/systemv.rs b/crates/jit/src/unwind/systemv.rs index b449f5d1761d..79f54ee38630 100644 --- a/crates/jit/src/unwind/systemv.rs +++ b/crates/jit/src/unwind/systemv.rs @@ -90,7 +90,10 @@ impl UnwindRegistry { let mut eh_frame = EhFrame(EndianVec::new(RunTimeEndian::default())); table.write_eh_frame(&mut eh_frame).unwrap(); - if cfg!(any(all(target_os = "linux", target_env = "gnu"), target_os = "freebsd")) { + if cfg!(any( + all(target_os = "linux", target_env = "gnu"), + target_os = "freebsd" + )) { // libgcc expects a terminating "empty" length, so write a 0 length at the end of the table. eh_frame.0.write_u32(0).unwrap(); } @@ -101,7 +104,10 @@ impl UnwindRegistry { } unsafe fn register_frames(&mut self) { - if cfg!(any(all(target_os = "linux", target_env = "gnu"), target_os = "freebsd")) { + if cfg!(any( + all(target_os = "linux", target_env = "gnu"), + target_os = "freebsd" + )) { // On gnu (libgcc), `__register_frame` will walk the FDEs until an entry of length 0 let ptr = self.frame_table.as_ptr(); __register_frame(ptr); From 56e20e08f8236aa0600b6cf75672c640cb3bc3d4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 08:55:24 -0700 Subject: [PATCH 4/9] Silence new warnings for wasi-nn --- crates/wasi-nn/examples/wasi-nn-rust-bindings/src/generated.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wasi-nn/examples/wasi-nn-rust-bindings/src/generated.rs b/crates/wasi-nn/examples/wasi-nn-rust-bindings/src/generated.rs index d03fd1ed0cd6..2e74c045a981 100644 --- a/crates/wasi-nn/examples/wasi-nn-rust-bindings/src/generated.rs +++ b/crates/wasi-nn/examples/wasi-nn-rust-bindings/src/generated.rs @@ -152,6 +152,7 @@ pub unsafe fn compute(context: GraphExecutionContext) -> Result<()> { } } +#[allow(improper_ctypes)] pub mod wasi_ephemeral_nn { use super::*; #[link(wasm_import_module = "wasi_ephemeral_nn")] From 168eeee63230febe7d67be55d961d06825b1398e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 08:58:28 -0700 Subject: [PATCH 5/9] Allow some dead code in the x64 backend Looks like new rustc is better about emitting some dead-code warnings --- cranelift/codegen/src/isa/x64/inst/args.rs | 1 + cranelift/codegen/src/isa/x64/lower.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/cranelift/codegen/src/isa/x64/inst/args.rs b/cranelift/codegen/src/isa/x64/inst/args.rs index f2c6feb3c1b3..be0819c354a8 100644 --- a/cranelift/codegen/src/isa/x64/inst/args.rs +++ b/cranelift/codegen/src/isa/x64/inst/args.rs @@ -462,6 +462,7 @@ pub(crate) enum InstructionSet { /// Some SSE operations requiring 2 operands r/m and r. #[derive(Clone, Copy, PartialEq)] +#[allow(dead_code)] // some variants here aren't used just yet pub enum SseOpcode { Addps, Addpd, diff --git a/cranelift/codegen/src/isa/x64/lower.rs b/cranelift/codegen/src/isa/x64/lower.rs index 1ac9806055af..f499b085a850 100644 --- a/cranelift/codegen/src/isa/x64/lower.rs +++ b/cranelift/codegen/src/isa/x64/lower.rs @@ -204,6 +204,7 @@ enum ExtSpec { ZeroExtendTo32, ZeroExtendTo64, SignExtendTo32, + #[allow(dead_code)] // not used just yet but may be used in the future! SignExtendTo64, } From c5f5f1d799557ea9ef678ec95ea5476d2651f0bc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 08:59:12 -0700 Subject: [PATCH 6/9] Update rust in peepmatic job --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a86b583312c5..bbc59420286d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -177,6 +177,7 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + - run: rustup update stable && rustup default stable - name: Test `peepmatic` run: | cargo test \ From 5df852f3e341a1d121d8b962c2d01bc15e398fe0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 09:03:14 -0700 Subject: [PATCH 7/9] Fix a test in the pooling allocator --- crates/runtime/src/instance/allocator/pooling.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/runtime/src/instance/allocator/pooling.rs b/crates/runtime/src/instance/allocator/pooling.rs index c63f4198a322..5d3ce02435ff 100644 --- a/crates/runtime/src/instance/allocator/pooling.rs +++ b/crates/runtime/src/instance/allocator/pooling.rs @@ -1618,7 +1618,7 @@ mod test { } #[cfg_attr(target_arch = "aarch64", ignore)] // https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133 - #[cfg(all(unix, target_pointer_width = "64"))] + #[cfg(all(unix, target_pointer_width = "64", feature = "async"))] #[test] fn test_stack_zeroed() -> Result<()> { let allocator = PoolingInstanceAllocator::new( From 5b3cd72e105274b0dad20a7b5fbd913939e25aa4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 09:28:31 -0700 Subject: [PATCH 8/9] Remove `package.metdata.docs.rs` temporarily Needs resolution of https://github.com/rust-lang/cargo/pull/9300 first --- cranelift/codegen/meta/Cargo.toml | 5 +++-- cranelift/peepmatic/crates/automata/Cargo.toml | 5 +++-- crates/wasmtime/Cargo.toml | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cranelift/codegen/meta/Cargo.toml b/cranelift/codegen/meta/Cargo.toml index c2ad1a8d4b9f..ccd04b386558 100644 --- a/cranelift/codegen/meta/Cargo.toml +++ b/cranelift/codegen/meta/Cargo.toml @@ -8,8 +8,9 @@ repository = "https://github.com/bytecodealliance/wasmtime" readme = "README.md" edition = "2018" -[package.metadata.docs.rs] -rustdoc-args = [ "--document-private-items" ] +# FIXME(rust-lang/cargo#9300): uncomment once that lands +# [package.metadata.docs.rs] +# rustdoc-args = [ "--document-private-items" ] [dependencies] cranelift-codegen-shared = { path = "../shared", version = "0.72.0" } diff --git a/cranelift/peepmatic/crates/automata/Cargo.toml b/cranelift/peepmatic/crates/automata/Cargo.toml index 5359f68d5703..3d8d43476b9e 100644 --- a/cranelift/peepmatic/crates/automata/Cargo.toml +++ b/cranelift/peepmatic/crates/automata/Cargo.toml @@ -6,8 +6,9 @@ edition = "2018" license = "Apache-2.0 WITH LLVM-exception" description = "Finite-state transducer automata" -[package.metadata.docs.rs] -all-features = true +# FIXME(rust-lang/cargo#9300): uncomment once that lands +# [package.metadata.docs.rs] +# all-features = true [dependencies] serde = { version = "1.0.106", optional = true } diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 8a284dc87c93..9617cca92c16 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -9,8 +9,9 @@ repository = "https://github.com/bytecodealliance/wasmtime" readme = "README.md" edition = "2018" -[package.metadata.docs.rs] -rustdoc-args = ["--cfg", "nightlydoc"] +# FIXME(rust-lang/cargo#9300): uncomment once that lands +# [package.metadata.docs.rs] +# rustdoc-args = ["--cfg", "nightlydoc"] [dependencies] wasmtime-runtime = { path = "../runtime", version = "0.25.0" } From b2c994407572377026913d1b41bc761e92900e4a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 09:43:27 -0700 Subject: [PATCH 9/9] Fix a warning in a wasi-nn example --- crates/wasi-nn/examples/classification-example/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/wasi-nn/examples/classification-example/src/main.rs b/crates/wasi-nn/examples/classification-example/src/main.rs index 3465de5caed1..5f0a7f4e5ae9 100644 --- a/crates/wasi-nn/examples/classification-example/src/main.rs +++ b/crates/wasi-nn/examples/classification-example/src/main.rs @@ -49,7 +49,8 @@ pub fn main() { 0, &mut output_buffer[..] as *mut [f32] as *mut u8, (output_buffer.len() * 4).try_into().unwrap(), - ); + ) + .unwrap(); } println!( "Found results, sorted top 5: {:?}",