Skip to content

Commit 5134a33

Browse files
committed
kbuild: rust: re-run Kconfig if the version text changes
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 <[email protected]> Tested-by: Alice Ryhl <[email protected]> Acked-by: Masahiro Yamada <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 6e74c6b commit 5134a33

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,11 @@ endif
648648

649649
# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
650650
# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
651-
# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
652-
# and from include/config/auto.conf.cmd to detect the compiler upgrade.
651+
# CC_VERSION_TEXT and RUSTC_VERSION_TEXT are referenced from Kconfig (so they
652+
# need export), and from include/config/auto.conf.cmd to detect the compiler
653+
# upgrade.
653654
CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
655+
RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
654656

655657
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
656658
include $(srctree)/scripts/Makefile.clang
@@ -671,7 +673,7 @@ ifdef config-build
671673
# KBUILD_DEFCONFIG may point out an alternative default configuration
672674
# used for 'make defconfig'
673675
include $(srctree)/arch/$(SRCARCH)/Makefile
674-
export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
676+
export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT RUSTC_VERSION_TEXT
675677

676678
config: outputmakefile scripts_basic FORCE
677679
$(Q)$(MAKE) $(build)=scripts/kconfig $@

init/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,9 @@ config RUST
19271927
config RUSTC_VERSION_TEXT
19281928
string
19291929
depends on RUST
1930-
default "$(shell,$(RUSTC) --version 2>/dev/null)"
1930+
default "$(RUSTC_VERSION_TEXT)"
1931+
help
1932+
See `CC_VERSION_TEXT`.
19311933

19321934
config BINDGEN_VERSION_TEXT
19331935
string

0 commit comments

Comments
 (0)