[PATCH] rust: jump_label: skip formatting generated file

Miguel Ojeda posted 1 patch 15 hours ago
rust/Makefile                                                 | 4 ++--
rust/kernel/.gitignore                                        | 2 +-
..._branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} | 0
rust/kernel/jump_label.rs                                     | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
rename rust/kernel/{arch_static_branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} (100%)
[PATCH] rust: jump_label: skip formatting generated file
Posted by Miguel Ojeda 15 hours ago
After a source tree build of the kernel, and having used the `RSCPP`
rule, running `rustfmt` fails with:

    error: macros that expand to items must be delimited with braces or followed by a semicolon
     --> rust/kernel/arch_static_branch_asm.rs:1:27
      |
    1 | ...ls!("1: jmp " ... ".popsection \n\t")
      |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
    help: change the delimiters to curly braces
      |
    1 | ::kernel::concat_literals!{"1: jmp " ... ".popsection \n\t"}
      |                           ~                                ~
    help: add a semicolon
      |
    1 | ::kernel::concat_literals!("1: jmp " ... ".popsection \n\t");
      |                                                             +

This file is not meant to be formatted nor works on its own since it is
meant to be textually included.

Thus skip formatting it by prefixing its name with `generated_`.

Fixes: 169484ab6677 ("rust: add arch_static_branch")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/Makefile                                                 | 4 ++--
 rust/kernel/.gitignore                                        | 2 +-
 ..._branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} | 0
 rust/kernel/jump_label.rs                                     | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
 rename rust/kernel/{arch_static_branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} (100%)

diff --git a/rust/Makefile b/rust/Makefile
index bc2a9071dd29..99db963637e6 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -36,7 +36,7 @@ always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
 
-always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/arch_static_branch_asm.rs
+always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs
 
 # Avoids running `$(RUSTC)` for the sysroot when it may not be available.
 ifdef CONFIG_RUST
@@ -427,7 +427,7 @@ $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \
 	+$(call if_changed_rule,rustc_library)
 
 ifdef CONFIG_JUMP_LABEL
-$(obj)/kernel.o: $(obj)/kernel/arch_static_branch_asm.rs
+$(obj)/kernel.o: $(obj)/kernel/generated_arch_static_branch_asm.rs
 endif
 
 endif # CONFIG_RUST
diff --git a/rust/kernel/.gitignore b/rust/kernel/.gitignore
index d082731007c6..6ba39a178f30 100644
--- a/rust/kernel/.gitignore
+++ b/rust/kernel/.gitignore
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 
-/arch_static_branch_asm.rs
+/generated_arch_static_branch_asm.rs
diff --git a/rust/kernel/arch_static_branch_asm.rs.S b/rust/kernel/generated_arch_static_branch_asm.rs.S
similarity index 100%
rename from rust/kernel/arch_static_branch_asm.rs.S
rename to rust/kernel/generated_arch_static_branch_asm.rs.S
diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
index 2f2df03a3275..8974f04737f8 100644
--- a/rust/kernel/jump_label.rs
+++ b/rust/kernel/jump_label.rs
@@ -39,7 +39,7 @@ macro_rules! static_branch_unlikely {
 #[cfg(CONFIG_JUMP_LABEL)]
 const _: &str = include!(concat!(
     env!("OBJTREE"),
-    "/rust/kernel/arch_static_branch_asm.rs"
+    "/rust/kernel/generated_arch_static_branch_asm.rs"
 ));
 
 #[macro_export]
@@ -48,7 +48,7 @@ macro_rules! static_branch_unlikely {
 macro_rules! arch_static_branch {
     ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
         $crate::asm!(
-            include!(concat!(env!("OBJTREE"), "/rust/kernel/arch_static_branch_asm.rs"));
+            include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_static_branch_asm.rs"));
             l_yes = label {
                 break 'my_label true;
             },

base-commit: 22193c586b43ee88d66954395885742a6e4a49a9
-- 
2.47.0
Re: [PATCH] rust: jump_label: skip formatting generated file
Posted by Miguel Ojeda 15 hours ago
On Wed, Nov 20, 2024 at 6:59 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Thus skip formatting it by prefixing its name with `generated_`.
>
> Fixes: 169484ab6677 ("rust: add arch_static_branch")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Steven: if you could please carry this one too before you send the PR,
that would be nice. Apologies for not noticing up earlier, I noticed
when doing some manual merge tests for the Rust subsystem PR.

If you happen to rebase for the other sample/test that you asked
Alice, then please feel free to just fix the original directly. Same
for the other fix you already applied -- both are really just renames.

Thanks!

Cheers,
Miguel
Re: [PATCH] rust: jump_label: skip formatting generated file
Posted by Steven Rostedt 14 hours ago
On Wed, 20 Nov 2024 19:09:13 +0100
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Wed, Nov 20, 2024 at 6:59 PM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > Thus skip formatting it by prefixing its name with `generated_`.
> >
> > Fixes: 169484ab6677 ("rust: add arch_static_branch")
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>  
> 
> Steven: if you could please carry this one too before you send the PR,
> that would be nice. Apologies for not noticing up earlier, I noticed
> when doing some manual merge tests for the Rust subsystem PR.
> 
> If you happen to rebase for the other sample/test that you asked
> Alice, then please feel free to just fix the original directly. Same
> for the other fix you already applied -- both are really just renames.

I don't do rebases unless absolutely necessary. I had to rerun my tests as
I added some code to another topic branch (and added the rust topic branch
to it). I can kill the tests, apply this and restart.

-- Steve