[PATCH v3 1/7] MIPS: Only check -msym32 when need-compiler

From: Maciej W. Rozycki

Date: Sat Sep 19 2026 - 11:14:29 EST


From: WangYuli <wangyuli@xxxxxxxxxxxxx>

During 'make modules_install', the need-compiler variable is null, so
Makefile.compiler isn't included. This results in call cc-option-yn
returning nothing and consequently an error is issued:

*** CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32. Stop.

and the invocation terminated for configurations that set the Kconfig
option named.

Previously commit a79a404e6c22 ("MIPS: Fix CONFIG_CPU_DADDI_WORKAROUNDS
`modules_install' regression") addressed the same issue for GCC versions
now supported for Linux compilation, but caused a build error with Clang
because it doesn't support '-msym32'. Then commit 18ca63a2e23c ("MIPS:
Probe toolchain support of -msym32") fixed the issue with Clang, but
reintroduced the 'make modules_install' error listed above.

Wrap the handling of the '-msym32' option then with ifdef need-compiler,
fixing said error for 'make modules_install'.

For more technical details on why need-compiler is null during 'make
modules_install' and why no compiler invocation is actually needed at
this point, please refer to commit 4fe4a6374c4d ("MIPS: Only fiddle with
CHECKFLAGS if need-compiler") and commit 805b2e1d427a ("kbuild: include
Makefile.compiler only when compiler is needed").

NB leading 8 spaces rather than tabs required due to `make' syntax.

Link: https://lore.kernel.org/all/alpine.DEB.2.21.2502120612000.65342@xxxxxxxxxxxxxxxxx/
Link: https://lore.kernel.org/all/alpine.DEB.2.21.2307180025120.62448@xxxxxxxxxxxxxxxxx/
Fixes: a79a404e6c22 ("MIPS: Fix CONFIG_CPU_DADDI_WORKAROUNDS `modules_install' regression")
Reported-by: Maciej W. Rozycki <macro@xxxxxxxxxxx>
Closes: https://lore.kernel.org/all/alpine.DEB.2.21.2501030535080.49841@xxxxxxxxxxxxxxxxx/
Co-developed-by: Chen Linxuan <chenlinxuan@xxxxxxxxxxxxx>
Signed-off-by: Chen Linxuan <chenlinxuan@xxxxxxxxxxxxx>
Signed-off-by: WangYuli <wangyuli@xxxxxxxxxxxxx>
Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxxx>
---
Changes from v2 (1/6),
<https://lore.kernel.org/r/C7DB555D3895DE54+20250422102253.137944-1-wangyuli@xxxxxxxxxxxxx/>:

- Fix indentation/nesting of Makefile conditionals.

- Drop "dec: " from the commit heading; the feature is generic even if
only used by DEC platforms right now.

- Rewrite commit description for clarity.
---
arch/mips/Makefile | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

linux-wangyuli-mips-msym32-need-compiler.diff
Index: linux-macro/arch/mips/Makefile
===================================================================
--- linux-macro.orig/arch/mips/Makefile
+++ linux-macro/arch/mips/Makefile
@@ -290,18 +290,20 @@ drivers-$(CONFIG_PCI) += arch/mips/pci/
# We can always force a build with a 64-bits symbol format by
# passing 'KBUILD_SYM32=no' option to the make's command line.
#
-ifdef CONFIG_64BIT
- ifndef KBUILD_SYM32
- ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
- KBUILD_SYM32 = $(call cc-option-yn, -msym32)
+ifdef need-compiler
+ ifdef CONFIG_64BIT
+ ifndef KBUILD_SYM32
+ ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
+ KBUILD_SYM32 = $(call cc-option-yn, -msym32)
+ endif
endif
- endif

- ifeq ($(KBUILD_SYM32), y)
- cflags-$(KBUILD_SYM32) += -msym32 -DKBUILD_64BIT_SYM32
- else
- ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y)
- $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32)
+ ifeq ($(KBUILD_SYM32), y)
+ cflags-$(KBUILD_SYM32) += -msym32 -DKBUILD_64BIT_SYM32
+ else
+ ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y)
+ $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32)
+ endif
endif
endif
endif