public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
@ 2024-04-29 11:21 gregkh
  2024-04-29 11:25 ` Miguel Ojeda
  0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2024-04-29 11:21 UTC (permalink / raw)
  To: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina; +Cc: stable


The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x ded103c7eb23753f22597afa500a7c1ad34116ba
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2024042909-whimsical-drapery-40d1@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:

ded103c7eb23 ("kbuild: rust: force `alloc` extern to allow "empty" Rust files")
295d8398c67e ("kbuild: specify output names separately for each emission type from rustc")
16169a47d5c3 ("kbuild: refactor host*_flags")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ded103c7eb23753f22597afa500a7c1ad34116ba Mon Sep 17 00:00:00 2001
From: Miguel Ojeda <ojeda@kernel.org>
Date: Mon, 22 Apr 2024 11:06:44 +0200
Subject: [PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust
 files

If one attempts to build an essentially empty file somewhere in the
kernel tree, it leads to a build error because the compiler does not
recognize the `new_uninit` unstable feature:

    error[E0635]: unknown feature `new_uninit`
     --> <crate attribute>:1:9
      |
    1 | feature(new_uninit)
      |         ^^^^^^^^^^

The reason is that we pass `-Zcrate-attr='feature(new_uninit)'` (together
with `-Zallow-features=new_uninit`) to let non-`rust/` code use that
unstable feature.

However, the compiler only recognizes the feature if the `alloc` crate
is resolved (the feature is an `alloc` one). `--extern alloc`, which we
pass, is not enough to resolve the crate.

Introducing a reference like `use alloc;` or `extern crate alloc;`
solves the issue, thus this is not seen in normal files. For instance,
`use`ing the `kernel` prelude introduces such a reference, since `alloc`
is used inside.

While normal use of the build system is not impacted by this, it can still
be fairly confusing for kernel developers [1], thus use the unstable
`force` option of `--extern` [2] (added in Rust 1.71 [3]) to force the
compiler to resolve `alloc`.

This new unstable feature is only needed meanwhile we use the other
unstable feature, since then we will not need `-Zcrate-attr`.

Cc: stable@vger.kernel.org # v6.6+
Reported-by: Daniel Almeida <daniel.almeida@collabora.com>
Reported-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/x/near/424096982 [1]
Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
Link: https://github.com/rust-lang/rust/issues/111302 [2]
Link: https://github.com/rust-lang/rust/pull/109421 [3]
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20240422090644.525520-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index baf86c0880b6..533a7799fdfe 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -273,7 +273,7 @@ rust_common_cmd = \
 	-Zallow-features=$(rust_allowed_features) \
 	-Zcrate-attr=no_std \
 	-Zcrate-attr='feature($(rust_allowed_features))' \
-	--extern alloc --extern kernel \
+	-Zunstable-options --extern force:alloc --extern kernel \
 	--crate-type rlib -L $(objtree)/rust/ \
 	--crate-name $(basename $(notdir $@)) \
 	--sysroot=/dev/null \


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
  2024-04-29 11:21 FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree gregkh
@ 2024-04-29 11:25 ` Miguel Ojeda
  2024-04-29 11:37   ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2024-04-29 11:25 UTC (permalink / raw)
  To: gregkh; +Cc: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina, stable

On Mon, Apr 29, 2024 at 1:21 PM <gregkh@linuxfoundation.org> wrote:
>
> The patch below does not apply to the 6.1-stable tree.

Yeah, this one was only intended for 6.6+:

> Cc: stable@vger.kernel.org # v6.6+

Was the annotation above incorrect?

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
  2024-04-29 11:25 ` Miguel Ojeda
@ 2024-04-29 11:37   ` Greg KH
  2024-04-29 12:22     ` Miguel Ojeda
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2024-04-29 11:37 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina, stable

On Mon, Apr 29, 2024 at 01:25:37PM +0200, Miguel Ojeda wrote:
> On Mon, Apr 29, 2024 at 1:21 PM <gregkh@linuxfoundation.org> wrote:
> >
> > The patch below does not apply to the 6.1-stable tree.
> 
> Yeah, this one was only intended for 6.6+:
> 
> > Cc: stable@vger.kernel.org # v6.6+
> 
> Was the annotation above incorrect?

That was, but you also say:
	Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
which is in 6.1, so what am I supposed to believe?

Hence the email :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
  2024-04-29 11:37   ` Greg KH
@ 2024-04-29 12:22     ` Miguel Ojeda
  2024-04-29 13:02       ` Miguel Ojeda
  2024-04-29 13:12       ` Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2024-04-29 12:22 UTC (permalink / raw)
  To: Greg KH; +Cc: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina, stable

On Mon, Apr 29, 2024 at 1:37 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> That was, but you also say:
>         Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> which is in 6.1, so what am I supposed to believe?
>
> Hence the email :)

Ah, I see. I thought the annotation "overrides" what could be found
automatically via the `Fixes`.

Let me send them manually then.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
  2024-04-29 12:22     ` Miguel Ojeda
@ 2024-04-29 13:02       ` Miguel Ojeda
  2024-04-29 13:12       ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2024-04-29 13:02 UTC (permalink / raw)
  To: Greg KH; +Cc: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina, stable

On Mon, Apr 29, 2024 at 2:22 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Let me send them manually then.

I see you queued them already for 6.6.y and 6.8.y -- thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree
  2024-04-29 12:22     ` Miguel Ojeda
  2024-04-29 13:02       ` Miguel Ojeda
@ 2024-04-29 13:12       ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2024-04-29 13:12 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: ojeda, aliceryhl, daniel.almeida, gary, julian.stecklina, stable

On Mon, Apr 29, 2024 at 02:22:13PM +0200, Miguel Ojeda wrote:
> On Mon, Apr 29, 2024 at 1:37 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > That was, but you also say:
> >         Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> > which is in 6.1, so what am I supposed to believe?
> >
> > Hence the email :)
> 
> Ah, I see. I thought the annotation "overrides" what could be found
> automatically via the `Fixes`.

When things are confusing, I punt and ask for what to do, especially
because people put commit ids in Fixes and don't always know how far
back those commits really were applied to.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-29 13:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 11:21 FAILED: patch "[PATCH] kbuild: rust: force `alloc` extern to allow "empty" Rust" failed to apply to 6.1-stable tree gregkh
2024-04-29 11:25 ` Miguel Ojeda
2024-04-29 11:37   ` Greg KH
2024-04-29 12:22     ` Miguel Ojeda
2024-04-29 13:02       ` Miguel Ojeda
2024-04-29 13:12       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox