mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: kbuild: generate a symbol version for rust_build_error
@ 2026-11-18  9:08 Peder Bergan via B4 Relay
  2026-11-19  0:44 ` Sami Tolvanen
  2026-11-19  2:24 ` Gary Guo
  0 siblings, 2 replies; 3+ messages in thread
From: Peder Bergan via B4 Relay @ 2026-11-18  9:08 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Nathan Chancellor, Nicolas Schier,
	Sami Tolvanen, Matthew Maurer, Masahiro Yamada, Gwan-gyeong Mun,
	rust-for-linux, linux-kernel, linux-kbuild, linux-modules

From: Peder Bergan <peder.bergan@gmail.com>

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.

Generate the checksum from build_error.o with the existing Rust library
rule. Make build_error.o depend on rust/Makefile when module versioning
is enabled so incremental builds pick up the change. Kbuild's saved
rustc command does not include the gendwarfksyms step.

Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
Reported-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1201
Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
---
An incremental x86-64 build with LLVM=1 CLIPPY=1 clears the modpost
warning. The kernel export and a Rust module that references it both
record the same nonzero CRC.

OpenAI Codex assisted with coding and testing.
---
 rust/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rust/Makefile b/rust/Makefile
index 0165626decbe..dd5b0a958d0c 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -773,8 +773,9 @@ $(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
+# Rebuild when the symbol version generation rule changes.
+$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o \
+    $(if $(CONFIG_MODVERSIONS),$(src)/Makefile) FORCE
 	+$(call if_changed_rule,rustc_library)
 
 $(obj)/ffi.o: private skip_gendwarfksyms = 1

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261118-fix-rust-build-error-modversions-4af535edc9b2

Best regards,
--  
Peder Bergan <peder.bergan@gmail.com>



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

* Re: [PATCH] rust: kbuild: generate a symbol version for rust_build_error
  2026-11-18  9:08 [PATCH] rust: kbuild: generate a symbol version for rust_build_error Peder Bergan via B4 Relay
@ 2026-11-19  0:44 ` Sami Tolvanen
  2026-11-19  2:24 ` Gary Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Sami Tolvanen @ 2026-11-19  0:44 UTC (permalink / raw)
  To: peder.bergan
  Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Nathan Chancellor,
	Nicolas Schier, Matthew Maurer, Masahiro Yamada, Gwan-gyeong Mun,
	rust-for-linux, linux-kernel, linux-kbuild, linux-modules

On Wed, Nov 18, 2026 at 1:08 AM Peder Bergan via B4 Relay
<devnull+peder.bergan.gmail.com@kernel.org> wrote:
>
> From: Peder Bergan <peder.bergan@gmail.com>
>
> 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.
>
> Generate the checksum from build_error.o with the existing Rust library
> rule. Make build_error.o depend on rust/Makefile when module versioning
> is enabled so incremental builds pick up the change. Kbuild's saved
> rustc command does not include the gendwarfksyms step.
>
> Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
> Reported-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1201
> Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
> ---
> An incremental x86-64 build with LLVM=1 CLIPPY=1 clears the modpost
> warning. The kernel export and a Rust module that references it both
> record the same nonzero CRC.
>
> OpenAI Codex assisted with coding and testing.
> ---
>  rust/Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>

Sami

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

* Re: [PATCH] rust: kbuild: generate a symbol version for rust_build_error
  2026-11-18  9:08 [PATCH] rust: kbuild: generate a symbol version for rust_build_error Peder Bergan via B4 Relay
  2026-11-19  0:44 ` Sami Tolvanen
@ 2026-11-19  2:24 ` Gary Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Gary Guo @ 2026-11-19  2:24 UTC (permalink / raw)
  To: peder.bergan, Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Nathan Chancellor, Nicolas Schier,
	Sami Tolvanen, Matthew Maurer, Masahiro Yamada, Gwan-gyeong Mun,
	rust-for-linux, linux-kernel, linux-kbuild, linux-modules

On Wed Nov 18, 2026 at 9:08 AM GMT, Peder Bergan via B4 Relay wrote:
> From: Peder Bergan <peder.bergan@gmail.com>
>
> 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.
>
> Generate the checksum from build_error.o with the existing Rust library
> rule. Make build_error.o depend on rust/Makefile when module versioning
> is enabled so incremental builds pick up the change. Kbuild's saved
> rustc command does not include the gendwarfksyms step.
>
> Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
> Reported-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1201
> Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
> ---
> An incremental x86-64 build with LLVM=1 CLIPPY=1 clears the modpost
> warning. The kernel export and a Rust module that references it both
> record the same nonzero CRC.
>
> OpenAI Codex assisted with coding and testing.
> ---
>  rust/Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 0165626decbe..dd5b0a958d0c 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -773,8 +773,9 @@ $(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
> +# Rebuild when the symbol version generation rule changes.
> +$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o \
> +    $(if $(CONFIG_MODVERSIONS),$(src)/Makefile) FORCE

Dependency on Makefile is just wrong in so many ways.

Best,
Gary

>  	+$(call if_changed_rule,rustc_library)
>  
>  $(obj)/ffi.o: private skip_gendwarfksyms = 1
>
> ---
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> change-id: 20261118-fix-rust-build-error-modversions-4af535edc9b2
>
> Best regards,
> --  
> Peder Bergan <peder.bergan@gmail.com>



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

end of thread, other threads:[~2026-11-19  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18  9:08 [PATCH] rust: kbuild: generate a symbol version for rust_build_error Peder Bergan via B4 Relay
2026-11-19  0:44 ` Sami Tolvanen
2026-11-19  2:24 ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®