public inbox for linux-modules@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Tolvanen <samitolvanen@google.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Haiyue Wang <haiyuewa@163.com>,
	rust-for-linux@vger.kernel.org, Miguel Ojeda <ojeda@kernel.org>,
	linux-modules@vger.kernel.org,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Subject: Re: Only rust/bindings.o build fail on rust-1.91.0
Date: Sat, 8 Nov 2025 04:42:06 +0000	[thread overview]
Message-ID: <20251108044206.GA3038215@google.com> (raw)
In-Reply-To: <CANiq72kcRsTWPhQVJ18P6RUxL=+c1Z8BJkyK_kRR8EBmmH+cWg@mail.gmail.com>

On Sat, Nov 08, 2025 at 05:04:06AM +0100, Miguel Ojeda wrote:
> On Sat, Nov 8, 2025 at 4:51 AM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
> >
> > What do you mean?
> 
> Do you mean in some cases? i.e. like with `CLIPPY=1`?

Ah, nevermind. I was looking at a stale object file. If there are no
exports, we should obviously skip gendwarfksyms.

For C objects, we use nm to check for __export_symbol_* symbols
before we attempt to generate symbol versions (see gen_symversions
in scripts/Makefile.build). We could do something similar for Rust
objects too, or just bail out early in gendwarfksyms if it's passed an
empty symbol list.

The trivial patch below should fix the issue.

Sami

---

From d1a4096cd328beae3323a1beb207c7cb5e770770 Mon Sep 17 00:00:00 2001
From: Sami Tolvanen <samitolvanen@google.com>
Date: Sat, 8 Nov 2025 04:26:10 +0000
Subject: [PATCH] gendwarfksyms: Skip files with no exports

Don't attempt to process files if we have no symbol versions to
calculate.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 scripts/gendwarfksyms/gendwarfksyms.c | 3 ++-
 scripts/gendwarfksyms/gendwarfksyms.h | 2 +-
 scripts/gendwarfksyms/symbols.c       | 4 +++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/gendwarfksyms/gendwarfksyms.c b/scripts/gendwarfksyms/gendwarfksyms.c
index 08ae61eb327e..f5203d1640ee 100644
--- a/scripts/gendwarfksyms/gendwarfksyms.c
+++ b/scripts/gendwarfksyms/gendwarfksyms.c
@@ -138,7 +138,8 @@ int main(int argc, char **argv)
 		error("no input files?");
 	}
 
-	symbol_read_exports(stdin);
+	if (!symbol_read_exports(stdin))
+		return 0;
 
 	if (symtypes_file) {
 		symfile = fopen(symtypes_file, "w");
diff --git a/scripts/gendwarfksyms/gendwarfksyms.h b/scripts/gendwarfksyms/gendwarfksyms.h
index d9c06d2cb1df..32cec8f7695a 100644
--- a/scripts/gendwarfksyms/gendwarfksyms.h
+++ b/scripts/gendwarfksyms/gendwarfksyms.h
@@ -123,7 +123,7 @@ struct symbol {
 typedef void (*symbol_callback_t)(struct symbol *, void *arg);
 
 bool is_symbol_ptr(const char *name);
-void symbol_read_exports(FILE *file);
+int symbol_read_exports(FILE *file);
 void symbol_read_symtab(int fd);
 struct symbol *symbol_get(const char *name);
 void symbol_set_ptr(struct symbol *sym, Dwarf_Die *ptr);
diff --git a/scripts/gendwarfksyms/symbols.c b/scripts/gendwarfksyms/symbols.c
index 35ed594f0749..ecddcb5ffcdf 100644
--- a/scripts/gendwarfksyms/symbols.c
+++ b/scripts/gendwarfksyms/symbols.c
@@ -128,7 +128,7 @@ static bool is_exported(const char *name)
 	return for_each(name, NULL, NULL) > 0;
 }
 
-void symbol_read_exports(FILE *file)
+int symbol_read_exports(FILE *file)
 {
 	struct symbol *sym;
 	char *line = NULL;
@@ -159,6 +159,8 @@ void symbol_read_exports(FILE *file)
 
 	free(line);
 	debug("%d exported symbols", nsym);
+
+	return nsym;
 }
 
 static void get_symbol(struct symbol *sym, void *arg)
-- 
2.51.2.1041.gc1ab5b90ca-goog


  reply	other threads:[~2025-11-08  4:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b8c1c73d-bf8b-4bf2-beb1-84ffdcd60547@163.com>
2025-11-06 13:57 ` Only rust/bindings.o build fail on rust-1.91.0 Miguel Ojeda
2025-11-06 14:04   ` Haiyue Wang
2025-11-06 16:07   ` Sami Tolvanen
2025-11-06 17:54     ` Miguel Ojeda
2025-11-08  1:41       ` Miguel Ojeda
2025-11-08  2:39         ` Sami Tolvanen
2025-11-08  3:51           ` Miguel Ojeda
2025-11-08  4:04             ` Miguel Ojeda
2025-11-08  4:42               ` Sami Tolvanen [this message]
2025-11-08  5:08                 ` Miguel Ojeda
2025-11-11 21:41                   ` Miguel Ojeda
2025-11-11 21:52                     ` Sami Tolvanen
2025-11-08  5:10           ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251108044206.GA3038215@google.com \
    --to=samitolvanen@google.com \
    --cc=haiyuewa@163.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox