Skip to content

Commit

Permalink
Merge pull request #4221 from wasmerio/bump-msrv
Browse files Browse the repository at this point in the history
Bump the MSRV from 1.69 to 1.70
  • Loading branch information
Michael-F-Bryan committed Sep 21, 2023
2 parents b3dde1a + 7e1bf3f commit 74623c4
Show file tree
Hide file tree
Showing 21 changed files with 194 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .github/cross-linux-riscv64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 /
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.67"
MSRV: "1.70"

jobs:
run_benchmark:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Builds
env:
RUST_BACKTRACE: 1
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.69"
MSRV: "1.70"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloudcompiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release cloudcompiler.wasm

env:
RUST_BACKTRACE: 1
MSRV: "1.67"
MSRV: "1.70"

on:
push:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
paths:
- 'lib/**'

env:
MSRV: "1.70"

jobs:
documentation:
name: Documentation
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
88 changes: 44 additions & 44 deletions Makefile

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions lib/api/src/mem_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
buf.len() * mem::size_of::<T>(),
)
};
let size = std::mem::size_of_val(buf);
let bytes =
unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut MaybeUninit<u8>, size) };
self.buffer.read_uninit(self.offset, bytes)?;
Ok(())
}
Expand Down Expand Up @@ -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::<T>())
};
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)
}

Expand Down
2 changes: 1 addition & 1 deletion lib/virtual-fs/src/arc_box_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/virtual-fs/src/arc_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions lib/virtual-fs/src/combine_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<io::Result<usize>> {
Expand Down
3 changes: 1 addition & 2 deletions lib/virtual-fs/src/dual_write_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<io::Result<usize>> {
Expand Down
3 changes: 1 addition & 2 deletions lib/virtual-fs/src/trace_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))]
Expand Down
2 changes: 1 addition & 1 deletion lib/wasi-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 2 additions & 6 deletions lib/wasix/src/runners/wcgi/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions lib/wasix/src/syscalls/wasi/fd_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,10 @@ pub(crate) fn fd_read_internal<M: MemorySize>(
// 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) };
Expand Down
1 change: 0 additions & 1 deletion lib/wasix/src/syscalls/wasix/stack_checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub fn stack_checkpoint<M: MemorySize>(
.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.
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.69
1.70
119 changes: 119 additions & 0 deletions tests/integration/cli/tests/msrv.rs
Original file line number Diff line number Diff line change
@@ -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<String> = 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<Path>, contents: impl AsRef<str>) {
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()
);
}
2 changes: 1 addition & 1 deletion tests/lib/compiler-test-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 74623c4

Please sign in to comment.