REGRESSION: armv7 build mismatched types
Subsystems (5)
Logs: https://gitlab.postmarketos.org/LogicalErzor/pmaports/-/jobs/1368490
Snip:
||
|EXPORTS rust/exports_core_generated.h| | ||
RUSTC L rust/compiler_builtins.o
||
RUSTC L rust/ffi.o
||
RUSTC L rust/build_error.o
||
RUSTC L rust/pin_init.o
||
RUSTC L rust/bindings.o
||
RUSTC L rust/uapi.o
||
EXPORTS rust/exports_bindings_generated.h
||
RUSTC L rust/kernel.o
||
error[E0308]: mismatched types
||
--> rust/kernel/lib.rs:234:45
||
|
||
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
||
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const drm_device`, found `*mut Opaque<drm_device>`
||
| | |
||
| | expected all arguments to be this `*const drm_device` type because they need to match the type of this parameter
||
| arguments to this function are incorrect
||
|
||
::: rust/kernel/drm/device.rs:140:18
||
|
||
140 | unsafe { crate::container_of!(ptr, Self, dev) }.cast_mut()
||
| ------------------------------------ in this macro invocation
||
|
||= note: expected raw pointer *const drm_device
||
found raw pointer *mut Opaque<drm_device>
||
note: function defined here
||
--> rust/kernel/lib.rs:241:8
||
|
||
241 | pub fn assert_same_type<T>(_: T, _: T) {}
||
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*const drm_device` type of parameter #1
||
| | |
||
| | parameter #2 needs to match the `*const drm_device` type of this parameter
||
| parameter #1 and parameter #2 both reference this parameter `T`
||= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info) ||
error[E0308]: mismatched types
||
--> rust/kernel/lib.rs:234:45
||
|
||
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
||
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>`
||
| | |
||
| | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter
||
| arguments to this function are incorrect
||
|
||
::: rust/kernel/drm/gem/mod.rs:130:20
||
|
||
130 | unsafe { &*crate::container_of!(self_ptr, Object<T>, obj) }
||
| ---------------------------------------------- in this macro invocation
||
|
||= note: expected raw pointer *mut drm_gem_object ||
found raw pointer *mut Opaque<drm_gem_object> ||
note: function defined here
||
--> rust/kernel/lib.rs:241:8
||
|
||
241 | pub fn assert_same_type<T>(_: T, _: T) {}
||
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1
||
| | |
||
| | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter
||
| parameter #1 and parameter #2 both reference this parameter `T`
||= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info) ||
error[E0308]: mismatched types
||
--> rust/kernel/lib.rs:234:45
||
|
||
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
||
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>`
||
| | |
||
| | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter
||
| arguments to this function are incorrect
||
|
||
::: rust/kernel/drm/gem/mod.rs:273:29
||
|
||
273 | let this = unsafe { crate::container_of!(obj, Self, obj) };
||
| ------------------------------------ in this macro invocation
||
|
||= note: expected raw pointer *mut drm_gem_object ||
found raw pointer *mut Opaque<drm_gem_object> ||
note: function defined here
||
--> rust/kernel/lib.rs:241:8
||
|
||
241 | pub fn assert_same_type<T>(_: T, _: T) {}
||
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1
||
| | |
||
| | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter
||
| parameter #1 and parameter #2 both reference this parameter `T`
||= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info) ||
error: aborting due to 3 previous errors
||
For more information about this error, try rustc --explain E0308.
||
make[2]: *** [rust/Makefile:538: rust/kernel.o] Error 1
||
make[1]: *** [/home/pmos/build/src/linux-next-next-20250530/Makefile:1285: prepare] Error 2
||make: *** [Makefile:248: __sub-make] Error 2|
Bad: next-20250530
Good: next-20250528
Likely introduced with: https://lore.kernel.org/all/CANiq72mFiCrzawVUVOU2giJtBVsRdAO3sGtDsZptPuFvmid3EQ@mail.gmail.com/
Repo: https://gitlab.postmarketos.org/LogicalErzor/pmaports/-/tree/rust/device/testing/linux-next
How it's built (Alpine-like build system):
Config fragments (in addition to qcom_defconfig):
Unsure why the formatting got messed up. Retrying a second time (if this doesn't work, please look at the logs and excuse me).
RUSTC L rust/ffi.o
RUSTC L rust/build_error.o
RUSTC L rust/pin_init.o
RUSTC L rust/bindings.o
RUSTC L rust/uapi.o
EXPORTS rust/exports_bindings_generated.h
RUSTC L rust/kernel.o
error[E0308]: mismatched types
--> rust/kernel/lib.rs:234:45
|
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const drm_device`, found `*mut Opaque<drm_device>` | | | | | expected all arguments to be this `*const drm_device` type because they need to match the type of this parameter | arguments to this function are incorrect |
::: rust/kernel/drm/device.rs:140:18
|
140 | unsafe { crate::container_of!(ptr, Self, dev) }.cast_mut() | ------------------------------------ in this macro invocation |
= note: expected raw pointer *const drm_device
found raw pointer *mut Opaque<drm_device>
note: function defined here
--> rust/kernel/lib.rs:241:8
|
241 | pub fn assert_same_type<T>(_: T, _: T) {}
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*const drm_device` type of parameter #1 | | | | | parameter #2 needs to match the `*const drm_device` type of this parameter | parameter #1 and parameter #2 both reference this parameter `T`
= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> rust/kernel/lib.rs:234:45
|
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>` | | | | | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter | arguments to this function are incorrect |
::: rust/kernel/drm/gem/mod.rs:130:20
|
130 | unsafe { &*crate::container_of!(self_ptr, Object<T>, obj) } | ---------------------------------------------- in this macro invocation |
= note: expected raw pointer *mut drm_gem_object
found raw pointer *mut Opaque<drm_gem_object>
note: function defined here
--> rust/kernel/lib.rs:241:8
|
241 | pub fn assert_same_type<T>(_: T, _: T) {}
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1 | | | | | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter | parameter #1 and parameter #2 both reference this parameter `T`
= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> rust/kernel/lib.rs:234:45
|
234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr).$($fields)*).cast_mut());
| ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>` | | | | | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter | arguments to this function are incorrect |
::: rust/kernel/drm/gem/mod.rs:273:29
|
273 | let this = unsafe { crate::container_of!(obj, Self, obj) }; | ------------------------------------ in this macro invocation |
= note: expected raw pointer *mut drm_gem_object
found raw pointer *mut Opaque<drm_gem_object>
note: function defined here
--> rust/kernel/lib.rs:241:8
|
241 | pub fn assert_same_type<T>(_: T, _: T) {}
| ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1 | | | | | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter | parameter #1 and parameter #2 both reference this parameter `T`
= note: this error originates in the macro crate::container_of (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
For more information about this error, try rustc --explain E0308.
make[2]: *** [rust/Makefile:538: rust/kernel.o] Error 1
make[1]: *** [/home/pmos/build/src/linux-next-next-20250530/Makefile:1285: prepare] Error 2
make: *** [Makefile:248: __sub-make] Error 2
Thorsten Leemhuis
maintainerCCing linux-next and Tamir Duberstein, who authored the culprit.
Quoted 4 lines · Rudraksha Gupta
Logs: https://gitlab.postmarketos.org/LogicalErzor/pmaports/-/jobs/1368490
Archive: https://web.archive.org/web/20250530060232/https://
gitlab.postmarketos.org/LogicalErzor/pmaports/-/jobs/1368490/raw
I ran into the same error on aarch64 and x86_64 when building -next for Fedora today using the rawhide config:
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-x86_64/09103515-next-next-all/builder-live.log.gz
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-aarch64/09103515-next-next-all/builder-live.log.gz
Reverting b20fbbc08a363f ("rust: check type of $ptr in container_of!") fixed things. That's the patch Rudraksha suspected to be the root of the problem (see the quote below).
Ciao, Thorsten
Quoted 229 lines
Snip:
||
|EXPORTS rust/exports_core_generated.h| | ||RUSTC L
rust/compiler_builtins.o
||
RUSTC Lrust/ffi.o
||
RUSTC Lrust/build_error.o
||
RUSTC Lrust/pin_init.o
||
RUSTC Lrust/bindings.o
||
RUSTC Lrust/uapi.o
||
EXPORTSrust/exports_bindings_generated.h
||
RUSTC Lrust/kernel.o
||
error[E0308]: mismatched types
||
-->rust/kernel/lib.rs:234:45|| | || 234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr). $($fields)*).cast_mut()); || | ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const drm_device`, found `*mut Opaque<drm_device>` || | | | || | | expected all arguments to be this `*const drm_device` type because they need to match the type of this parameter || | arguments to this function are incorrect || | || ::: rust/kernel/drm/device.rs:140:18 || | || 140 | unsafe { crate::container_of!(ptr, Self, dev) }.cast_mut() || | ------------------------------------ in this macro invocation || | ||= note: expected raw pointer
*const drm_device
||
found raw pointer*mut Opaque<drm_device>
||
note: function defined here
||
-->rust/kernel/lib.rs:241:8|| | || 241 | pub fn assert_same_type<T>(_: T, _: T) {} || | ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*const drm_device` type of parameter #1 || | | | || | | parameter #2 needs to match the `*const drm_device` type of this parameter || | parameter #1 and parameter #2 both reference this parameter `T` ||= note: this error originates in the macro
crate::container_of(in Nightly builds, run with -Z macro-backtrace for more info) ||
error[E0308]: mismatched types
||
-->rust/kernel/lib.rs:234:45|| | || 234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr). $($fields)*).cast_mut()); || | ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>` || | | | || | | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter || | arguments to this function are incorrect || | || ::: rust/kernel/drm/gem/mod.rs:130:20 || | || 130 | unsafe { &*crate::container_of!(self_ptr, Object<T>, obj) } || | ---------------------------------------------- in this macro invocation || | ||= note: expected raw pointer
*mut drm_gem_object||
found raw pointer*mut Opaque<drm_gem_object>||
note: function defined here
||
-->rust/kernel/lib.rs:241:8|| | || 241 | pub fn assert_same_type<T>(_: T, _: T) {} || | ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1 || | | | || | | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter || | parameter #1 and parameter #2 both reference this parameter `T` ||= note: this error originates in the macro
crate::container_of(in Nightly builds, run with -Z macro-backtrace for more info) ||
error[E0308]: mismatched types
||
-->rust/kernel/lib.rs:234:45|| | || 234 | $crate::assert_same_type(field_ptr, (&raw const (*container_ptr). $($fields)*).cast_mut()); || | ------------------------ --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut drm_gem_object`, found `*mut Opaque<drm_gem_object>` || | | | || | | expected all arguments to be this `*mut drm_gem_object` type because they need to match the type of this parameter || | arguments to this function are incorrect || | || ::: rust/kernel/drm/gem/mod.rs:273:29 || | || 273 | let this = unsafe { crate::container_of!(obj, Self, obj) }; || | ------------------------------------ in this macro invocation || | ||= note: expected raw pointer
*mut drm_gem_object||
found raw pointer*mut Opaque<drm_gem_object>||
note: function defined here
||
-->rust/kernel/lib.rs:241:8|| | || 241 | pub fn assert_same_type<T>(_: T, _: T) {} || | ^^^^^^^^^^^^^^^^ - ---- ---- this parameter needs to match the `*mut drm_gem_object` type of parameter #1 || | | | || | | parameter #2 needs to match the `*mut drm_gem_object` type of this parameter || | parameter #1 and parameter #2 both reference this parameter `T` ||= note: this error originates in the macro
crate::container_of(in Nightly builds, run with -Z macro-backtrace for more info) ||
error: aborting due to 3 previous errors
||
For more information about this error, tryrustc --explain E0308. ||
make[2]: *** [rust/Makefile:538:rust/kernel.o] Error 1 ||
make[1]: *** [/home/pmos/build/src/linux-next-next-20250530/Makefile:1285: prepare] Error 2
||make: *** [Makefile:248: __sub-make] Error 2|Bad: next-20250530
Good: next-20250528
Likely introduced with: https://lore.kernel.org/all/
CANiq72mFiCrzawVUVOU2giJtBVsRdAO3sGtDsZptPuFvmid3EQ@mail.gmail.com/Repo: https://gitlab.postmarketos.org/LogicalErzor/pmaports/-/tree/rust/
device/testing/linux-nextHow it's built (Alpine-like build system):
Config fragments (in addition to
qcom_defconfig):
Quoted 3 lines · Rudraksha Gupta
Bad: next-20250530
Good: next-20250528
Thanks Rudraksha, the diff attached was needed on merge -- Stephen didn't hit the error in his build so he didn't apply it just in case I think, but it should be fixed in the next tag.
(If the diff doesn't work, of course, please let us know!)
Cheers,
Miguel
rust/kernel/drm/device.rs +2 -0
@@ -135,6 +135,8 @@ pub(crate) fn as_raw(&self) -> *mut bindings::drm_device {/// /// `ptr` must be a valid pointer to a `struct device` embedded in `Self`. unsafe fn from_drm_device (ptr: *const bindings::drm_device ) -> *mut Self { +let ptr: *const Opaque <bindings::drm_device > = ptr.cast (); +// SAFETY: By the safety requirements of this function `ptr` is a valid pointer to a // `struct drm_device` embedded in `Self`. unsafe {crate ::container_of!(ptr,Self , dev) }.cast_mut ()
rust/kernel/drm/gem/mod.rs +5 -1
@@ -125,6 +125,8 @@ fn as_raw(&self) -> *mut bindings::drm_gem_object { }unsafe fn as_ref <'a>(self_ptr: *mut bindings::drm_gem_object ) -> &'aSelf { +let self_ptr: *mut Opaque <bindings::drm_gem_object > = self_ptr.cast (); +// SAFETY: `obj` is guaranteed to be in an `Object<T>` via the safety contract of this // function unsafe { &*crate ::container_of!(self_ptr,Object <T >, obj) }
@@ -269,8 +271,10 @@ fn as_raw(&self) -> *mut bindings::drm_gem_object { }extern "C" fn free_callback (obj: *mut bindings::drm_gem_object ) { +let ptr: *mut Opaque <bindings::drm_gem_object > = obj.cast (); +// SAFETY: All of our objects are of type `Object<T>`. -let this =unsafe {crate ::container_of!(obj,Self , obj) }; +let this =unsafe {crate ::container_of!(ptr,Self , obj) };// SAFETY: The C code only ever calls this callback with a valid pointer to a `struct // drm_gem_object`.
Thorsten Leemhuis
maintainerQuoted 8 lines · Miguel Ojeda
Quoted 3 lines · Rudraksha Gupta
Bad: next-20250530
Good: next-20250528Thanks Rudraksha, the diff attached was needed on merge -- Stephen didn't hit the error in his build so he didn't apply it just in case I think, but it should be fixed in the next tag.
Stephen, would be nice to see this picked up for -next, as I ran into the error described at the start of the thread again with todays -next on Fedora x86_64 and aarch64 using a Fedora rawhide config.
Or is this heading towards mainline really soon now anyway?
Quoted 1 line
(If the diff doesn't work, of course, please let us know!)
Thx, it fixed things for me.
Ciao, Thorsten
Quoted 2 lines · Thorsten Leemhuis
Or is this heading towards mainline really soon now anyway?
The Rust PR is, but it would be nice to have the fix in -next before sending the PR (I will give Linus a test merge anyway, but it is nice to know everything is OK in -next too, and to have another reference point for Linus).
Quoted 1 line
Thx, it fixed things for me.
Thanks for checking!
Cheers,
Miguel
Hi Miguel,
Quoted 9 lines · On Tue, 3 Jun 2025 15:04:02 +0200 Miguel Ojeda…
Quoted 2 lines · Thorsten Leemhuis
Or is this heading towards mainline really soon now anyway?
The Rust PR is, but it would be nice to have the fix in -next before sending the PR (I will give Linus a test merge anyway, but it is nice to know everything is OK in -next too, and to have another reference point for Linus).
Damn! I knew I would forget. Sorry about that, it will be applied today.
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 3 lines · Stephen Rothwell
Damn! I knew I would forget. Sorry about that, it will be applied today.
No worries! If you prefer that I send a reminder in this kind of cases, I would be happy to do so.
Thanks!
Cheers,
Miguel
Quoted 3 lines · Stephen Rothwell
Damn! I knew I would forget. Sorry about that, it will be applied today.
Looks good to me today, thanks!
Rudraksha/Thorsten: the error should be gone from your builds now.
Cheers,
Miguel
Perfect! Works for me now, thanks :)
Thanks,
Rudraksha