[PATCH v7 05/23] selftests/nolibc: Use a dedicated cross cc-option helper

From: Leo Yan

Date: Tue Jun 02 2026 - 10:53:22 EST


Makefile.nolibc uses cc-option for architecture-specific flag probes
such as -m32, -mmultiple and -mabi=elfv2. These probes need to include
CLANG_CROSS_FLAGS so that Clang tests the option for the selected target
instead of the host.

The file also includes tools/scripts/Makefile.include. In a sequential
change, Makefile.include will define its own cc-option helper.

Rename the nolibc helper to cross-cc-option and use it for the
architecture-specific probes that require CLANG_CROSS_FLAGS. This keeps
the cross-build checks explicit and avoids clashing with the common
tools cc-option helper.

Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
tools/testing/selftests/nolibc/Makefile.nolibc | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index f30bc68470cceec2b61805af0a4a9f2fb2de7c57..e88b1c15445f3c64dd78cc7edef5c9670a389b50 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -23,7 +23,7 @@ include $(srctree)/scripts/subarch.include
ARCH = $(SUBARCH)
endif

-cc-option = $(call __cc-option, $(CC),$(CLANG_CROSS_FLAGS),$(1),$(2))
+cross-cc-option = $(call __cc-option, $(CC),$(CLANG_CROSS_FLAGS),$(1),$(2))

# XARCH extends the kernel's ARCH with a few variants of the same
# architecture that only differ by the configuration, the toolchain
@@ -211,13 +211,13 @@ else
Q=@
endif

-CFLAGS_i386 = $(call cc-option,-m32)
+CFLAGS_i386 = $(call cross-cc-option,-m32)
CFLAGS_x32 = -mx32
CFLAGS_arm = -marm
CFLAGS_armthumb = -mthumb -march=armv6t2
-CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple)
-CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple)
-CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=elfv2)
+CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cross-cc-option,-mmultiple)
+CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cross-cc-option,-mmultiple)
+CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cross-cc-option,-mabi=elfv2)
CFLAGS_s390x = -m64
CFLAGS_mips32le = -EL -mabi=32 -fPIC
CFLAGS_mips32be = -EB -mabi=32
@@ -226,7 +226,7 @@ CFLAGS_mipsn32be = -EB -mabi=n32 -march=mips64r6
CFLAGS_mips64le = -EL -mabi=64 -march=mips64r6
CFLAGS_mips64be = -EB -mabi=64 -march=mips64r2
CFLAGS_loongarch = $(if $(LLVM),-fuse-ld=lld)
-CFLAGS_sparc32 = $(call cc-option,-m32) -mcpu=v8
+CFLAGS_sparc32 = $(call cross-cc-option,-m32) -mcpu=v8
CFLAGS_sh4 = -ml -m4
ifeq ($(origin XARCH),command line)
CFLAGS_XARCH = $(CFLAGS_$(XARCH))

--
2.34.1