Skip to content

Commit ff4a607

Browse files
authored
[ci] Check (but don't test) avr-none target (#2448)
Closes #2400 gherrit-pr-id: I69f30d9256afe91a6cf7619bec2b37b57ce98880
1 parent d769fb9 commit ff4a607

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,45 @@ jobs:
631631
- name: Check big endian for aarch64_be-unknown-linux-gnu target
632632
run: ./cargo.sh +nightly build --target=aarch64_be-unknown-linux-gnu -Zbuild-std --features simd
633633

634+
# We can't use this as part of the build matrix because rustup doesn't support
635+
# the `avr-none` target.
636+
check_avr_artmega:
637+
runs-on: ubuntu-latest
638+
name: Build (zerocopy / nightly / --simd / avr-none)
639+
steps:
640+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
641+
- name: Configure environment variables
642+
run: |
643+
set -eo pipefail
644+
ZC_TOOLCHAIN="$(./cargo.sh --version nightly)"
645+
RUSTFLAGS="$RUSTFLAGS $ZC_NIGHTLY_RUSTFLAGS"
646+
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
647+
echo "ZC_TOOLCHAIN=$ZC_TOOLCHAIN" >> $GITHUB_ENV
648+
- name: Rust Cache
649+
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
650+
with:
651+
key: avr-none
652+
- name: Install stable Rust for use in 'cargo.sh'
653+
uses: dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable
654+
with:
655+
toolchain: stable
656+
- name: Install Rust with nightly toolchain (${{ env.ZC_TOOLCHAIN }})
657+
uses: dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable
658+
with:
659+
toolchain: ${{ env.ZC_TOOLCHAIN }}
660+
components: clippy, rust-src
661+
# NOTE: We cannot check tests because of a number of different issues (at
662+
# the time of writing):
663+
# - No `alloc::sync`
664+
# - Values of type `[u8; 32768]` are too big
665+
#
666+
# To try for yourself, replace `-Zbuild-std=core` with `-Zbuild-std` and
667+
# add `--tests`.
668+
- name: Check avr-none target
669+
run: RUSTFLAGS='-C target-cpu=atmega328p' ./cargo.sh +nightly check --target=avr-none -Zbuild-std=core --features simd,simd-nightly,float-nightly,derive
670+
- name: Clippy check avr-none target
671+
run: RUSTFLAGS='-C target-cpu=atmega328p' ./cargo.sh +nightly clippy --target=avr-none -Zbuild-std=core --features simd,simd-nightly,float-nightly,derive
672+
634673
check_fmt:
635674
runs-on: ubuntu-latest
636675
name: Check Rust formatting
@@ -761,7 +800,7 @@ jobs:
761800
# 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
762801
if: failure()
763802
runs-on: ubuntu-latest
764-
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]
803+
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]
765804
steps:
766805
- name: Mark the job as failed
767806
run: exit 1

src/util/macro_util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use core::{
2525
// TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this
2626
// `cfg` when `size_of_val_raw` is stabilized.
2727
#[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)]
28+
#[cfg(not(target_pointer_width = "16"))]
2829
use core::ptr;
2930

3031
use crate::{
@@ -105,11 +106,13 @@ impl<T, U> MaxAlignsOf<T, U> {
105106
}
106107

107108
#[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)]
109+
#[cfg(not(target_pointer_width = "16"))]
108110
const _64K: usize = 1 << 16;
109111

110112
// TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this
111113
// `cfg` when `size_of_val_raw` is stabilized.
112114
#[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)]
115+
#[cfg(not(target_pointer_width = "16"))]
113116
#[repr(C, align(65536))]
114117
struct Aligned64kAllocation([u8; _64K]);
115118

@@ -122,6 +125,7 @@ struct Aligned64kAllocation([u8; _64K]);
122125
// TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this
123126
// `cfg` when `size_of_val_raw` is stabilized.
124127
#[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)]
128+
#[cfg(not(target_pointer_width = "16"))]
125129
pub const ALIGNED_64K_ALLOCATION: NonNull<[u8]> = {
126130
const REF: &Aligned64kAllocation = &Aligned64kAllocation([0; _64K]);
127131
let ptr: *const Aligned64kAllocation = REF;

0 commit comments

Comments
 (0)