diff --git a/arch/arm64/rules.mk b/arch/arm64/rules.mk index c0210c40..f4145af5 100644 --- a/arch/arm64/rules.mk +++ b/arch/arm64/rules.mk @@ -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 diff --git a/arch/riscv/rules.mk b/arch/riscv/rules.mk index 44fb993f..24d8e19d 100644 --- a/arch/riscv/rules.mk +++ b/arch/riscv/rules.mk @@ -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 diff --git a/engine.mk b/engine.mk index 4c32fade..65c75261 100644 --- a/engine.mk +++ b/engine.mk @@ -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