Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the MSRV from 1.69 to 1.70 #4221

Merged
merged 12 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion 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
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
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()
.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<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()
);
}