rust: kbuild: generate a symbol version for rust_build_error
PATCH v2 1/1 rust: kbuild: generate a symbol version for rust_build_error
CONFIG_RUST_BUILD_ASSERT_ALLOW exports rust_build_error to modules. When CONFIG_MODVERSIONS is also enabled, modpost warns that the export has no symbol version and records a zero CRC because the build_error.o rule skips gendwarfksyms.
Let the existing Rust library rule run gendwarfksyms for build_error.o so modpost gets a version calculated from the Rust definition.
---
A clean x86-64 build with Clippy enabled generated the same nonzero CRC for the kernel export and an external Rust module that references it. An output tree built before this patch can reuse rust/build_error.o without generating the CRC. Rebuild that object before relinking. External modules built with the old CRC for rust_build_error also need rebuilding against the corrected kernel.
OpenAI Codex assisted with coding and testing.
---
Changes in v2:
- Drop the rust/Makefile prerequisite after Gary's review.
- Omit Sami's v1 Reviewed-by because v2 changes incremental rebuild behavior.
- Link to v1: https://lore.kernel.org/rust-for-linux/20261118-fix-rust-build-error-modversions-v1-1-7c1023764f30@gmail.com/
--- rust/Makefile | 1 - 1 file changed, 1 deletion(-)
rust/Makefile +0 -1
@@ -773,7 +773,6 @@ $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \ # treated as such so that we pass the same flags. Otherwise, for instance, # `rustc` will complain about missing sanitizer flags causing an ABI mismatch. $(obj)/build_error.o: private is-kernel-object := y -$(obj)/build_error.o: private skip_gendwarfksyms = 1 $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE +$(call if_changed_rule,rustc_library)
---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261118-fix-rust-build-error-modversions-4af535edc9b2
Best regards,
Signature · 1 line
Peder Bergan <[email protected]>
Quoted 2 lines · On Thu, Nov 19, 2026 at 11:19 AM Peder Bergan via B4 Relay…
- Omit Sami's v1 Reviewed-by because v2 changes incremental rebuild behavior.
I guess Sami is still OK with it, given it is a subset of the previous patch and the core part of it.
But I will wait for his confirmation -- this one is not urgent.
Thanks for the patch!
Cheers,
Miguel
Quoted 8 lines · On Thu, Nov 19, 2026 at 2:19 AM Peder Bergan via B4 Relay…
From: Peder Bergan <[email protected]>
CONFIG_RUST_BUILD_ASSERT_ALLOWexportsrust_build_errorto modules. WhenCONFIG_MODVERSIONSis also enabled, modpost warns that the export has no symbol version and records a zero CRC because the build_error.o rule skips gendwarfksyms.
Quoted 7 lines
Let the existing Rust library rule run gendwarfksyms for build_error.o so modpost gets a version calculated from the Rust definition.
Fixes ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")Reported-by Gwan-gyeong Mun <[email protected]>Signed-off-by Peder Bergan <[email protected]>
Sami