From 00794b92c4fdbfb60e57fdf423e7e21fc07de879 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 8 Jan 2025 19:15:26 +0800 Subject: [PATCH] arch/risc-v: Improve LLVM CPU type detection with findstring Use findstring instead of direct equality checks for LLVM_CPUTYPE conditions to better handle ARCHCPUEXTFLAGS that may contain additional ISA extensions. This makes the CPU type detection more robust when dealing with extended instruction sets while still ensuring the required base ISA extensions are present. For example, ARCHCPUEXTFLAGS="imc_zicsr_zifencei" will now correctly match as sifive-e20 rather than failing the exact match check. Signed-off-by: Huang Qi --- arch/risc-v/src/common/Toolchain.defs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index ef13c63a78..5873608a74 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -277,17 +277,17 @@ endif # These models can't cover all implementation of RISCV, but it's enough for most cases. ifeq ($(CONFIG_ARCH_RV32),y) - ifeq ($(ARCHCPUEXTFLAGS), imc) + ifeq ($(findstring imc,$(ARCHCPUEXTFLAGS)),imc) LLVM_CPUTYPE := sifive-e20 - else ifeq ($(ARCHCPUEXTFLAGS), imac) + else ifeq ($(findstring imac,$(ARCHCPUEXTFLAGS)),imac) LLVM_CPUTYPE := sifive-e31 - else ifeq ($(ARCHCPUEXTFLAGS), imafc) + else ifeq ($(findstring imafc,$(ARCHCPUEXTFLAGS)),imafc) LLVM_CPUTYPE := sifive-e76 endif else - ifeq ($(ARCHCPUEXTFLAGS), imac) + ifeq ($(findstring imac,$(ARCHCPUEXTFLAGS)),imac) LLVM_CPUTYPE := sifive-s51 - else ifeq ($(ARCHCPUEXTFLAGS), imafdc) + else ifeq ($(findstring imafdc,$(ARCHCPUEXTFLAGS)),imafdc) LLVM_CPUTYPE := sifive-u54 endif endif