diff --git a/makefiles/arch/riscv.inc.mk b/makefiles/arch/riscv.inc.mk index 3544b214b1..b8fc8da19a 100644 --- a/makefiles/arch/riscv.inc.mk +++ b/makefiles/arch/riscv.inc.mk @@ -35,10 +35,15 @@ TARGET_ARCH_RISCV ?= \ $(subst -gcc,,\ $(notdir \ $(word 1,\ - $(foreach triple,$(_TRIPLES_TO_TEST),$(shell which $(triple)-gcc 2> /dev/null)))))) + $(shell which $(addsuffix -gcc,$(_TRIPLES_TO_TEST)) 2> /dev/null))))) TARGET_ARCH ?= $(TARGET_ARCH_RISCV) +# Convert to a simply expanded variable here, as a recursively expended +# variable would result in detecting the toolchain each and every time again the +# toolchain is referenced. +TARGET_ARCH := $(TARGET_ARCH) + ifeq (,$(TARGET_ARCH)) $(error No RISC-V toolchain detected. Make sure a RISC-V toolchain is installed.) endif