From 1376586ca51b48daecbf52f57e33d6f567dbc72c Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Wed, 21 Aug 2024 16:36:36 -0700 Subject: [PATCH 1/2] use the portable optimizer_hide() when running under Miri --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ src/lib.rs | 21 +++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42a533b..2a8b81a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,3 +86,24 @@ jobs: cargo build --verbose --release --target $TARGET - run: cargo test --verbose --release --features count_instructions_test - run: cargo bench --verbose + + miri: + name: Run tests under Miri + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-nightly-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} + - run: rustup toolchain install nightly --profile=minimal --no-self-update + - run: rustup default nightly + - run: rustup override set nightly + - run: rustup component add miri + - run: rustc --verbose --version + - run: cargo --verbose --version + - run: cargo miri test --verbose diff --git a/src/lib.rs b/src/lib.rs index 82fe03a..6c22e82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(not(miri))] #[inline] #[must_use] fn optimizer_hide(mut value: u8) -> u8 { @@ -17,6 +18,7 @@ fn optimizer_hide(mut value: u8) -> u8 { target_arch = "riscv32", target_arch = "riscv64" ))] +#[cfg(not(miri))] #[inline] #[must_use] #[allow(asm_sub_register)] @@ -28,14 +30,17 @@ fn optimizer_hide(mut value: u8) -> u8 { } } -#[cfg(not(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "riscv32", - target_arch = "riscv64" -)))] +#[cfg(any( + not(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "riscv32", + target_arch = "riscv64", + )), + miri, +))] #[inline(never)] #[must_use] fn optimizer_hide(value: u8) -> u8 { From 1d26e366a2dc6a287f11d60e1554bce257d446e9 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Wed, 21 Aug 2024 17:39:02 -0700 Subject: [PATCH 2/2] bump the MSRV in CI to 1.74 to accommodate clap --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a8b81a..89f04ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - toolchain: [1.68.0, stable, beta, nightly] + toolchain: [1.74.0, stable, beta, nightly] steps: - uses: actions/checkout@v3 - uses: actions/cache@v3