[PATCH v2 4/7] selftests/nolibc: allow customize CROSS_COMPILE by architecture

From: Zhangjin Wu
Date: Fri Aug 11 2023 - 16:31:46 EST


Some cross compilers are not just prefixed with XARCH, customize them by
architecture may simplify the test a lot, especially, when iterate with
XARCH.

After customizing this for every architecture or its variant, the
minimal test argument will be architecture or variant itself, no
CROSS_COMPILE required to be passed.

If the prefix of installed cross compiler is not the same as the one
customized, we can also pass CROSS_COMPILE as before or even pass
CROSS_COMPILE_$(XARCH) and CC from command line.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
tools/testing/selftests/nolibc/Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 91ccfc27780f..5aff60d31d72 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for nolibc tests
-include ../../../scripts/Makefile.include
# We need this for the "cc-option" macro.
include ../../../build/Build.include

@@ -55,6 +54,12 @@ IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi
IMAGE = $(IMAGE_$(XARCH))
IMAGE_NAME = $(notdir $(IMAGE))

+# CROSS_COMPILE: cross toolchain prefix by architecture
+CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH))
+
+# Make CC is always prefixed with $(CROSS_COMPILE)
+include ../../../scripts/Makefile.include
+
# default kernel configurations that appear to be usable
DEFCONFIG_i386 = defconfig
DEFCONFIG_x86_64 = defconfig
--
2.25.1