[PATCH] x86/rust: avoid duplication of RETPOLINE_RUSTFLAGS in recursive kbuild
From: Thomas Weißschuh
Date: Tue Oct 13 2026 - 04:43:19 EST
Currently the only modificiation of REPTOLINE_RUSTFLAGS is an append.
There is no initial (re)set of the value. When kbuild is invoked
recursively, for example through a top-level `make pacman-pkg`
invocation, then the inner instance of kbuild will inherit the value
from the outer one and append the same values again.
Switching between recursive and non-recursive invocations of kbuild in
the same build tree the command line changes and Rust code is rebuilt.
While this is harmless, it is slow and unnecessary.
Replace the append operation with a regular assignment. This avoids the
duplicated values in a recursive kbuild invocation and therefore also
the spurious rebuilds.
RETPOLINE_CFLAGS is not affected as it is always reset to a fixed value
further up in the Makefile.
Fixes: d7868550d573 ("x86/rust: support MITIGATION_RETHUNK")
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
This is the only instance of this problem in my kernel configuration.
---
arch/x86/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 8af6b80cffdd..0973b0262661 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -26,7 +26,7 @@ ifdef CONFIG_MITIGATION_RETHUNK
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
RETHUNK_RUSTFLAGS := -Zfunction-return=thunk-extern
RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS)
-RETPOLINE_RUSTFLAGS += $(RETHUNK_RUSTFLAGS)
+RETPOLINE_RUSTFLAGS := $(RETHUNK_RUSTFLAGS)
endif
export RETHUNK_CFLAGS
---
base-commit: 7704c4c5bb127673b4f0ead839919db573559e38
change-id: 20261013-rust-x86-rethunk-rebuilds-82c0109356d2
Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>