Skip to content

Transition from wasm32-wasi to wasm32-wasip1, fix clippy lint #158

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
- name: Run tests with miscellaneous features
run: ${{ env.CARGO }} test --verbose --features logging

# Setup and run tests on the wasm32-wasi target via wasmtime.
# Setup and run tests on the wasm32-wasip1 target via wasmtime.
wasm:
runs-on: ubuntu-latest
env:
Expand All @@ -143,16 +143,16 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Add wasm32-wasi target
run: rustup target add wasm32-wasi
- name: Add wasm32-wasip1 target
run: rustup target add wasm32-wasip1
- name: Download and install Wasmtime
run: |
echo "CARGO_BUILD_TARGET=wasm32-wasi" >> $GITHUB_ENV
echo "CARGO_BUILD_TARGET=wasm32-wasip1" >> $GITHUB_ENV
echo "RUSTFLAGS=-Ctarget-feature=+simd128" >> $GITHUB_ENV
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v$WASMTIME_VERSION/wasmtime-v$WASMTIME_VERSION-x86_64-linux.tar.xz
tar xvf wasmtime-v$WASMTIME_VERSION-x86_64-linux.tar.xz
echo `pwd`/wasmtime-v$WASMTIME_VERSION-x86_64-linux >> $GITHUB_PATH
echo "CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime run --wasm simd --" >> $GITHUB_ENV
echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime run --wasm simd --" >> $GITHUB_ENV
- name: Basic build
run: cargo build --verbose
- name: Run tests
Expand All @@ -162,7 +162,7 @@ jobs:
- name: Run tests without any features enabled (core-only)
run: cargo test --verbose --no-default-features

# Setup and run tests on the wasm32-wasi target via wasmtime, but without
# Setup and run tests on the wasm32-wasip1 target via wasmtime, but without
# simd128 enabled.
wasm-no-simd128:
runs-on: ubuntu-latest
Expand All @@ -176,16 +176,16 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Add wasm32-wasi target
run: rustup target add wasm32-wasi
- name: Add wasm32-wasip1 target
run: rustup target add wasm32-wasip1
- name: Download and install Wasmtime
run: |
echo "CARGO_BUILD_TARGET=wasm32-wasi" >> $GITHUB_ENV
echo "CARGO_BUILD_TARGET=wasm32-wasip1" >> $GITHUB_ENV
echo "RUSTFLAGS=-Ctarget-feature=-simd128" >> $GITHUB_ENV
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v$WASMTIME_VERSION/wasmtime-v$WASMTIME_VERSION-x86_64-linux.tar.xz
tar xvf wasmtime-v$WASMTIME_VERSION-x86_64-linux.tar.xz
echo `pwd`/wasmtime-v$WASMTIME_VERSION-x86_64-linux >> $GITHUB_PATH
echo "CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime run --" >> $GITHUB_ENV
echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime run --" >> $GITHUB_ENV
- name: Basic build
run: cargo build --verbose
- name: Run tests
Expand Down Expand Up @@ -270,8 +270,8 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Add wasm32-wasi target
run: rustup target add wasm32-wasi
- name: Add wasm32-wasip1 target
run: rustup target add wasm32-wasip1
- name: Download and install Wasmtime
run: |
# Note that we don't have to set CARGO_BUILD_TARGET and other
Expand Down
50 changes: 25 additions & 25 deletions benchmarks/engines.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memchr-oneshot",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand Down Expand Up @@ -546,7 +546,7 @@

# Engines that specifically target wasm32. These reuse the actual code from
# existing engines in `rust/memchr`, but change the build configuration to
# build for `wasm32-wasi` and use the `wasmtime` JIT to actually run it. We
# build for `wasm32-wasip1` and use the `wasmtime` JIT to actually run it. We
# don't define every possible engine for wasm32, but just a subset for basic
# sanity checks. If it would be beneficial to be more exhaustive, please file
# an issue.
Expand All @@ -558,28 +558,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memchr-prebuilt",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand All @@ -590,28 +590,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memchr-onlycount",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand All @@ -622,28 +622,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memchr2",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32p1-wasi" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32p1-wasi" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand All @@ -654,28 +654,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memchr3",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand All @@ -686,28 +686,28 @@
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"--version",
]
[engine.run]
bin = "wasmtime"
args = [
"run", "--wasm", "simd", "--",
"./target/wasm32-wasi/release/main.wasm",
"./target/wasm32-wasip1/release/main.wasm",
"memmem-prebuilt",
]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]
[[engine.clean]]
bin = "cargo"
args = ["clean"]
envs = [
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasi" },
{ name = "CARGO_BUILD_TARGET", value = "wasm32-wasip1" },
{ name = "RUSTFLAGS", value = "-Ctarget-feature=+simd128" },
]

Expand Down
2 changes: 1 addition & 1 deletion src/arch/all/packedpair/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Pair {
core::mem::swap(&mut rare1, &mut rare2);
core::mem::swap(&mut index1, &mut index2);
}
let max = usize::from(core::u8::MAX);
let max = usize::from(u8::MAX);
for (i, &b) in needle.iter().enumerate().take(max).skip(2) {
if ranker.rank(b) < ranker.rank(rare1) {
rare2 = rare1;
Expand Down
2 changes: 1 addition & 1 deletion src/memmem/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl PrefilterState {
// `skipped` to overflow a `u32`. (And we use a `u32` to reduce the
// size of a prefilter state.)
self.skipped = match u32::try_from(skipped) {
Err(_) => core::u32::MAX,
Err(_) => u32::MAX,
Ok(skipped) => self.skipped.saturating_add(skipped),
};
}
Expand Down