kbuild: rust: re-run Kconfig if the version text changes
authorMiguel Ojeda <ojeda@kernel.org>
Mon, 2 Sep 2024 16:55:29 +0000 (18:55 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 5 Sep 2024 20:44:34 +0000 (22:44 +0200)
Re-run Kconfig if we detect the Rust compiler has changed via the version
text, like it is done for C.

Unlike C, and unlike `RUSTC_VERSION`, the `RUSTC_VERSION_TEXT` is kept
under `depends on RUST`, since it should not be needed unless `RUST`
is enabled.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Tested-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20240902165535.1101978-3-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Makefile
init/Kconfig

index 68ebd6d6b444df00aedb3d09baa4e484977f5eb0..1883aeb919a416a50da88dc169a737137a0e724a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -648,9 +648,11 @@ endif
 
 # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
 # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
-# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
-# and from include/config/auto.conf.cmd to detect the compiler upgrade.
+# CC_VERSION_TEXT and RUSTC_VERSION_TEXT are referenced from Kconfig (so they
+# need export), and from include/config/auto.conf.cmd to detect the compiler
+# upgrade.
 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
+RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
 
 ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
 include $(srctree)/scripts/Makefile.clang
@@ -671,7 +673,7 @@ ifdef config-build
 # KBUILD_DEFCONFIG may point out an alternative default configuration
 # used for 'make defconfig'
 include $(srctree)/arch/$(SRCARCH)/Makefile
-export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
+export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT RUSTC_VERSION_TEXT
 
 config: outputmakefile scripts_basic FORCE
        $(Q)$(MAKE) $(build)=scripts/kconfig $@
index 38c1cfcce821e4c768acbe60d0db31d87533ca46..c6b744a48dcca7d7fb5b1e87256865fcfd305375 100644 (file)
@@ -1927,7 +1927,9 @@ config RUST
 config RUSTC_VERSION_TEXT
        string
        depends on RUST
-       default "$(shell,$(RUSTC) --version 2>/dev/null)"
+       default "$(RUSTC_VERSION_TEXT)"
+       help
+         See `CC_VERSION_TEXT`.
 
 config BINDGEN_VERSION_TEXT
        string