Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
19791: makefiles/arch/riscv.inc.mk: speed up toolchain detection r=benpicco a=maribu

### Contribution description

- 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 RIOT-OS#19788


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
  • Loading branch information
bors[bot] and maribu authored Jul 6, 2023
2 parents a345e00 + 55e2233 commit e487ac5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion makefiles/arch/riscv.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e487ac5

Please sign in to comment.