Skip to contentSkip to conversation

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

DISCUSSION Stephen Rothwell 3 participants 9 messages Nov 11, 2024 – Nov 12, 2024 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hi all,

My first rust build error! ;-)

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

error[E0308]: mismatched types

     --> rust/kernel/device.rs:176:17
      |
175   |             bindings::_dev_printk(
      |             --------------------- arguments to this function are incorrect
176   |                 klevel as *const _ as *const core::ffi::c_char,
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
      |
      = note: expected raw pointer `*const u8`
                 found raw pointer `*const i8`
note: function defined here
     --> /home/sfr/next/x86_64_allmodconfig/rust/bindings/bindings_generated.rs:60521:12
      |
60521 |     pub fn _dev_printk(level: *const ffi::c_char, dev: *const device, fmt: *const ffi::c_char, ...);
      |            ^^^^^^^^^^^

error[E0308]: mismatched types
--> rust/kernel/miscdevice.rs:159:52

    |
159 |             unlocked_ioctl: maybe_fn(T::HAS_IOCTL, fops_ioctl::<T>),
    |                             --------               ^^^^^^^^^^^^^^^ expected fn pointer, found fn item
    |                             |
    |                             arguments to this function are incorrect
    |
    = note: expected fn pointer `unsafe extern "C" fn(_, _, usize) -> isize`
                  found fn item `unsafe extern "C" fn(_, _, u64) -> i64 {fops_ioctl::<T>}`
help: the return type of this call is `unsafe extern "C" fn(*mut bindings::file, u32, u64) -> i64 {fops_ioctl::<T>}` due to the type of the argument passed
   --> rust/kernel/miscdevice.rs:159:29
    |
159 |             unlocked_ioctl: maybe_fn(T::HAS_IOCTL, fops_ioctl::<T>),
    |                             ^^^^^^^^^^^^^^^^^^^^^^^---------------^
    |                                                    |
    |                                                    this argument influences the return type of `maybe_fn`
note: function defined here
   --> rust/kernel/miscdevice.rs:144:14
    |
144 |     const fn maybe_fn<T: Copy>(check: bool, func: T) -> Option<T> {
    |              ^^^^^^^^                       -------

error[E0308]: mismatched types
--> rust/kernel/miscdevice.rs:162:22

    |
162 |                 Some(fops_compat_ioctl::<T>)
    |                 ---- ^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
    |                 |
    |                 arguments to this enum variant are incorrect
    |
    = note: expected fn pointer `unsafe extern "C" fn(_, _, usize) -> isize`
                  found fn item `unsafe extern "C" fn(_, _, u64) -> i64 {fops_compat_ioctl::<T>}`
help: the type constructed contains `unsafe extern "C" fn(*mut bindings::file, u32, u64) -> i64 {fops_compat_ioctl::<T>}` due to the type of the argument passed
   --> rust/kernel/miscdevice.rs:162:17
    |
162 |                 Some(fops_compat_ioctl::<T>)
    |                 ^^^^^----------------------^
    |                      |
    |                      this argument influences the type of `Some`
note: tuple variant defined here
   --> /usr/lib/rustlib/src/rust/library/core/src/option.rs:579:5
    |
579 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^

error[E0308]: mismatched types
--> rust/kernel/security.rs:36:13

   |
32 |         to_result(unsafe { bindings::security_secid_to_secctx(secid, &mut secdata, &mut seclen) })?;
   |                                                                           ------- here the type of `secdata` is inferred to be `*mut u8`
...
36 |             secdata,
   |             ^^^^^^^ expected `*mut i8`, found `*mut u8`
   |

= note: expected raw pointer *mut i8
found raw pointer *mut u8

error[E0308]: mismatched types

     --> rust/kernel/security.rs:72:52
      |
72    |         unsafe { bindings::security_release_secctx(self.secdata, self.seclen as u32) };
      |                  --------------------------------- ^^^^^^^^^^^^ expected `*mut u8`, found `*mut i8`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut u8`
                 found raw pointer `*mut i8`
note: function defined here
     --> /home/sfr/next/x86_64_allmodconfig/rust/bindings/bindings_generated.rs:87586:12
      |
87586 |     pub fn security_release_secctx(secdata: *mut ffi::c_char, seclen: u32_);
      |            ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

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

Presumably caused by my merge resolutions involving commit

d072acda4862 ("rust: use custom FFI integer types")

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

Any help with the merge resolutions would be much appreciated.

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

My first rust build error! ;-)

:)

Quoted 10 lines

error[E0308]: mismatched types

     --> rust/kernel/device.rs:176:17
      |
175   |             bindings::_dev_printk(
      |             --------------------- arguments to this function are incorrect
176   |                 klevel as *const _ as *const core::ffi::c_char,
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
      |

= note: expected raw pointer *const u8
found raw pointer *const i8

Yeah, sorry about that, this had very high chances of happening. For instance, here we would need crate::ffi::c_char.

I am thinking perhaps the easiest way for everyone is to take for the moment only the patches up to introducing the new ffi:: crate (which includes most of the changes), i.e. up to commit d072acda4862 ("rust:
use custom FFI integer types") but without doing the big remapping just yet, so that others have it available for their branches, and then take that last part later, ideally early in a cycle.

Gary: what do you think?

Thanks!

(Relatedly, I have been thinking of moving the c_* types into the prelude).

Cheers,
Miguel

#2 lore raw
Quoted 5 lines · Miguel Ojeda

moment only the patches up to introducing the new ffi:: crate (which includes most of the changes), i.e. up to commit d072acda4862 ("rust:
use custom FFI integer types") but without doing the big remapping just yet, so that others have it available for their branches, and

"without doing the big remapping" is ambiguous -- I meant "actual remapping", i.e. taking the commit as-is without the next commit, since we should be able to do most of the renames already.

But the other interpretation, i.e. skipping most of the changes/renames core -> ffi in that commit and do those later when we do the actual remapping (which is most of the changes, in fact), is also fine. They are not needed right away.

I will check how it would look like on top of next.

Cheers,
Miguel

#3 lore raw
Quoted 11 lines · On Mon, 11 Nov 2024 09:28:53 +0100 Miguel Ojeda…
Quoted 5 lines · Miguel Ojeda

moment only the patches up to introducing the new ffi:: crate (which includes most of the changes), i.e. up to commit d072acda4862 ("rust:
use custom FFI integer types") but without doing the big remapping just yet, so that others have it available for their branches, and

"without doing the big remapping" is ambiguous -- I meant "actual remapping", i.e. taking the commit as-is without the next commit, since we should be able to do most of the renames already.

That sounds reasonable to me. So for next cycles we have a commit that fixes up remaining renames, and then apply the other commits?

Best,
Gary

Quoted 10 lines

But the other interpretation, i.e. skipping most of the changes/renames core -> ffi in that commit and do those later when we do the actual remapping (which is most of the changes, in fact), is also fine. They are not needed right away.

I will check how it would look like on top of next.

Cheers,
Miguel

#4 lore raw
Quoted 3 lines · Gary Guo

That sounds reasonable to me. So for next cycles we have a commit that fixes up remaining renames, and then apply the other commits?

Yeah -- that way at least we get the new infrastructure there.

We may need to give other trees a branch with the commits that change the mapping, so that they can write new code that does not break when we all merge.

Or perhaps we may just simplify and do a final remapping right after a merge window as a special case even if it is not a pure fix -- that would be easier to successfully do at once.

Either that or we do something fancier to avoid a flag day, but hopefully we will not need it.

Thanks!

Cheers,
Miguel

#5 lore raw
In reply to Miguel Ojeda
Quoted 3 lines · Miguel Ojeda

remapping", i.e. taking the commit as-is without the next commit, since we should be able to do most of the renames already.

Stephen: I went with this, since unless I did something wrong, you should see those build failures are gone, i.e. your build resolutions were fine.

The hashes didn't change, I just dropped the top two commits.

You should be able to reuse the resolutions from yesterday.

If needed, we may simplify further, but let's see if this way works.

Thanks!

Cheers,
Miguel

#6 lore raw

Hi Miguel,

Quoted 11 lines · On Tue, 12 Nov 2024 00:58:47 +0100 Miguel Ojeda…
Quoted 3 lines · Miguel Ojeda

remapping", i.e. taking the commit as-is without the next commit, since we should be able to do most of the renames already.

Stephen: I went with this, since unless I did something wrong, you should see those build failures are gone, i.e. your build resolutions were fine.

Quoted 5 lines

The hashes didn't change, I just dropped the top two commits.

You should be able to reuse the resolutions from yesterday.

If needed, we may simplify further, but let's see if this way works.

Thanks, I will let you know.

Signature · 2 lines
Cheers,
Stephen Rothwell
#7 lore raw
In reply to Miguel Ojeda

Hi Miguel,

Quoted 10 lines · On Tue, 12 Nov 2024 00:58:47 +0100 Miguel Ojeda…

Stephen: I went with this, since unless I did something wrong, you should see those build failures are gone, i.e. your build resolutions were fine.

The hashes didn't change, I just dropped the top two commits.

You should be able to reuse the resolutions from yesterday.

If needed, we may simplify further, but let's see if this way works.

Its all good, no build failures and conflicts still there (but rerere took care of those).

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

Its all good, no build failures and conflicts still there (but rerere took care of those).

Great, thanks!

Cheers,
Miguel