Skip to contentSkip to conversation

rust: kbuild: skip gendwarfksyms in `bindings.o` for Rust >= 1.91.0

PATCH In review Miguel Ojeda 3 participants 4 messages Nov 8, 2025

Subsystems (3)
lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

PATCH 1/1 rust: kbuild: skip gendwarfksyms in `bindings.o` for Rust >= 1.91.0

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?

For the moment, conditionally skip gendwarfksyms for Rust >= 1.91.0.

---
 rust/Makefile | 1 +
 1 file changed, 1 insertion(+)
rust/Makefile +1 -0
index 3e545c1a0ff4..269bf7cf5b97 100644
@@ -543,6 +543,7 @@ $(obj)/ffi.o: private skip_gendwarfksyms = 1
 $(obj)/ffi.o: $(src)/ffi.rs $(obj)/compiler_builtins.o FORCE
 	+$(call if_changed_rule,rustc_library)
 
+$(obj)/bindings.o: private skip_gendwarfksyms := $(if $(call rustc-min-version,109100),1)
 $(obj)/bindings.o: private rustc_target_flags = --extern ffi --extern pin_init
 $(obj)/bindings.o: $(src)/bindings/lib.rs \
     $(obj)/ffi.o \

base-commit: dc77806cf3b4788d328fddf245e86c5b529f31a2

Signature · 1 line
2.51.2
#1 lore raw
Quoted 2 lines · Miguel Ojeda

note that CLIPPY=1 does not reproduce it

And obviously this means we have to special case this one too...

    $(obj)/bindings.o: private skip_gendwarfksyms := $(if $(call

rustc-min-version,109100),$(if $(KBUILD_CLIPPY),,1))

There may be other cases that disable the optimization or similar, plus we may have other small crates in the future that could also suffer from this, so it may be best to simply force to generate the DWARF with a dummy symbol from that crate for the time being as the fix:

    #[expect(unused)]
    static DUMMY_SYMBOL_FOR_DWARF_DEBUGINFO_GENERATION_FOR_GENDWARFKSYMS:

() = ();

With #[no_mangle] may be more reliable and it also gives an actual exported symbol.

And then later do something in the cmd command itself or teaching genkallksyms to auto-skip in cases like this.

What do you think?

Cheers,
Miguel

#2 lore raw
Quoted 3 lines · Miguel Ojeda

With #[no_mangle] may be more reliable and it also gives an actual exported symbol.

Or #[used] to keep it mangled since we don't care.

Cheers,
Miguel

#3 lore raw
In reply to Miguel Ojeda
Quoted 16 lines · Miguel Ojeda
Quoted 2 lines · Miguel Ojeda

note that CLIPPY=1 does not reproduce it

And obviously this means we have to special case this one too...

    $(obj)/bindings.o: private skip_gendwarfksyms := $(if $(call

rustc-min-version,109100),$(if $(KBUILD_CLIPPY),,1))

There may be other cases that disable the optimization or similar, plus we may have other small crates in the future that could also suffer from this, so it may be best to simply force to generate the DWARF with a dummy symbol from that crate for the time being as the fix:

Quoted 3 lines
    #[expect(unused)]
    static DUMMY_SYMBOL_FOR_DWARF_DEBUGINFO_GENERATION_FOR_GENDWARFKSYMS:

() = ();

This looks reasonable to me, and indeed seems to fix the problem.

Quoted 4 lines

And then later do something in the cmd command itself or teaching genkallksyms to auto-skip in cases like this.

What do you think?

Like I mentioned in the other thread, we ideally wouldn't silently skip symbol versioning because the exported symbols won't be usable in this case.

Sami