llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] btf, scripts: rust: drop is_rust_module.sh
@ 2023-07-04  5:21 Andrea Righi
  2023-07-04 13:29 ` Martin Rodriguez Reboredo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrea Righi @ 2023-07-04  5:21 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Masahiro Yamada, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Tom Rix, linux-kernel, rust-for-linux,
	linux-kbuild, llvm

With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
we are now able to use pahole directly to identify Rust compilation
units (CUs) and exclude them from generating BTF debugging information
(when DEBUG_INFO_BTF is enabled).

And if pahole doesn't support the --lang-exclude flag, we can't enable
both RUST and DEBUG_INFO_BTF at the same time.

So, in any case, the script is_rust_module.sh is just redundant and we
can drop it.

NOTE: we may also be able to drop the "Rust loadable module" mark
inside Rust modules, but it seems safer to keep it for now to make sure
we are not breaking any external tool that may potentially rely on it.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
 rust/macros/module.rs     |  2 +-
 scripts/Makefile.modfinal |  2 --
 scripts/is_rust_module.sh | 16 ----------------
 3 files changed, 1 insertion(+), 19 deletions(-)
 delete mode 100755 scripts/is_rust_module.sh

diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index fb1244f8c2e6..d62d8710d77a 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -199,7 +199,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
             /// Used by the printing macros, e.g. [`info!`].
             const __LOG_PREFIX: &[u8] = b\"{name}\\0\";
 
-            /// The \"Rust loadable module\" mark, for `scripts/is_rust_module.sh`.
+            /// The \"Rust loadable module\" mark.
             //
             // This may be best done another way later on, e.g. as a new modinfo
             // key or a new section. For the moment, keep it simple.
diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
index fc19f67039bd..b3a6aa8fbe8c 100644
--- a/scripts/Makefile.modfinal
+++ b/scripts/Makefile.modfinal
@@ -41,8 +41,6 @@ quiet_cmd_btf_ko = BTF [M] $@
       cmd_btf_ko = 							\
 	if [ ! -f vmlinux ]; then					\
 		printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
-	elif [ -n "$(CONFIG_RUST)" ] && $(srctree)/scripts/is_rust_module.sh $@; then 		\
-		printf "Skipping BTF generation for %s because it's a Rust module\n" $@ 1>&2; \
 	else								\
 		LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
 		$(RESOLVE_BTFIDS) -b vmlinux $@; 			\
diff --git a/scripts/is_rust_module.sh b/scripts/is_rust_module.sh
deleted file mode 100755
index 464761a7cf7f..000000000000
--- a/scripts/is_rust_module.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0
-#
-# is_rust_module.sh module.ko
-#
-# Returns `0` if `module.ko` is a Rust module, `1` otherwise.
-
-set -e
-
-# Using the `16_` prefix ensures other symbols with the same substring
-# are not picked up (even if it would be unlikely). The last part is
-# used just in case LLVM decides to use the `.` suffix.
-#
-# In the future, checking for the `.comment` section may be another
-# option, see https://github.com/rust-lang/rust/pull/97550.
-${NM} "$*" | grep -qE '^[0-9a-fA-F]+ [Rr] _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'
-- 
2.40.1


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

* Re: [PATCH] btf, scripts: rust: drop is_rust_module.sh
  2023-07-04  5:21 [PATCH] btf, scripts: rust: drop is_rust_module.sh Andrea Righi
@ 2023-07-04 13:29 ` Martin Rodriguez Reboredo
  2023-07-11 14:39 ` Miguel Ojeda
  2023-08-09 23:22 ` Miguel Ojeda
  2 siblings, 0 replies; 6+ messages in thread
From: Martin Rodriguez Reboredo @ 2023-07-04 13:29 UTC (permalink / raw)
  To: Andrea Righi, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Masahiro Yamada, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Tom Rix, linux-kernel, rust-for-linux,
	linux-kbuild, llvm

On 7/4/23 02:21, Andrea Righi wrote:
> With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
> we are now able to use pahole directly to identify Rust compilation
> units (CUs) and exclude them from generating BTF debugging information
> (when DEBUG_INFO_BTF is enabled).
> 
> And if pahole doesn't support the --lang-exclude flag, we can't enable
> both RUST and DEBUG_INFO_BTF at the same time.
> 
> So, in any case, the script is_rust_module.sh is just redundant and we
> can drop it.
> 
> NOTE: we may also be able to drop the "Rust loadable module" mark
> inside Rust modules, but it seems safer to keep it for now to make sure
> we are not breaking any external tool that may potentially rely on it.

Keep it, I think it can be useful with tooling like kmod.

> 
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> ---
> [...]

Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>

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

* Re: [PATCH] btf, scripts: rust: drop is_rust_module.sh
  2023-07-04  5:21 [PATCH] btf, scripts: rust: drop is_rust_module.sh Andrea Righi
  2023-07-04 13:29 ` Martin Rodriguez Reboredo
@ 2023-07-11 14:39 ` Miguel Ojeda
  2023-07-11 15:18   ` Andrea Righi
  2023-07-11 17:22   ` Daniel Xu
  2023-08-09 23:22 ` Miguel Ojeda
  2 siblings, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2023-07-11 14:39 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier, Tom Rix,
	linux-kernel, rust-for-linux, linux-kbuild, llvm, bpf,
	Martin KaFai Lau, Arnaldo Carvalho de Melo

On Tue, Jul 4, 2023 at 7:21 AM Andrea Righi <andrea.righi@canonical.com> wrote:
>
> With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
> we are now able to use pahole directly to identify Rust compilation
> units (CUs) and exclude them from generating BTF debugging information
> (when DEBUG_INFO_BTF is enabled).
>
> And if pahole doesn't support the --lang-exclude flag, we can't enable
> both RUST and DEBUG_INFO_BTF at the same time.
>
> So, in any case, the script is_rust_module.sh is just redundant and we
> can drop it.
>
> NOTE: we may also be able to drop the "Rust loadable module" mark
> inside Rust modules, but it seems safer to keep it for now to make sure
> we are not breaking any external tool that may potentially rely on it.

Just to recall the history of these changes:

  - The script got added in order to skip the BTF generation in the
`BTF [M]` step (under `DEBUG_INFO_BTF_MODULES`, which depends on
`DEBUG_INFO_BTF`).

  - A few months later, it was noticed that C modules couldn't be
loaded if Rust was enabled, due to the base BTF info in `vmlinux`.
That triggered the eventual addition of `--lang_exclude=` to `pahole`,
but meanwhile, we made `DEBUG_INFO_BTF` and `RUST` exclusive.

  - Now, this patch removes the script because having a newer `pahole`
also correctly skips the Rust CUs in the `BTF [M]` steps (i.e. and not
just the `vmlinux` one), since we pass `--lang_exclude=` to both cases
(`link-vmlinux.sh` and `Makefile.modfinal`), if I understand correctly
(the script could, in principle, have been removed even before
`pahole` got the new feature, given the exclusivity of the options).

If this is all correct, then the patch looks good to me. I am Cc'ing
Arnaldo, Martin and the BPF list.

If this goes through the Rust tree, I will also pick the older `Reviewed-by`s.

Thanks!

Cheers,
Miguel

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

* Re: [PATCH] btf, scripts: rust: drop is_rust_module.sh
  2023-07-11 14:39 ` Miguel Ojeda
@ 2023-07-11 15:18   ` Andrea Righi
  2023-07-11 17:22   ` Daniel Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Andrea Righi @ 2023-07-11 15:18 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier, Tom Rix,
	linux-kernel, rust-for-linux, linux-kbuild, llvm, bpf,
	Martin KaFai Lau, Arnaldo Carvalho de Melo

On Tue, Jul 11, 2023 at 04:39:27PM +0200, Miguel Ojeda wrote:
> On Tue, Jul 4, 2023 at 7:21 AM Andrea Righi <andrea.righi@canonical.com> wrote:
> >
> > With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
> > we are now able to use pahole directly to identify Rust compilation
> > units (CUs) and exclude them from generating BTF debugging information
> > (when DEBUG_INFO_BTF is enabled).
> >
> > And if pahole doesn't support the --lang-exclude flag, we can't enable
> > both RUST and DEBUG_INFO_BTF at the same time.
> >
> > So, in any case, the script is_rust_module.sh is just redundant and we
> > can drop it.
> >
> > NOTE: we may also be able to drop the "Rust loadable module" mark
> > inside Rust modules, but it seems safer to keep it for now to make sure
> > we are not breaking any external tool that may potentially rely on it.
> 
> Just to recall the history of these changes:
> 
>   - The script got added in order to skip the BTF generation in the
> `BTF [M]` step (under `DEBUG_INFO_BTF_MODULES`, which depends on
> `DEBUG_INFO_BTF`).
> 
>   - A few months later, it was noticed that C modules couldn't be
> loaded if Rust was enabled, due to the base BTF info in `vmlinux`.
> That triggered the eventual addition of `--lang_exclude=` to `pahole`,
> but meanwhile, we made `DEBUG_INFO_BTF` and `RUST` exclusive.
> 
>   - Now, this patch removes the script because having a newer `pahole`
> also correctly skips the Rust CUs in the `BTF [M]` steps (i.e. and not
> just the `vmlinux` one), since we pass `--lang_exclude=` to both cases
> (`link-vmlinux.sh` and `Makefile.modfinal`), if I understand correctly
> (the script could, in principle, have been removed even before
> `pahole` got the new feature, given the exclusivity of the options).

The history looks correct to me.

Also, note that, if pahole doesn't support the new `--lang-exclude=`, we
have `RUST` depending on `!DEBUG_INFO_BTF`, so we fallback the old
"exclusivity" mode between BTF and Rust and, again, the script is not
needed.

As you correctly say, in principle, we could have removed the script
even before the new `pahole`.

> 
> If this is all correct, then the patch looks good to me. I am Cc'ing
> Arnaldo, Martin and the BPF list.
> 
> If this goes through the Rust tree, I will also pick the older `Reviewed-by`s.
> 
> Thanks!
> 
> Cheers,
> Miguel

Thanks,
-Andrea

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

* Re: [PATCH] btf, scripts: rust: drop is_rust_module.sh
  2023-07-11 14:39 ` Miguel Ojeda
  2023-07-11 15:18   ` Andrea Righi
@ 2023-07-11 17:22   ` Daniel Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Xu @ 2023-07-11 17:22 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Andrea Righi, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Masahiro Yamada, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Tom Rix, linux-kernel, rust-for-linux,
	linux-kbuild, llvm, bpf, Martin KaFai Lau,
	Arnaldo Carvalho de Melo

Hi Miguel, Andrea,

On Tue, Jul 11, 2023 at 04:39:27PM +0200, Miguel Ojeda wrote:
> On Tue, Jul 4, 2023 at 7:21 AM Andrea Righi <andrea.righi@canonical.com> wrote:
> >
> > With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
> > we are now able to use pahole directly to identify Rust compilation
> > units (CUs) and exclude them from generating BTF debugging information
> > (when DEBUG_INFO_BTF is enabled).
> >
> > And if pahole doesn't support the --lang-exclude flag, we can't enable
> > both RUST and DEBUG_INFO_BTF at the same time.
> >
> > So, in any case, the script is_rust_module.sh is just redundant and we
> > can drop it.
> >
> > NOTE: we may also be able to drop the "Rust loadable module" mark
> > inside Rust modules, but it seems safer to keep it for now to make sure
> > we are not breaking any external tool that may potentially rely on it.
> 
> Just to recall the history of these changes:
> 
>   - The script got added in order to skip the BTF generation in the
> `BTF [M]` step (under `DEBUG_INFO_BTF_MODULES`, which depends on
> `DEBUG_INFO_BTF`).
> 
>   - A few months later, it was noticed that C modules couldn't be
> loaded if Rust was enabled, due to the base BTF info in `vmlinux`.
> That triggered the eventual addition of `--lang_exclude=` to `pahole`,
> but meanwhile, we made `DEBUG_INFO_BTF` and `RUST` exclusive.
> 
>   - Now, this patch removes the script because having a newer `pahole`
> also correctly skips the Rust CUs in the `BTF [M]` steps (i.e. and not
> just the `vmlinux` one), since we pass `--lang_exclude=` to both cases
> (`link-vmlinux.sh` and `Makefile.modfinal`), if I understand correctly
> (the script could, in principle, have been removed even before
> `pahole` got the new feature, given the exclusivity of the options).
> 
> If this is all correct, then the patch looks good to me. I am Cc'ing
> Arnaldo, Martin and the BPF list.

I believe I authored the original script. This all sounds right to me.

Acked-by: Daniel Xu <dxu@dxuuu.xyz>

Thanks,
Daniel

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

* Re: [PATCH] btf, scripts: rust: drop is_rust_module.sh
  2023-07-04  5:21 [PATCH] btf, scripts: rust: drop is_rust_module.sh Andrea Righi
  2023-07-04 13:29 ` Martin Rodriguez Reboredo
  2023-07-11 14:39 ` Miguel Ojeda
@ 2023-08-09 23:22 ` Miguel Ojeda
  2 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2023-08-09 23:22 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier, Tom Rix,
	linux-kernel, rust-for-linux, linux-kbuild, llvm, bpf,
	Martin KaFai Lau, Arnaldo Carvalho de Melo

On Tue, Jul 4, 2023 at 7:21 AM Andrea Righi <andrea.righi@canonical.com> wrote:
>
> With commit c1177979af9c ("btf, scripts: Exclude Rust CUs with pahole")
> we are now able to use pahole directly to identify Rust compilation
> units (CUs) and exclude them from generating BTF debugging information
> (when DEBUG_INFO_BTF is enabled).
>
> And if pahole doesn't support the --lang-exclude flag, we can't enable
> both RUST and DEBUG_INFO_BTF at the same time.
>
> So, in any case, the script is_rust_module.sh is just redundant and we
> can drop it.
>
> NOTE: we may also be able to drop the "Rust loadable module" mark
> inside Rust modules, but it seems safer to keep it for now to make sure
> we are not breaking any external tool that may potentially rely on it.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>

Applied to `rust-next` -- thanks everyone, and Andrea and Daniel for
confirming my summary/recollection sounded right in the other message.

Cheers,
Miguel

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

end of thread, other threads:[~2023-08-09 23:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  5:21 [PATCH] btf, scripts: rust: drop is_rust_module.sh Andrea Righi
2023-07-04 13:29 ` Martin Rodriguez Reboredo
2023-07-11 14:39 ` Miguel Ojeda
2023-07-11 15:18   ` Andrea Righi
2023-07-11 17:22   ` Daniel Xu
2023-08-09 23:22 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).