From 597b5043884af32a54f07c46195381d4456cbb38 Mon Sep 17 00:00:00 2001 From: Hui Wang Date: Tue, 14 Jul 2026 12:31:08 +0800 Subject: [PATCH] kselftest/riscv: Improve building under native riscv64 environment When we build the kselftest natively, we usually don't pass an ARCH= parameter. In this case if I build kselftest/riscv under a riscv64 environment, the testcase will not be built at all because 'uname -m' returns riscv64 instead of riscv. make -C tools/testing/selftests TARGETS=riscv make: Entering directory 'linux/tools/testing/selftests' make[1]: Entering directory 'linux/tools/testing/selftests/riscv' make[1]: Leaving directory 'linux/tools/testing/selftests/riscv' make: Leaving directory 'linux/tools/testing/selftests' This issue can be fixed by getting ARCH from scripts/subarch.include, whose SUBARCH normalizes 'riscv64' to 'riscv'. This also aligns with how other selftests (e.g. arm64, x86) already resolve ARCH. Signed-off-by: Hui Wang Signed-off-by: Linux RISC-V bot --- tools/testing/selftests/riscv/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/riscv/Makefile b/tools/testing/selftests/riscv/Makefile index 5671b4405a1294..43eddb91970579 100644 --- a/tools/testing/selftests/riscv/Makefile +++ b/tools/testing/selftests/riscv/Makefile @@ -1,8 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 # Originally tools/testing/arm64/Makefile +# A proper top_srcdir is needed by KSFT(lib.mk) +top_srcdir = $(realpath ../../../../) + # When ARCH not overridden for crosscompiling, lookup machine -ARCH ?= $(shell uname -m 2>/dev/null || echo not) +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) ifneq (,$(filter $(ARCH),riscv)) RISCV_SUBTARGETS ?= abi hwprobe mm sigreturn vector cfi @@ -12,9 +16,6 @@ endif CFLAGS := -Wall -O2 -g -# A proper top_srcdir is needed by KSFT(lib.mk) -top_srcdir = $(realpath ../../../../) - # Additional include paths needed by kselftest.h and local headers CFLAGS += -I$(top_srcdir)/tools/testing/selftests/