From 23654a140e3a49c81720b63043a690cd1f9c4e57 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Tue, 18 Mar 2025 11:11:07 -0700 Subject: [PATCH] [ci] Check (but don't test) avr-none target Closes #2400 gherrit-pr-id: I69f30d9256afe91a6cf7619bec2b37b57ce98880 --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++++++++++++++++- src/util/macro_util.rs | 4 ++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11c1ea1820..dd64e85d62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -631,6 +631,45 @@ jobs: - name: Check big endian for aarch64_be-unknown-linux-gnu target run: ./cargo.sh +nightly build --target=aarch64_be-unknown-linux-gnu -Zbuild-std --features simd + # We can't use this as part of the build matrix because rustup doesn't support + # the `avr-none` target. + check_avr_artmega: + runs-on: ubuntu-latest + name: Build (zerocopy / nightly / --simd / avr-none) + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - name: Configure environment variables + run: | + set -eo pipefail + ZC_TOOLCHAIN="$(./cargo.sh --version nightly)" + RUSTFLAGS="$RUSTFLAGS $ZC_NIGHTLY_RUSTFLAGS" + echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV + echo "ZC_TOOLCHAIN=$ZC_TOOLCHAIN" >> $GITHUB_ENV + - name: Rust Cache + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + key: avr-none + - name: Install stable Rust for use in 'cargo.sh' + uses: dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable + with: + toolchain: stable + - name: Install Rust with nightly toolchain (${{ env.ZC_TOOLCHAIN }}) + uses: dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable + with: + toolchain: ${{ env.ZC_TOOLCHAIN }} + components: clippy, rust-src + # NOTE: We cannot check tests because of a number of different issues (at + # the time of writing): + # - No `alloc::sync` + # - Values of type `[u8; 32768]` are too big + # + # To try for yourself, replace `-Zbuild-std=core` with `-Zbuild-std` and + # add `--tests`. + - name: Check avr-none target + run: RUSTFLAGS='-C target-cpu=atmega328p' ./cargo.sh +nightly check --target=avr-none -Zbuild-std=core --features simd,simd-nightly,float-nightly,derive + - name: Clippy check avr-none target + run: RUSTFLAGS='-C target-cpu=atmega328p' ./cargo.sh +nightly clippy --target=avr-none -Zbuild-std=core --features simd,simd-nightly,float-nightly,derive + check_fmt: runs-on: ubuntu-latest name: Check Rust formatting @@ -761,7 +800,7 @@ jobs: # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks if: failure() runs-on: ubuntu-latest - needs: [build_test, kani,check_be_aarch64 , check_fmt, check_readme, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks] + needs: [build_test, kani, check_be_aarch64, check_avr_artmega, check_fmt, check_readme, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks] steps: - name: Mark the job as failed run: exit 1 diff --git a/src/util/macro_util.rs b/src/util/macro_util.rs index 3881d2bf45..70a2064ae5 100644 --- a/src/util/macro_util.rs +++ b/src/util/macro_util.rs @@ -25,6 +25,7 @@ use core::{ // TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this // `cfg` when `size_of_val_raw` is stabilized. #[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)] +#[cfg(not(target_pointer_width = "16"))] use core::ptr; use crate::{ @@ -105,11 +106,13 @@ impl MaxAlignsOf { } #[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)] +#[cfg(not(target_pointer_width = "16"))] const _64K: usize = 1 << 16; // TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this // `cfg` when `size_of_val_raw` is stabilized. #[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)] +#[cfg(not(target_pointer_width = "16"))] #[repr(C, align(65536))] struct Aligned64kAllocation([u8; _64K]); @@ -122,6 +125,7 @@ struct Aligned64kAllocation([u8; _64K]); // TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this // `cfg` when `size_of_val_raw` is stabilized. #[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)] +#[cfg(not(target_pointer_width = "16"))] pub const ALIGNED_64K_ALLOCATION: NonNull<[u8]> = { const REF: &Aligned64kAllocation = &Aligned64kAllocation([0; _64K]); let ptr: *const Aligned64kAllocation = REF;