From ac16302aad7326a018bb3f0ff0daf86712dc552e Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 00:10:01 +0100 Subject: [PATCH 01/12] feat: Bumped the MSRV from 1.69 to 1.70 --- .github/cross-linux-riscv64/Dockerfile | 4 ++-- .github/workflows/benchmark.yaml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/cloudcompiler.yaml | 2 +- .github/workflows/documentation.yaml | 5 ++++- .github/workflows/test.yaml | 2 +- Cargo.toml | 2 +- lib/wasi-web/Cargo.toml | 2 +- rust-toolchain | 2 +- 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/cross-linux-riscv64/Dockerfile b/.github/cross-linux-riscv64/Dockerfile index 69ca159ed5b..5b22c57a917 100644 --- a/.github/cross-linux-riscv64/Dockerfile +++ b/.github/cross-linux-riscv64/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update && \ # install rust tools RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -RUN rustup -v toolchain install 1.69 +RUN rustup -v toolchain install 1.70 # add docker the manual way COPY install_docker.sh / RUN /install_docker.sh @@ -61,7 +61,7 @@ ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc RUST_TEST_THREADS=1 \ PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" -RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.69-x86_64-unknown-linux-gnu +RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.70-x86_64-unknown-linux-gnu #compile libssl-dev for riscv64! COPY build_openssl.sh / diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 26ce8bbc4ec..65438dfa5d2 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -7,7 +7,7 @@ on: env: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git - MSRV: "1.67" + MSRV: "1.70" jobs: run_benchmark: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e12e619479f..d1ce5483b9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Builds env: RUST_BACKTRACE: 1 CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git - MSRV: "1.69" + MSRV: "1.70" on: push: diff --git a/.github/workflows/cloudcompiler.yaml b/.github/workflows/cloudcompiler.yaml index 2c25fe8a959..83b685f5b0b 100644 --- a/.github/workflows/cloudcompiler.yaml +++ b/.github/workflows/cloudcompiler.yaml @@ -2,7 +2,7 @@ name: Release cloudcompiler.wasm env: RUST_BACKTRACE: 1 - MSRV: "1.67" + MSRV: "1.70" on: push: diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 4c615f9142d..2eed568c044 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -7,6 +7,9 @@ on: paths: - 'lib/**' +env: + MSRV: "1.70" + jobs: documentation: name: Documentation @@ -16,7 +19,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.67 + toolchain: ${{ env.MSRV }} - name: Install LLVM shell: bash run: | diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6c9a829c30..107440ea2a1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,7 +24,7 @@ env: # Rust, but it's not stable on 1.69 yet. By explicitly setting the protocol we # can override that behaviour CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git - MSRV: "1.69" + MSRV: "1.70" jobs: diff --git a/Cargo.toml b/Cargo.toml index ed1cb8d4bb8..508d4995b61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ edition = "2021" homepage = "https://wasmer.io/" license = "MIT" repository = "https://github.com/wasmerio/wasmer" -rust-version = "1.67" +rust-version = "1.70" version = "4.2.0" [workspace.dependencies] diff --git a/lib/wasi-web/Cargo.toml b/lib/wasi-web/Cargo.toml index f2ff2a61f7d..3926bcb08fe 100644 --- a/lib/wasi-web/Cargo.toml +++ b/lib/wasi-web/Cargo.toml @@ -10,7 +10,7 @@ keywords = [ "wasm", "browser", "terminal" ] repository = "https://github.com/wasmerio/wasmer" readme = "../README.md" homepage = "https://wasmer.io/" -rust-version = "1.67" +rust-version = "1.70" # This crate is in its own workspace because it gets compiled to WebAssembly [workspace] diff --git a/rust-toolchain b/rust-toolchain index 883d7d6539f..bfe79d0bddb 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.69 +1.70 From 73ff0ee1a282c21c2ee2543e3e89761e15b4ad13 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 00:54:34 +0100 Subject: [PATCH 02/12] Introduced an integration test which will keep our MSRV in sync with the rust-version in Cargo.toml --- tests/integration/cli/tests/msrv.rs | 119 ++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 tests/integration/cli/tests/msrv.rs diff --git a/tests/integration/cli/tests/msrv.rs b/tests/integration/cli/tests/msrv.rs new file mode 100644 index 00000000000..b7d07faf485 --- /dev/null +++ b/tests/integration/cli/tests/msrv.rs @@ -0,0 +1,119 @@ +//! Integration tests which makes sure various parts of the project (CI, +//! Dockerfiles, etc.) are all using the Rust version specified in `/Cargo.toml`. + +use std::path::Path; + +use once_cell::sync::Lazy; +use regex::Regex; + +static MSRV: Lazy = Lazy::new(|| { + let cargo_toml = project_root().join("Cargo.toml"); + let contents = std::fs::read_to_string(cargo_toml).unwrap(); + let rust_version_line = contents + .lines() + .find(|line| line.contains("rust-version") && line.contains('"')) + .unwrap(); + let pieces: Vec<_> = rust_version_line.split('"').collect(); + let [_, msrv, _] = pieces.as_slice() else { + panic!(); + }; + + msrv.to_string() +}); + +#[test] +fn docker_file_is_up_to_date() { + let pattern = Regex::new(r"1\.\d\d").unwrap(); + let dockerfile = project_root() + .join(".github") + .join("cross-linux-riscv64") + .join("Dockerfile"); + + let contents = std::fs::read_to_string(&dockerfile).unwrap(); + let expected = pattern.replace_all(&contents, MSRV.as_str()); + + ensure_file_contents(dockerfile, expected); +} + +#[test] +fn rust_toolchain_file_is_up_to_date() { + let pattern = Regex::new(r"1\.\d\d").unwrap(); + let rust_toolchain = project_root().join("rust-toolchain"); + + let contents = std::fs::read_to_string(&rust_toolchain).unwrap(); + let expected = pattern.replace_all(&contents, MSRV.as_str()); + + ensure_file_contents(rust_toolchain, expected); +} + +#[test] +fn wasi_web_is_up_to_date() { + let pattern = Regex::new(r#"rust-version\s*=\s*"\d\.\d\d""#).unwrap(); + let rust_toolchain = project_root() + .join("lib") + .join("wasi-web") + .join("Cargo.toml"); + + let replacement = format!("rust-version = \"{}\"", MSRV.as_str()); + let contents = std::fs::read_to_string(&rust_toolchain).unwrap(); + let expected = pattern.replace_all(&contents, replacement); + + ensure_file_contents(rust_toolchain, expected); +} + +#[test] +fn ci_files_are_up_to_date() { + let pattern = Regex::new(r#"MSRV:\s*"\d+\.\d+""#).unwrap(); + let replacement = format!("MSRV: \"{}\"", MSRV.as_str()); + let workflows = project_root().join(".github").join("workflows"); + + for result in workflows.read_dir().unwrap() { + let path = result.unwrap().path(); + + let contents = std::fs::read_to_string(&path).unwrap(); + let expected = pattern.replace_all(&contents, &replacement); + + ensure_file_contents(path, expected); + } +} + +/// Get the root directory for this repository. +fn project_root() -> &'static Path { + Path::new(env!("CARGO_MANIFEST_DIR")) + .ancestors() + .find(|dir| dir.join(".git").exists()) + .unwrap() +} + +/// Check that a particular file has the desired contents. +/// +/// If the file is missing or outdated, this function will update the file and +/// trigger a panic to fail any test this is called from. +fn ensure_file_contents(path: impl AsRef, contents: impl AsRef) { + let path = path.as_ref(); + let contents = contents.as_ref(); + + if let Ok(old_contents) = std::fs::read_to_string(path) { + if contents == old_contents { + // File is already up to date + return; + } + } + + let display_path = path.strip_prefix(project_root()).unwrap_or(path); + + eprintln!("{} was not up-to-date, updating...", display_path.display()); + + if std::env::var("CI").is_ok() { + eprintln!("Note: run `cargo test` locally and commit the updated files"); + } + + if let Some(parent) = path.parent() { + let _ = std::fs::create_dir_all(parent); + } + std::fs::write(&path, contents).unwrap(); + panic!( + "\"{}\" was not up to date and has been updated. Please commit the changes and re-run the tests.", + path.strip_prefix(project_root()).unwrap_or(path).display() + ); +} From 45b579eab21c6d0c82c908ee164516e92a5f764e Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 01:13:00 +0100 Subject: [PATCH 03/12] Add "--locked" to all "cargo" commands in the Makefile to make sure Cargo.toml is always up to date --- Makefile | 88 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index e68e0ab114c..60ea2536969 100644 --- a/Makefile +++ b/Makefile @@ -382,10 +382,10 @@ all: build-wasmer build-capi build-capi-headless check: check-wasmer check-wasmer-wasm check-capi check-wasmer: - $(CARGO_BINARY) check $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer + $(CARGO_BINARY) check $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer --locked check-wasmer-wasm: - $(CARGO_BINARY) check --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler + $(CARGO_BINARY) check --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler --locked check-capi: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) check $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml \ @@ -393,10 +393,10 @@ check-capi: build-wasmer: - $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer + $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer --locked build-wasmer-jsc: - $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --release --manifest-path lib/cli/Cargo.toml --no-default-features --features="jsc,wat" --bin wasmer + $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --release --manifest-path lib/cli/Cargo.toml --no-default-features --features="jsc,wat" --bin wasmer --locked install-wasi-web: cd lib/wasi-web && npm install || true @@ -406,13 +406,13 @@ build-wasi-web: cd lib/wasi-web && npm run build build-wasmer-debug: - $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer + $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --bin wasmer --locked bench: $(CARGO_BINARY) bench $(CARGO_TARGET_FLAG) $(compiler_features) build-wasmer-wasm: - $(CARGO_BINARY) build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler + $(CARGO_BINARY) build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler --locked # For best results ensure the release profile looks like the following # in Cargo.toml: @@ -438,7 +438,7 @@ else endif build-docs: - $(CARGO_BINARY) doc $(CARGO_TARGET_FLAG) --release $(compiler_features) --document-private-items --no-deps --workspace --exclude wasmer-c-api + $(CARGO_BINARY) doc $(CARGO_TARGET_FLAG) --release $(compiler_features) --document-private-items --no-deps --workspace --exclude wasmer-c-api --locked test-build-docs-rs: @manifest_docs_rs_features_path="package.metadata.docs.rs.features"; \ @@ -452,10 +452,10 @@ test-build-docs-rs: fi; \ printf "*** Building doc for package with manifest $$manifest_path ***\n\n"; \ if [ -z "$$features" ]; then \ - RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" || exit 1; \ + RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --locked || exit 1; \ else \ printf "Following features are inferred from Cargo.toml: $$features\n\n\n"; \ - RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --features "$$features" || exit 1; \ + RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --features "$$features" --locked || exit 1; \ fi; \ fi; \ done @@ -472,10 +472,10 @@ test-build-docs-rs-ci: fi; \ printf "*** Building doc for package with manifest $$manifest_path ***\n\n"; \ if [ -z "$$features" ]; then \ - RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" || exit 1; \ + RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --locked || exit 1; \ else \ printf "Following features are inferred from Cargo.toml: $$features\n\n\n"; \ - RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --features "$$features" || exit 1; \ + RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --features "$$features" --locked || exit 1; \ fi; \ fi; \ done @@ -485,50 +485,50 @@ build-docs-capi: # when generating the documentation, we rename it to its # crate's name. Then we restore the lib's name. sed "$(SEDI)" -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compiler,cranelift,wasi + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compiler,cranelift,wasi --locked sed "$(SEDI)" -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml build-capi: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) + --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) --locked build-capi-singlepass: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner --locked build-capi-singlepass-universal: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner --locked build-capi-cranelift: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner --locked build-capi-cranelift-universal: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner --locked build-capi-llvm: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner --locked build-capi-llvm-universal: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner + --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner --locked build-capi-jsc: RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,jsc,wasi + --no-default-features --features wat,jsc,wasi --locked # Headless (we include the minimal to be able to run) build-capi-headless: ifeq ($(CARGO_TARGET_FLAG),) RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless + --no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless --locked else RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless + --no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless --locked endif build-capi-headless-ios: @@ -543,28 +543,28 @@ build-capi-headless-ios: # test compilers test-stage-0-wast: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) --locked # test packages test-stage-1-test-all: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --all --release $(exclude_tests) --exclude wasmer-c-api-test-runner --exclude wasmer-capi-examples-runner $(compiler_features) + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --all --release $(exclude_tests) --exclude wasmer-c-api-test-runner --exclude wasmer-capi-examples-runner $(compiler_features) --locked test-stage-2-test-compiler-cranelift-nostd: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/compiler-cranelift/Cargo.toml --release --no-default-features --features=std + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/compiler-cranelift/Cargo.toml --release --no-default-features --features=std --locked test-stage-3-test-compiler-singlepass-nostd: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std --locked test-stage-4-wasmer-cli: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/virtual-fs/Cargo.toml --release - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --release + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/virtual-fs/Cargo.toml --release --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/cli/Cargo.toml $(compiler_features) --release --locked # test examples test-stage-5-test-examples: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) $(compiler_features) --features wasi --examples + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) $(compiler_features) --features wasi --examples --locked test-stage-6-test-examples-release: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release $(compiler_features) --features wasi --examples + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release $(compiler_features) --features wasi --examples --locked test-stage-7-capi-integration-tests: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --package wasmer-c-api-test-runner - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --package wasmer-capi-examples-runner + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --package wasmer-c-api-test-runner --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --package wasmer-capi-examples-runner --locked test: test-compilers test-packages test-examples @@ -596,13 +596,13 @@ test-js-wasi: test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler)) test-singlepass-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- singlepass::universal + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- singlepass::universal --locked test-cranelift-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- cranelift::universal + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- cranelift::universal --locked test-llvm-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- llvm::universal + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- llvm::universal --locked test-singlepass: $(foreach singlepass_engine,$(filter singlepass-%,$(compilers_engines)),test-$(singlepass_engine)) @@ -621,7 +621,7 @@ test-capi-jsc: build-capi-jsc package-capi test-capi-integration-jsc test-capi-crate-%: WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) -- --nocapture + --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) -- --nocapture --locked test-capi-integration-%: # note: you need to do make build-capi and make package-capi first! @@ -631,23 +631,23 @@ test-capi-integration-%: cd lib/c-api/examples; WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-integration-//) WASMER_DIR=`pwd`/../../../package make run test-wasi-unit: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/wasi/Cargo.toml --release + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/wasi/Cargo.toml --release --locked test-wasi: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- wasi::wasitests + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- wasi::wasitests --locked test-integration-cli: build-wasmer build-capi package-capi-headless package distribution cp ./dist/wasmer.tar.gz ./link.tar.gz rustup target add wasm32-wasi - WASMER_DIR=`pwd`/package $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli + WASMER_DIR=`pwd`/package $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli --locked # Before running this in the CI, we need to set up link.tar.gz and /cache/wasmer-[target].tar.gz test-integration-cli-ci: rustup target add wasm32-wasi - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-cli + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-cli --locked test-integration-ios: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-ios + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-ios --locked generate-wasi-tests: # Uncomment the following for installing the toolchain @@ -926,9 +926,9 @@ update-testsuite: lint-packages: RUSTFLAGS += -D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D function_item_references # TODO: add `-D missing-docs` lint-packages: - RUSTFLAGS="${RUSTFLAGS}" cargo clippy --all --exclude wasmer-cli -- -D clippy::all - RUSTFLAGS="${RUSTFLAGS}" cargo clippy --manifest-path lib/cli/Cargo.toml $(compiler_features) -- -D clippy::all - RUSTFLAGS="${RUSTFLAGS}" cargo clippy --manifest-path fuzz/Cargo.toml $(compiler_features) -- -D clippy::all + RUSTFLAGS="${RUSTFLAGS}" cargo clippy --all --exclude wasmer-cli --locked -- -D clippy::all + RUSTFLAGS="${RUSTFLAGS}" cargo clippy --manifest-path lib/cli/Cargo.toml --locked $(compiler_features) -- -D clippy::all + RUSTFLAGS="${RUSTFLAGS}" cargo clippy --manifest-path fuzz/Cargo.toml --locked $(compiler_features) -- -D clippy::all lint-formatting: cargo fmt --all -- --check From dc871460e5d6c896e1c085d361da593833213ecc Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 01:19:26 +0100 Subject: [PATCH 04/12] Made clippy happy --- lib/api/src/mem_access.rs | 14 +++++--------- lib/virtual-fs/src/arc_box_file.rs | 2 +- lib/virtual-fs/src/arc_file.rs | 2 +- lib/virtual-fs/src/combine_file.rs | 3 +-- lib/virtual-fs/src/dual_write_file.rs | 3 +-- lib/virtual-fs/src/trace_fs.rs | 3 +-- 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/api/src/mem_access.rs b/lib/api/src/mem_access.rs index fb72d301349..7218ad71178 100644 --- a/lib/api/src/mem_access.rs +++ b/lib/api/src/mem_access.rs @@ -265,12 +265,9 @@ impl<'a, T: ValueType> WasmSlice<'a, T> { self.len, "slice length doesn't match WasmSlice length" ); - let bytes = unsafe { - slice::from_raw_parts_mut( - buf.as_mut_ptr() as *mut MaybeUninit, - buf.len() * mem::size_of::(), - ) - }; + let size = std::mem::size_of_val(buf); + let bytes = + unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut MaybeUninit, size) }; self.buffer.read_uninit(self.offset, bytes)?; Ok(()) } @@ -310,9 +307,8 @@ impl<'a, T: ValueType> WasmSlice<'a, T> { self.len, "slice length doesn't match WasmSlice length" ); - let bytes = unsafe { - slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * mem::size_of::()) - }; + let size = std::mem::size_of_val(data); + let bytes = unsafe { slice::from_raw_parts(data.as_ptr() as *const u8, size) }; self.buffer.write(self.offset, bytes) } diff --git a/lib/virtual-fs/src/arc_box_file.rs b/lib/virtual-fs/src/arc_box_file.rs index 48a8d405fc8..cd6b10c204c 100644 --- a/lib/virtual-fs/src/arc_box_file.rs +++ b/lib/virtual-fs/src/arc_box_file.rs @@ -115,7 +115,7 @@ impl VirtualFile for ArcBoxFile { let mut inner = self.inner.lock().unwrap(); let fut = inner.unlink(); drop(inner); - Box::pin(async { fut.await }) + Box::pin(fut) } fn is_open(&self) -> bool { let inner = self.inner.lock().unwrap(); diff --git a/lib/virtual-fs/src/arc_file.rs b/lib/virtual-fs/src/arc_file.rs index e3961d0b7d6..04de81511d8 100644 --- a/lib/virtual-fs/src/arc_file.rs +++ b/lib/virtual-fs/src/arc_file.rs @@ -131,7 +131,7 @@ where let mut inner = self.inner.lock().unwrap(); let fut = inner.unlink(); drop(inner); - Box::pin(async move { fut.await }) + Box::pin(fut) } fn is_open(&self) -> bool { let inner = self.inner.lock().unwrap(); diff --git a/lib/virtual-fs/src/combine_file.rs b/lib/virtual-fs/src/combine_file.rs index 2339d392b2c..4880545fc84 100644 --- a/lib/virtual-fs/src/combine_file.rs +++ b/lib/virtual-fs/src/combine_file.rs @@ -42,8 +42,7 @@ impl VirtualFile for CombineFile { } fn unlink(&mut self) -> BoxFuture<'static, Result<()>> { - let fut = self.tx.unlink(); - Box::pin(async { fut.await }) + Box::pin(self.tx.unlink()) } fn poll_read_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { diff --git a/lib/virtual-fs/src/dual_write_file.rs b/lib/virtual-fs/src/dual_write_file.rs index 0f290294e63..f2c0aca0198 100644 --- a/lib/virtual-fs/src/dual_write_file.rs +++ b/lib/virtual-fs/src/dual_write_file.rs @@ -50,8 +50,7 @@ impl VirtualFile for DualWriteFile { } fn unlink(&mut self) -> BoxFuture<'static, Result<()>> { - let fut = self.inner.unlink(); - Box::pin(async { fut.await }) + Box::pin(self.inner.unlink()) } fn poll_read_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { diff --git a/lib/virtual-fs/src/trace_fs.rs b/lib/virtual-fs/src/trace_fs.rs index 627dca8a5b3..53db3db90b6 100644 --- a/lib/virtual-fs/src/trace_fs.rs +++ b/lib/virtual-fs/src/trace_fs.rs @@ -130,8 +130,7 @@ impl VirtualFile for TraceFile { } fn unlink(&mut self) -> BoxFuture<'static, crate::Result<()>> { - let fut = self.file.unlink(); - Box::pin(async move { fut.await }) + Box::pin(self.file.unlink()) } #[tracing::instrument(level = "trace", skip_all, fields(path=%self.path.display()))] From 7804c0f2ca5d57756f10340d77d668b8f660a67c Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 09:38:52 +0100 Subject: [PATCH 05/12] Made clippy happy --- lib/wasix/src/syscalls/wasi/fd_read.rs | 11 ++++------- lib/wasix/src/syscalls/wasix/stack_checkpoint.rs | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/wasix/src/syscalls/wasi/fd_read.rs b/lib/wasix/src/syscalls/wasi/fd_read.rs index ae28f3d7acf..220d1af7cb2 100644 --- a/lib/wasix/src/syscalls/wasi/fd_read.rs +++ b/lib/wasix/src/syscalls/wasi/fd_read.rs @@ -351,13 +351,10 @@ pub(crate) fn fd_read_internal( // Yield until the notifications are triggered let tasks_inner = env.tasks().clone(); - let res = - __asyncify_light(env, None, async { poller.await })?.map_err( - |err| match err { - Errno::Timedout => Errno::Again, - a => a, - }, - ); + let res = __asyncify_light(env, None, poller)?.map_err(|err| match err { + Errno::Timedout => Errno::Again, + a => a, + }); let val = wasi_try_ok_ok!(res); let mut memory = unsafe { env.memory_view(ctx) }; diff --git a/lib/wasix/src/syscalls/wasix/stack_checkpoint.rs b/lib/wasix/src/syscalls/wasix/stack_checkpoint.rs index b6d4b52b64e..59b8d3a430d 100644 --- a/lib/wasix/src/syscalls/wasix/stack_checkpoint.rs +++ b/lib/wasix/src/syscalls/wasix/stack_checkpoint.rs @@ -50,7 +50,6 @@ pub fn stack_checkpoint( .unwrap(); let env = ctx.data(); let store_data = Bytes::from(store_data); - let mut memory_stack_corrected = memory_stack.clone(); // We compute the hash again for two reasons... integrity so if there // is a long jump that goes to the wrong place it will fail gracefully. From 910782c116a3c35a990712a293c6b9aa432251a2 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 09:39:05 +0100 Subject: [PATCH 06/12] Fixed a typo in a profile override --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 508d4995b61..c622b3d6c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,7 +168,7 @@ opt-level = 3 opt-level = 3 [profile.dev.package.weezl] opt-level = 3 -[profile.dev.package.sha256] +[profile.dev.package.sha2] opt-level = 3 [profile.dev.package.digest] opt-level = 3 From f5d520bd7721fcc8e6c9a729d5cfd827cd6d879c Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 09:41:58 +0100 Subject: [PATCH 07/12] Fixed some --locked flags that weren't in the right position --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 60ea2536969..65a923a7548 100644 --- a/Makefile +++ b/Makefile @@ -596,13 +596,13 @@ test-js-wasi: test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler)) test-singlepass-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- singlepass::universal --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) --locked -- singlepass::universal test-cranelift-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- cranelift::universal --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) --locked -- cranelift::universal test-llvm-universal: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- llvm::universal --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) --locked -- llvm::universal test-singlepass: $(foreach singlepass_engine,$(filter singlepass-%,$(compilers_engines)),test-$(singlepass_engine)) @@ -621,7 +621,7 @@ test-capi-jsc: build-capi-jsc package-capi test-capi-integration-jsc test-capi-crate-%: WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) -- --nocapture --locked + --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) --locked -- --nocapture test-capi-integration-%: # note: you need to do make build-capi and make package-capi first! @@ -634,7 +634,7 @@ test-wasi-unit: $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --manifest-path lib/wasi/Cargo.toml --release --locked test-wasi: - $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- wasi::wasitests --locked + $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) --locked -- wasi::wasitests test-integration-cli: build-wasmer build-capi package-capi-headless package distribution cp ./dist/wasmer.tar.gz ./link.tar.gz From 9aa7450bdcf5d12ad530b3aa658a34e495ace1d6 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 10:15:39 +0100 Subject: [PATCH 08/12] Made clippy happy --- tests/lib/compiler-test-derive/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/compiler-test-derive/src/lib.rs b/tests/lib/compiler-test-derive/src/lib.rs index 8e8e2e43c5b..009a1ae867c 100644 --- a/tests/lib/compiler-test-derive/src/lib.rs +++ b/tests/lib/compiler-test-derive/src/lib.rs @@ -23,7 +23,7 @@ fn compiler_test_impl(attrs: TokenStream, input: TokenStream) -> TokenStream { Ok(f) => f, Err(e) => return e.into_compile_error(), }; - let fn_name = my_fn.sig.ident.clone(); + let fn_name = my_fn.sig.ident; // Let's build the ignores to append an `#[ignore]` macro to the // autogenerated tests in case the test appears in the `ignores.txt` path; From 6465f445ce04e19972a5bf5fb29c74f9563e557a Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 16:17:12 +0100 Subject: [PATCH 09/12] Fixed something I broke while making clippy happy --- tests/lib/compiler-test-derive/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/compiler-test-derive/src/lib.rs b/tests/lib/compiler-test-derive/src/lib.rs index 009a1ae867c..83c95eba0e9 100644 --- a/tests/lib/compiler-test-derive/src/lib.rs +++ b/tests/lib/compiler-test-derive/src/lib.rs @@ -23,7 +23,7 @@ fn compiler_test_impl(attrs: TokenStream, input: TokenStream) -> TokenStream { Ok(f) => f, Err(e) => return e.into_compile_error(), }; - let fn_name = my_fn.sig.ident; + let fn_name = &my_fn.sig.ident; // Let's build the ignores to append an `#[ignore]` macro to the // autogenerated tests in case the test appears in the `ignores.txt` path; From 1686429d76a1300d38d2078552b6d600e3c41744 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 20:13:07 +0100 Subject: [PATCH 10/12] More clippy --- lib/wasix/src/runners/wcgi/handler.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/wasix/src/runners/wcgi/handler.rs b/lib/wasix/src/runners/wcgi/handler.rs index e6219380d10..2101142e3ca 100644 --- a/lib/wasix/src/runners/wcgi/handler.rs +++ b/lib/wasix/src/runners/wcgi/handler.rs @@ -84,9 +84,7 @@ impl Handler { } .in_current_span(); task_manager - .task_shared(Box::new(move || { - Box::pin(async move { work_consume_stderr.await }) - })) + .task_shared(Box::new(move || Box::pin(work_consume_stderr))) .ok(); let work_drive_io = async move { @@ -99,9 +97,7 @@ impl Handler { } .in_current_span(); task_manager - .task_shared(Box::new(move || { - Box::pin(async move { work_drive_io.await }) - })) + .task_shared(Box::new(move || Box::pin(work_drive_io))) .ok(); let parts = self From 0c7a45d930d23670d5a31d3d7ef7373575dc9cf1 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Wed, 20 Sep 2023 22:02:29 +0100 Subject: [PATCH 11/12] The .git directory doesn't exist in the Docker container used when testing MUSL --- tests/integration/cli/tests/msrv.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/cli/tests/msrv.rs b/tests/integration/cli/tests/msrv.rs index b7d07faf485..c96c6cbb5e4 100644 --- a/tests/integration/cli/tests/msrv.rs +++ b/tests/integration/cli/tests/msrv.rs @@ -79,10 +79,12 @@ fn ci_files_are_up_to_date() { /// Get the root directory for this repository. fn project_root() -> &'static Path { - Path::new(env!("CARGO_MANIFEST_DIR")) + let project_dir = Path::new(env!("CARGO_MANIFEST_DIR")) .ancestors() - .find(|dir| dir.join(".git").exists()) - .unwrap() + .nth(3) + .unwrap(); + assert!(project_dir.join(".git").exists()); + project_dir } /// Check that a particular file has the desired contents. From 7e1bf3f23780a0b3863ab4be9a26d19c1b4450fd Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Thu, 21 Sep 2023 11:25:11 +0100 Subject: [PATCH 12/12] Remove the assertion that the ".git" directory exists --- tests/integration/cli/tests/msrv.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/integration/cli/tests/msrv.rs b/tests/integration/cli/tests/msrv.rs index c96c6cbb5e4..cc04b29e811 100644 --- a/tests/integration/cli/tests/msrv.rs +++ b/tests/integration/cli/tests/msrv.rs @@ -79,12 +79,10 @@ fn ci_files_are_up_to_date() { /// Get the root directory for this repository. fn project_root() -> &'static Path { - let project_dir = Path::new(env!("CARGO_MANIFEST_DIR")) + Path::new(env!("CARGO_MANIFEST_DIR")) .ancestors() .nth(3) - .unwrap(); - assert!(project_dir.join(".git").exists()); - project_dir + .unwrap() } /// Check that a particular file has the desired contents.