rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
Subsystems (4)
Miguel Ojeda
maintainerPATCH 1/1 rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
For arm32, on a x86_64 builder, running the rusttest target yields:
error[E0080]: evaluation of constant value failed
--> rust/kernel/static_assert.rs:37:23
|
37 | const _: () = ::core::assert!($condition $(,$arg)?);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1
|
::: rust/kernel/sync/atomic/predefine.rs:68:1
|
68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>());
| -------------------------------------------------------------------- in this macro invocation
|
= note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)The reason is that rusttest runs on the host, so for e.g. a x86_64 builder isize is 64 bits but it is not a CONFIG_64BIT build.
Fix it by providing a stub for rusttest as usual.
---
I kept the cfgs separated instead of using all so that, when we get to remove this (since these tests will eventually be moved to KUnit), it will just be line deletions (and I find it easier to read, too).
rust/kernel/sync/atomic/predefine.rs | 11 +++++++++++ 1 file changed, 11 insertions(+)
rust/kernel/sync/atomic/predefine.rs +11 -0
@@ -35,12 +35,23 @@ fn rhs_into_delta(rhs: i64) -> i64 {// as `isize` and `usize`, and `isize` and `usize` are always bi-directional transmutable to // `isize_atomic_repr`, which also always implements `AtomicImpl`. #[allow(non_camel_case_types)] +#[cfg(not(testlib))] #[cfg(not( CONFIG_64BIT ))] type isize_atomic_repr =i32 ;#[allow(non_camel_case_types)] +#[cfg(not(testlib))] #[cfg( CONFIG_64BIT )] type isize_atomic_repr =i64 ; +#[allow(non_camel_case_types)] +#[cfg(testlib)] +#[cfg(target_pointer_width = "32" )] +type isize_atomic_repr =i32 ; +#[allow(non_camel_case_types)] +#[cfg(testlib)] +#[cfg(target_pointer_width = "64" )] +type isize_atomic_repr =i64 ; +// Ensure size and alignment requirements are checked. static_assert! (size_of ::<isize >() ==size_of ::<isize_atomic_repr >());static_assert! (align_of ::<isize >() ==align_of ::<isize_atomic_repr >());
base-commit: a44bfed9df8a514962e2cb076d9c0b594caeff36 --
2.52.0
Quoted 66 lines · On Sat, 24 Jan 2026 00:34:32 +0100 Miguel Ojeda <[email protected]> wrote:
For arm32, on a
x86_64builder, running therusttesttarget yields:error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^the evaluated program panicked at 'assertion failed:
size_of::<isize>() == size_of::<isize_atomic_repr>()',rust/kernel/sync/atomic/predefine.rs:68:1| :::rust/kernel/sync/atomic/predefine.rs:68:1| 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); |
--------------------------------------------------------------------
in this macro invocation | = note: this error originates in the macro::core::assertwhich comes from the expansion of the macrostatic_assert(in Nightly builds, run with -Z macro-backtrace for more info)The reason is that
rusttestruns on the host, so for e.g. ax86_64builderisizeis 64 bits but it is not aCONFIG_64BITbuild.Fix it by providing a stub for
rusttestas usual.Fixes 84c6d36bcaf9 ("rust: sync: atomic: Add Atomic<{usize,isize}>")Signed-off-by Miguel Ojeda <[email protected]>---
I kept thecfgs separated instead of usingallso that, when we get to remove this (since these tests will eventually be moved to KUnit), it will just be line deletions (and I find it easier to read, too).rust/kernel/sync/atomic/predefine.rs | 11 +++++++++++ 1 file changed, 11 insertions(+)(quoted diff) +0
-0
b/rust/kernel/sync/atomic/predefine.rsindex45a17985cda4..0fca1ba3c2db100644 ---a/rust/kernel/sync/atomic/predefine.rs+++b/rust/kernel/sync/atomic/predefine.rs@@ -35,12 +35,23 @@ fnrhs_into_delta(rhs: i64)-> i64 { // asisizeandusize, andisizeandusizeare always bi-directional transmutable to //isize_atomic_repr, which also always implementsAtomicImpl. #[allow(non_camel_case_types)] +#[cfg(not(testlib))]
#[cfg(not(CONFIG_64BIT))]
typeisize_atomic_repr= i32; #[allow(non_camel_case_types)]rust/kernel/sync/atomic/predefine.rs +10
-0+#[cfg(not(testlib))] #[cfg( CONFIG_64BIT )] type isize_atomic_repr =i64 ; +#[allow(non_camel_case_types)] +#[cfg(testlib)] +#[cfg(target_pointer_width = "32" )] +type isize_atomic_repr =i32 ; +#[allow(non_camel_case_types)] +#[cfg(testlib)] +#[cfg(target_pointer_width = "64" )] +type isize_atomic_repr =i64 ; +// Ensure size and alignment requirements are checked. static_assert! (size_of ::<isize >() ==size_of ::<isize_atomic_repr >());static_assert! (align_of ::<isize >() ==align_of::<isize_atomic_repr>());
Quoted 3 lines
base-commit:
a44bfed9df8a514962e2cb076d9c0b594caeff36--
2.52.0
Quoted 16 lines · Miguel Ojeda
For arm32, on a
x86_64builder, running therusttesttarget yields:error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1 | ::: rust/kernel/sync/atomic/predefine.rs:68:1 | 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); | -------------------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
Quoted 8 lines
The reason is that
rusttestruns on the host, so for e.g. ax86_64builderisizeis 64 bits but it is not aCONFIG_64BITbuild.Fix it by providing a stub for
rusttestas usual.Fixes 84c6d36bcaf9 ("rust: sync: atomic: Add Atomic<{usize,isize}>")Signed-off-by Miguel Ojeda <[email protected]>
Boqun et al.: in case it helps, I will send a fixes PR early this week, so if you happen to want me to pick this one up with the rest, please let me know.
Cheers,
Miguel
Boqun Feng
Acked-byQuoted 20 lines · Miguel Ojeda
Quoted 19 lines · Miguel Ojeda
For arm32, on a
x86_64builder, running therusttesttarget yields:error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1 | ::: rust/kernel/sync/atomic/predefine.rs:68:1 | 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); | -------------------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)The reason is that
rusttestruns on the host, so for e.g. ax86_64builderisizeis 64 bits but it is not aCONFIG_64BITbuild.
Quoted 8 lines
Quoted 5 lines
Fix it by providing a stub for
rusttestas usual.Fixes 84c6d36bcaf9 ("rust: sync: atomic: Add Atomic<{usize,isize}>")Signed-off-by Miguel Ojeda <[email protected]>Boqun et al.: in case it helps, I will send a fixes PR early this week, so if you happen to want me to pick this one up with the rest,
Thank you, that'll be great!
Regards,
Boqun
Quoted 4 lines
please let me know.
Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 16 lines · Miguel Ojeda
For arm32, on a
x86_64builder, running therusttesttarget yields:error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1 | ::: rust/kernel/sync/atomic/predefine.rs:68:1 | 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); | -------------------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
Quoted 8 lines
The reason is that
rusttestruns on the host, so for e.g. ax86_64builderisizeis 64 bits but it is not aCONFIG_64BITbuild.Fix it by providing a stub for
rusttestas usual.Fixes 84c6d36bcaf9 ("rust: sync: atomic: Add Atomic<{usize,isize}>")Signed-off-by Miguel Ojeda <[email protected]>
Applied to rust-fixes-- thanks everyone!
Cheers,
Miguel