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

Stephen Rothwell posted 1 patch 1 year ago
There is a newer version of this series
rust/kernel/miscdevice.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
linux-next: build failure after merge of the rust tree
Posted by Stephen Rothwell 1 year ago
Hi all,

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

error[E0423]: expected function, found macro `kernel::build_error`
   --> rust/kernel/miscdevice.rs:159:9
    |
159 |         kernel::build_error(VTABLE_DEFAULT_ERROR)
    |         ^^^^^^^^^^^^^^^^^^^ not a function
    |
help: use `!` to invoke the macro
    |
159 |         kernel::build_error!(VTABLE_DEFAULT_ERROR)
    |                            +
help: consider importing one of these functions instead
    |
11  + use crate::build_assert::build_error;
    |
11  + use build_error::build_error;
    |
help: if you import `build_error`, refer to it directly
    |
159 -         kernel::build_error(VTABLE_DEFAULT_ERROR)
159 +         build_error(VTABLE_DEFAULT_ERROR)
    |

error: aborting due to 1 previous error

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

Caused by commit

  614724e780f5 ("rust: kernel: move `build_error` hidden function to prevent mistakes")

interacting with commit

  5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")

from the driver-core tree.

I have added the following merge resolution patch.

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Fri, 10 Jan 2025 16:02:19 +1100
Subject: [PATCH] fix up for "rust: kernel: move `build_error` hidden function
 to prevent mistakes"

interacting with commit

  5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")

from the driver-core tree.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 rust/kernel/miscdevice.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index 9685e50b100d..3ba018651bc0 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -156,7 +156,7 @@ fn show_fdinfo(
         _m: &SeqFile,
         _file: &File,
     ) {
-        kernel::build_error(VTABLE_DEFAULT_ERROR)
+        build_error!(VTABLE_DEFAULT_ERROR)
     }
 }
 
-- 
2.45.2

-- 
Cheers,
Stephen Rothwell
Re: linux-next: build failure after merge of the rust tree
Posted by Alice Ryhl 1 year ago
On Fri, Jan 10, 2025 at 6:28 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi all,
>
> After merging the rust tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> error[E0423]: expected function, found macro `kernel::build_error`
>    --> rust/kernel/miscdevice.rs:159:9
>     |
> 159 |         kernel::build_error(VTABLE_DEFAULT_ERROR)
>     |         ^^^^^^^^^^^^^^^^^^^ not a function
>     |
> help: use `!` to invoke the macro
>     |
> 159 |         kernel::build_error!(VTABLE_DEFAULT_ERROR)
>     |                            +
> help: consider importing one of these functions instead
>     |
> 11  + use crate::build_assert::build_error;
>     |
> 11  + use build_error::build_error;
>     |
> help: if you import `build_error`, refer to it directly
>     |
> 159 -         kernel::build_error(VTABLE_DEFAULT_ERROR)
> 159 +         build_error(VTABLE_DEFAULT_ERROR)
>     |
>
> error: aborting due to 1 previous error
>
> For more information about this error, try `rustc --explain E0423`.
>
> Caused by commit
>
>   614724e780f5 ("rust: kernel: move `build_error` hidden function to prevent mistakes")
>
> interacting with commit
>
>   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
>
> from the driver-core tree.
>
> I have added the following merge resolution patch.
>
> From: Stephen Rothwell <sfr@canb.auug.org.au>
> Date: Fri, 10 Jan 2025 16:02:19 +1100
> Subject: [PATCH] fix up for "rust: kernel: move `build_error` hidden function
>  to prevent mistakes"
>
> interacting with commit
>
>   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
>
> from the driver-core tree.
>
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
>  rust/kernel/miscdevice.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> index 9685e50b100d..3ba018651bc0 100644
> --- a/rust/kernel/miscdevice.rs
> +++ b/rust/kernel/miscdevice.rs
> @@ -156,7 +156,7 @@ fn show_fdinfo(
>          _m: &SeqFile,
>          _file: &File,
>      ) {
> -        kernel::build_error(VTABLE_DEFAULT_ERROR)
> +        build_error!(VTABLE_DEFAULT_ERROR)
>      }
>  }

Thank you, this fix is correct. Greg, can you pick this up directly,
or do you want a real patch?

Alice
Re: linux-next: build failure after merge of the rust tree
Posted by Greg Kroah-Hartman 1 year ago
On Fri, Jan 10, 2025 at 10:28:46AM +0100, Alice Ryhl wrote:
> On Fri, Jan 10, 2025 at 6:28 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Hi all,
> >
> > After merging the rust tree, today's linux-next build (x86_64
> > allmodconfig) failed like this:
> >
> > error[E0423]: expected function, found macro `kernel::build_error`
> >    --> rust/kernel/miscdevice.rs:159:9
> >     |
> > 159 |         kernel::build_error(VTABLE_DEFAULT_ERROR)
> >     |         ^^^^^^^^^^^^^^^^^^^ not a function
> >     |
> > help: use `!` to invoke the macro
> >     |
> > 159 |         kernel::build_error!(VTABLE_DEFAULT_ERROR)
> >     |                            +
> > help: consider importing one of these functions instead
> >     |
> > 11  + use crate::build_assert::build_error;
> >     |
> > 11  + use build_error::build_error;
> >     |
> > help: if you import `build_error`, refer to it directly
> >     |
> > 159 -         kernel::build_error(VTABLE_DEFAULT_ERROR)
> > 159 +         build_error(VTABLE_DEFAULT_ERROR)
> >     |
> >
> > error: aborting due to 1 previous error
> >
> > For more information about this error, try `rustc --explain E0423`.
> >
> > Caused by commit
> >
> >   614724e780f5 ("rust: kernel: move `build_error` hidden function to prevent mistakes")
> >
> > interacting with commit
> >
> >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> >
> > from the driver-core tree.
> >
> > I have added the following merge resolution patch.
> >
> > From: Stephen Rothwell <sfr@canb.auug.org.au>
> > Date: Fri, 10 Jan 2025 16:02:19 +1100
> > Subject: [PATCH] fix up for "rust: kernel: move `build_error` hidden function
> >  to prevent mistakes"
> >
> > interacting with commit
> >
> >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> >
> > from the driver-core tree.
> >
> > Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > ---
> >  rust/kernel/miscdevice.rs | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> > index 9685e50b100d..3ba018651bc0 100644
> > --- a/rust/kernel/miscdevice.rs
> > +++ b/rust/kernel/miscdevice.rs
> > @@ -156,7 +156,7 @@ fn show_fdinfo(
> >          _m: &SeqFile,
> >          _file: &File,
> >      ) {
> > -        kernel::build_error(VTABLE_DEFAULT_ERROR)
> > +        build_error!(VTABLE_DEFAULT_ERROR)
> >      }
> >  }
> 
> Thank you, this fix is correct. Greg, can you pick this up directly,
> or do you want a real patch?

Can I take this as a real patch for my tree?  Or is this only an issue
due to the trees being merged?

thanks,

greg k-h
Re: linux-next: build failure after merge of the rust tree
Posted by Miguel Ojeda 1 year ago
On Fri, Jan 10, 2025 at 10:34 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> Can I take this as a real patch for my tree?  Or is this only an issue
> due to the trees being merged?

The issue appears when the trees are merged, i.e. the code is on its
own OK, though it is also true the code should be using the function
but the macro (even if both work), so you could take the patch as an
independent cleanup to the tree, I guess. In that case, I would clean
the 3 cases (i.e. adding `!` but not removing `kernel::`).

I can also drop a couple bits in `rust-next` and do the cleanup early
next cycle.

Context:

    15f2f9313a39 ("rust: use the `build_error!` macro, not the hidden function")
    614724e780f5 ("rust: kernel: move `build_error` hidden function to
prevent mistakes")

Thanks!

Cheers,
Miguel
Re: linux-next: build failure after merge of the rust tree
Posted by Miguel Ojeda 1 year ago
On Fri, Jan 10, 2025 at 11:16 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> independent cleanup to the tree, I guess. In that case, I would clean
> the 3 cases (i.e. adding `!` but not removing `kernel::`).

The patch that Alice sent for this looks good.

Stephen: I did a quick build test with a merge with `rust-next` using
the following resolution (attached).

Cheers,
Miguel
Re: linux-next: build failure after merge of the rust tree
Posted by Alice Ryhl 1 year ago
On Fri, Jan 10, 2025 at 10:34 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Jan 10, 2025 at 10:28:46AM +0100, Alice Ryhl wrote:
> > On Fri, Jan 10, 2025 at 6:28 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > >
> > > Hi all,
> > >
> > > After merging the rust tree, today's linux-next build (x86_64
> > > allmodconfig) failed like this:
> > >
> > > error[E0423]: expected function, found macro `kernel::build_error`
> > >    --> rust/kernel/miscdevice.rs:159:9
> > >     |
> > > 159 |         kernel::build_error(VTABLE_DEFAULT_ERROR)
> > >     |         ^^^^^^^^^^^^^^^^^^^ not a function
> > >     |
> > > help: use `!` to invoke the macro
> > >     |
> > > 159 |         kernel::build_error!(VTABLE_DEFAULT_ERROR)
> > >     |                            +
> > > help: consider importing one of these functions instead
> > >     |
> > > 11  + use crate::build_assert::build_error;
> > >     |
> > > 11  + use build_error::build_error;
> > >     |
> > > help: if you import `build_error`, refer to it directly
> > >     |
> > > 159 -         kernel::build_error(VTABLE_DEFAULT_ERROR)
> > > 159 +         build_error(VTABLE_DEFAULT_ERROR)
> > >     |
> > >
> > > error: aborting due to 1 previous error
> > >
> > > For more information about this error, try `rustc --explain E0423`.
> > >
> > > Caused by commit
> > >
> > >   614724e780f5 ("rust: kernel: move `build_error` hidden function to prevent mistakes")
> > >
> > > interacting with commit
> > >
> > >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> > >
> > > from the driver-core tree.
> > >
> > > I have added the following merge resolution patch.
> > >
> > > From: Stephen Rothwell <sfr@canb.auug.org.au>
> > > Date: Fri, 10 Jan 2025 16:02:19 +1100
> > > Subject: [PATCH] fix up for "rust: kernel: move `build_error` hidden function
> > >  to prevent mistakes"
> > >
> > > interacting with commit
> > >
> > >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> > >
> > > from the driver-core tree.
> > >
> > > Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > > ---
> > >  rust/kernel/miscdevice.rs | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> > > index 9685e50b100d..3ba018651bc0 100644
> > > --- a/rust/kernel/miscdevice.rs
> > > +++ b/rust/kernel/miscdevice.rs
> > > @@ -156,7 +156,7 @@ fn show_fdinfo(
> > >          _m: &SeqFile,
> > >          _file: &File,
> > >      ) {
> > > -        kernel::build_error(VTABLE_DEFAULT_ERROR)
> > > +        build_error!(VTABLE_DEFAULT_ERROR)
> > >      }
> > >  }
> >
> > Thank you, this fix is correct. Greg, can you pick this up directly,
> > or do you want a real patch?
>
> Can I take this as a real patch for my tree?  Or is this only an issue
> due to the trees being merged?

You can take it as a real patch. That will make your tree compile both
with and without rust-next merged.

Though I guess it would be nice to update all three instances of
build_error! if we make a real patch. (The other two instances are
updated in rust-next, so they don't cause the failure.)

Alice
Re: linux-next: build failure after merge of the rust tree
Posted by Miguel Ojeda 1 year ago
On Fri, Jan 10, 2025 at 10:41 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> You can take it as a real patch. That will make your tree compile both
> with and without rust-next merged.

I don't think it builds without `rust-next` since the tree does not
have `build_error!` imported (from the prelude).

Greg: if you want to pick it as a patch, please do instead:

-        kernel::build_error(VTABLE_DEFAULT_ERROR)
+        kernel::build_error!(VTABLE_DEFAULT_ERROR).

Cheers,
Miguel
Re: linux-next: build failure after merge of the rust tree
Posted by Alice Ryhl 1 year ago
On Fri, Jan 10, 2025 at 10:41 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> On Fri, Jan 10, 2025 at 10:34 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Jan 10, 2025 at 10:28:46AM +0100, Alice Ryhl wrote:
> > > On Fri, Jan 10, 2025 at 6:28 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > After merging the rust tree, today's linux-next build (x86_64
> > > > allmodconfig) failed like this:
> > > >
> > > > error[E0423]: expected function, found macro `kernel::build_error`
> > > >    --> rust/kernel/miscdevice.rs:159:9
> > > >     |
> > > > 159 |         kernel::build_error(VTABLE_DEFAULT_ERROR)
> > > >     |         ^^^^^^^^^^^^^^^^^^^ not a function
> > > >     |
> > > > help: use `!` to invoke the macro
> > > >     |
> > > > 159 |         kernel::build_error!(VTABLE_DEFAULT_ERROR)
> > > >     |                            +
> > > > help: consider importing one of these functions instead
> > > >     |
> > > > 11  + use crate::build_assert::build_error;
> > > >     |
> > > > 11  + use build_error::build_error;
> > > >     |
> > > > help: if you import `build_error`, refer to it directly
> > > >     |
> > > > 159 -         kernel::build_error(VTABLE_DEFAULT_ERROR)
> > > > 159 +         build_error(VTABLE_DEFAULT_ERROR)
> > > >     |
> > > >
> > > > error: aborting due to 1 previous error
> > > >
> > > > For more information about this error, try `rustc --explain E0423`.
> > > >
> > > > Caused by commit
> > > >
> > > >   614724e780f5 ("rust: kernel: move `build_error` hidden function to prevent mistakes")
> > > >
> > > > interacting with commit
> > > >
> > > >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> > > >
> > > > from the driver-core tree.
> > > >
> > > > I have added the following merge resolution patch.
> > > >
> > > > From: Stephen Rothwell <sfr@canb.auug.org.au>
> > > > Date: Fri, 10 Jan 2025 16:02:19 +1100
> > > > Subject: [PATCH] fix up for "rust: kernel: move `build_error` hidden function
> > > >  to prevent mistakes"
> > > >
> > > > interacting with commit
> > > >
> > > >   5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
> > > >
> > > > from the driver-core tree.
> > > >
> > > > Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > > > ---
> > > >  rust/kernel/miscdevice.rs | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> > > > index 9685e50b100d..3ba018651bc0 100644
> > > > --- a/rust/kernel/miscdevice.rs
> > > > +++ b/rust/kernel/miscdevice.rs
> > > > @@ -156,7 +156,7 @@ fn show_fdinfo(
> > > >          _m: &SeqFile,
> > > >          _file: &File,
> > > >      ) {
> > > > -        kernel::build_error(VTABLE_DEFAULT_ERROR)
> > > > +        build_error!(VTABLE_DEFAULT_ERROR)
> > > >      }
> > > >  }
> > >
> > > Thank you, this fix is correct. Greg, can you pick this up directly,
> > > or do you want a real patch?
> >
> > Can I take this as a real patch for my tree?  Or is this only an issue
> > due to the trees being merged?
>
> You can take it as a real patch. That will make your tree compile both
> with and without rust-next merged.
>
> Though I guess it would be nice to update all three instances of
> build_error! if we make a real patch. (The other two instances are
> updated in rust-next, so they don't cause the failure.)

Actually, it looks like I am mistaken. This patch doesn't build without
https://lore.kernel.org/all/20241123222849.350287-3-ojeda@kernel.org/

I'll send a real patch.

Alice
[PATCH] miscdevice: rust: use build_error! macro instead of function
Posted by Alice Ryhl 1 year ago
The function called build_error is an implementation detail of the macro
of the same name. Thus, update miscdevice to use the macro rather than
the function. See [1] for more information on this.

This use the macro with the kernel:: prefix as it has not yet been added
to the prelude.

Link: https://lore.kernel.org/all/20241123222849.350287-2-ojeda@kernel.org/ [1]
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
 rust/kernel/miscdevice.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index ebc82e7dfc80..dfb363630c70 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -134,7 +134,7 @@ fn ioctl(
         _cmd: u32,
         _arg: usize,
     ) -> Result<isize> {
-        kernel::build_error(VTABLE_DEFAULT_ERROR)
+        kernel::build_error!(VTABLE_DEFAULT_ERROR)
     }
 
     /// Handler for ioctls.
@@ -151,7 +151,7 @@ fn compat_ioctl(
         _cmd: u32,
         _arg: usize,
     ) -> Result<isize> {
-        kernel::build_error(VTABLE_DEFAULT_ERROR)
+        kernel::build_error!(VTABLE_DEFAULT_ERROR)
     }
 
     /// Show info for this fd.
@@ -160,7 +160,7 @@ fn show_fdinfo(
         _m: &SeqFile,
         _file: &File,
     ) {
-        kernel::build_error(VTABLE_DEFAULT_ERROR)
+        kernel::build_error!(VTABLE_DEFAULT_ERROR)
     }
 }
 

base-commit: 7687c66c18c66d4ccd9949c6f641c0e7b5773483
-- 
2.47.1.613.gc27f4b7a9f-goog
Re: [PATCH] miscdevice: rust: use build_error! macro instead of function
Posted by Miguel Ojeda 1 year ago
On Fri, Jan 10, 2025 at 11:15 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> The function called build_error is an implementation detail of the macro
> of the same name. Thus, update miscdevice to use the macro rather than
> the function. See [1] for more information on this.
>
> This use the macro with the kernel:: prefix as it has not yet been added
> to the prelude.

Typo: "These"

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Thanks!

Cheers,
Miguel
Re: [PATCH] miscdevice: rust: use build_error! macro instead of function
Posted by Greg KH 1 year ago
On Fri, Jan 10, 2025 at 11:38:10AM +0100, Miguel Ojeda wrote:
> On Fri, Jan 10, 2025 at 11:15 AM Alice Ryhl <aliceryhl@google.com> wrote:
> >
> > The function called build_error is an implementation detail of the macro
> > of the same name. Thus, update miscdevice to use the macro rather than
> > the function. See [1] for more information on this.
> >
> > This use the macro with the kernel:: prefix as it has not yet been added
> > to the prelude.
> 
> Typo: "These"
> 
> Acked-by: Miguel Ojeda <ojeda@kernel.org>

And I'll add a Reported-by: line when I apply this in a few minutes,
thanks!

greg k-h
Re: [PATCH] miscdevice: rust: use build_error! macro instead of function
Posted by Alice Ryhl 1 year ago
On Fri, Jan 10, 2025 at 1:23 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Fri, Jan 10, 2025 at 11:38:10AM +0100, Miguel Ojeda wrote:
> > On Fri, Jan 10, 2025 at 11:15 AM Alice Ryhl <aliceryhl@google.com> wrote:
> > >
> > > The function called build_error is an implementation detail of the macro
> > > of the same name. Thus, update miscdevice to use the macro rather than
> > > the function. See [1] for more information on this.
> > >
> > > This use the macro with the kernel:: prefix as it has not yet been added
> > > to the prelude.
> >
> > Typo: "These"
> >
> > Acked-by: Miguel Ojeda <ojeda@kernel.org>
>
> And I'll add a Reported-by: line when I apply this in a few minutes,
> thanks!

Good call, thanks!