]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gendwarfksyms: Skip files with no exports
authorSami Tolvanen <samitolvanen@google.com>
Mon, 10 Nov 2025 13:19:13 +0000 (14:19 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 11 Nov 2025 19:37:11 +0000 (20:37 +0100)
Starting with Rust 1.91.0 (released 2025-10-30), in upstream commit
ab91a63d403b ("Ignore intrinsic calls in cross-crate-inlining cost model")
[1][2], `bindings.o` stops containing DWARF debug information because the
`Default` implementations contained `write_bytes()` calls which are now
ignored in that cost model (note that `CLIPPY=1` does not reproduce it).

This means `gendwarfksyms` complains:

      RUSTC L rust/bindings.o
    error: gendwarfksyms: process_module: dwarf_get_units failed: no debugging information?

There are several alternatives that would work here: conditionally
skipping in the cases needed (but that is subtle and brittle), forcing
DWARF generation with e.g. a dummy `static` (ugly and we may need to
do it in several crates), skipping the call to the tool in the Kbuild
command when there are no exports (fine) or teaching the tool to do so
itself (simple and clean).

Thus do the last one: don't attempt to process files if we have no symbol
versions to calculate.

  [ I used the commit log of my patch linked below since it explained the
    root issue and expanded it a bit more to summarize the alternatives.

      - Miguel ]

Cc: stable@vger.kernel.org # Needed in 6.17.y.
Reported-by: Haiyue Wang <haiyuewa@163.com>
Closes: https://lore.kernel.org/rust-for-linux/b8c1c73d-bf8b-4bf2-beb1-84ffdcd60547@163.com/
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/rust-for-linux/CANiq72nKC5r24VHAp9oUPR1HVPqT+=0ab9N0w6GqTF-kJOeiSw@mail.gmail.com/
Link: https://github.com/rust-lang/rust/commit/ab91a63d403b0105cacd72809cd292a72984ed99
Link: https://github.com/rust-lang/rust/pull/145910
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Haiyue Wang <haiyuewa@163.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251110131913.1789896-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
scripts/gendwarfksyms/gendwarfksyms.c
scripts/gendwarfksyms/gendwarfksyms.h
scripts/gendwarfksyms/symbols.c

index 08ae61eb327eac7ee402b2464c1114b749daf0a9..f5203d1640ee692a4c6534835ccd53ac15316db5 100644 (file)
@@ -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");
index d9c06d2cb1dfc07aed805356feb624fe74194c6d..32cec8f7695a805fed2a2d9cdeaf349809e502a9 100644 (file)
@@ -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);
index 35ed594f0749b72ceea391e037a80fa923eea75c..ecddcb5ffcdfb925b432dbb0f1772aa3a1f3e7ce 100644 (file)
@@ -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)