From: Thomas Weißschuh Date: Wed, 13 Aug 2025 05:43:40 +0000 (+0200) Subject: kbuild: userprogs: avoid duplication of flags inherited from kernel X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2d0ec4a9319c5207fdd2359e8543ef35012e8d4e;p=users%2Fhch%2Fmisc.git kbuild: userprogs: avoid duplication of flags inherited from kernel The duplication makes maintenance harder. Changes need to be done in two places and the lines will grow overly long. Use an intermediary variable instead. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Acked-by: Masahiro Yamada Link: https://lore.kernel.org/r/20250813-kbuild-userprogs-bits-v1-1-2d9f7f411083@linutronix.de Signed-off-by: Nathan Chancellor --- diff --git a/Makefile b/Makefile index 6630a66659c6..3e8544b11520 100644 --- a/Makefile +++ b/Makefile @@ -1135,8 +1135,9 @@ LDFLAGS_vmlinux += --emit-relocs --discard-none endif # Align the bit size of userspace programs with the kernel -KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) -KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) +USERFLAGS_FROM_KERNEL := -m32 -m64 --target=% +KBUILD_USERCFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) +KBUILD_USERLDFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) # userspace programs are linked via the compiler, use the correct linker ifdef CONFIG_CC_IS_CLANG