Skip to contentSkip to conversation

linux-next: build failure after merge of the rust tree

DISCUSSION Stephen Rothwell 3 participants 5 messages Dec 16, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the rust tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> drivers/gpu/drm/drm_panic_qr.rs:961:60

    |
961 |         let url_cstr: &CStr = unsafe { CStr::from_char_ptr(url) };
    |                                        ------------------- ^^^ expected `*const u8`, found `*const i8`
    |                                        |
    |                                        arguments to this function are incorrect
    |

= note: expected raw pointer *const u8
found raw pointer *const i8
note: associated function defined here
--> rust/kernel/str.rs:187:19

    |
187 |     pub unsafe fn from_char_ptr<'a>(ptr: *const crate::ffi::c_char) -> &'a Self {
    |                   ^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

e721cd7570b2 ("rust: map long to isize and char to u8")

I have used the rust tree from next-20241213 for today.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 3 lines · Stephen Rothwell

After merging the rust tree, today's linux-next build (x86_64 allmodconfig) failed like this:

Apologies, fixed now, thanks!

Jocelyn: we are performing the remapping via the new ffi crate in this cycle. I had to add a change to drm_panic_qr.rs to take c_char instead of i8 in drm_panic_qr_generate, so that types match both before and after the remapping. I think this signature would have been better anyway, but please let me know if you disagree!

    https://github.com/Rust-for-Linux/linux/commit/e1157aee5f038c2c91af269cd48653133e99f3fb

(Diff copied below too)

Thanks!

Cheers,
Miguel

[1]

drivers/gpu/drm/drm_panic_qr.rs +1 -1
index ef2d490965ba..bcf248f69252 100644
@@ -931,7 +931,7 @@ fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
 /// They must remain valid for the duration of the function call.
 #[no_mangle]
 pub unsafe extern "C" fn drm_panic_qr_generate(
-    url: *const i8,
+    url: *const kernel::ffi::c_char,
     data: *mut u8,
     data_len: usize,
     data_size: usize,
#2 lore raw
Quoted 13 lines · Miguel Ojeda
Quoted 3 lines · Stephen Rothwell

After merging the rust tree, today's linux-next build (x86_64 allmodconfig) failed like this:

Apologies, fixed now, thanks!

Jocelyn: we are performing the remapping via the new ffi crate in this cycle. I had to add a change to drm_panic_qr.rs to take c_char instead of i8 in drm_panic_qr_generate, so that types match both before and after the remapping. I think this signature would have been better anyway, but please let me know if you disagree!

Quoted 3 lines
     https://github.com/Rust-for-Linux/linux/commit/e1157aee5f038c2c91af269cd48653133e99f3fb

(Diff copied below too)

Yes, I'm fine with that change, thanks for the fix!

Best regards,

Signature · 1 line
Jocelyn
Quoted 22 lines

Thanks!

Cheers,
Miguel

[1]

drivers/gpu/drm/drm_panic_qr.rs +1 -1
index ef2d490965ba..bcf248f69252 100644
@@ -931,7 +931,7 @@ fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
  /// They must remain valid for the duration of the function call.
  #[no_mangle]
  pub unsafe extern "C" fn drm_panic_qr_generate(
-    url: *const i8,
+    url: *const kernel::ffi::c_char,
      data: *mut u8,
      data_len: usize,
      data_size: usize,
#3 lore raw
Quoted 2 lines · Jocelyn Falempe

Yes, I'm fine with that change, thanks for the fix!

Thanks for the quick reply!

May I transform your reply into an Acked-by?

By the way, if you want it as an independent fix that can go to stable too, I am happy to split it into its own (previous) commit and tag it as such. I am not sure if it should be considered a fix, though, since one could argue nothing is "broken" (apart from the type not being the optimal choice).

I am also happy to split it without marking it as a fix, in case you may want to backport it independently as a prerequisite at some point or similar.

Cheers,
Miguel

#4 lore raw
Quoted 7 lines · Miguel Ojeda
Quoted 2 lines · Jocelyn Falempe

Yes, I'm fine with that change, thanks for the fix!

Thanks for the quick reply!

May I transform your reply into an Acked-by?

Sure, please do.

Quoted 6 lines

By the way, if you want it as an independent fix that can go to stable too, I am happy to split it into its own (previous) commit and tag it as such. I am not sure if it should be considered a fix, though, since one could argue nothing is "broken" (apart from the type not being the optimal choice).

Don't spend more time on this trivial fix, it probably won't need to be backported.

Quoted 8 lines

I am also happy to split it without marking it as a fix, in case you may want to backport it independently as a prerequisite at some point or similar.

Cheers,
Miguel

Thanks,

--

Jocelyn