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..c622b3d6c25 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] @@ -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 diff --git a/Makefile b/Makefile index e68e0ab114c..65a923a7548 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) --locked -- singlepass::universal 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) --locked -- cranelift::universal 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) --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 + --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! @@ -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) --locked -- wasi::wasitests 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 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()))] 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/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 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. diff --git a/rust-toolchain b/rust-toolchain index 883d7d6539f..bfe79d0bddb 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.69 +1.70 diff --git a/tests/integration/cli/tests/msrv.rs b/tests/integration/cli/tests/msrv.rs new file mode 100644 index 00000000000..cc04b29e811 --- /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() + .nth(3) + .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() + ); +} diff --git a/tests/lib/compiler-test-derive/src/lib.rs b/tests/lib/compiler-test-derive/src/lib.rs index 8e8e2e43c5b..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.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;