From 55e223353af615bb0f8ed4d17a8032b8f09f6883 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 3 Jul 2023 15:20:30 +0200 Subject: [PATCH] makefiles/arch/riscv.inc.mk: speed up toolchain detection - Use a sane (a.k.a. simply expanded) variable for the `$(TARGET_ARCH)` instead of an insane (a.k.a. recursive expended) variable - The toolchain detection will now happen only once, rather than each and every time `$(TARGET_ARCH)` is referenced - Use a single call to `which` rather than one per possible target triple Fixes https://github.com/RIOT-OS/RIOT/issues/19788 --- makefiles/arch/riscv.inc.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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