[riscv][toolchain] fix clang test of -misa switch which is not present

The test inside riscv/rules.mk was assuming gcc and that the CC variable
isn't passed in from the user. This is not a very clean solution and
acts like a bandaid over the problem. Added some todos for a potential
solution.
This commit is contained in:
Travis Geiselbrecht
2025-10-05 13:54:11 -07:00
parent 48d331f144
commit e0b5008641
3 changed files with 10 additions and 0 deletions

View File

@@ -111,6 +111,7 @@ ARCH_COMPILEFLAGS_FLOAT :=
ARCH_LDFLAGS += -z max-page-size=$(ARM64_PAGE_SIZE)
# Note: assumes the use of gcc and the user is not overriding CC which is set later in engine.mk
LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) -print-libgcc-file-name)
# make sure some bits were set up

View File

@@ -183,7 +183,12 @@ endif
# test to see if -misa-spec=2.2 is a valid switch.
# misa-spec is added to make sure the compiler picks up the zicsr extension by default.
# If CC is being overridden by the user, use that instead of the toolchain gcc.
ifdef CC
MISA_SPEC := $(shell $(CC) $(ARCH_COMPILEFLAGS) -misa-spec=2.2 -E - < /dev/null > /dev/null 2>1 && echo supported)
else
MISA_SPEC := $(shell $(TOOLCHAIN_PREFIX)gcc $(ARCH_COMPILEFLAGS) -misa-spec=2.2 -E - < /dev/null > /dev/null 2>1 && echo supported)
endif
$(info MISA_SPEC = $(MISA_SPEC))
ifeq ($(MISA_SPEC),supported)
ARCH_COMPILEFLAGS += -misa-spec=2.2

View File

@@ -202,6 +202,10 @@ $(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
list-toolchain:
else
# TODO: rethink how this works and perhaps have the arch rules.mk set up CC, OBJCOPY, etc
# so that they can be a bit more flexible in how they are set up.
# Also consider using ARCH_CC, etc to disambiguate between host and target toolchains.
# default to no ccache
CCACHE ?=
CC ?= $(CCACHE) $(TOOLCHAIN_PREFIX)gcc