1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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
This commit is contained in:
Marian Buschsieweke 2023-07-03 15:20:30 +02:00
parent c2df430deb
commit 55e223353a
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -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