Skip to content

Commit

Permalink
risc-v: Fix risc-gnu-toolchain -march=rv64imafdc_zicsr_zifencei error.
Browse files Browse the repository at this point in the history
cc1: error: '-march=rv64imafdc_zicsr_zifencei': unsupported ISA subset 'z'
cc1: error: requested ABI requires '-march' to subsume the 'D' extension
cc1: error: ABI requires '-march=rv64'

Signed-off-by: cuiziwei <[email protected]>
  • Loading branch information
cuiziweizw committed Oct 11, 2024
1 parent 5076b0c commit 2f23220
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion arch/risc-v/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,16 @@ if(CONFIG_RISCV_TOOLCHAIN STREQUAL GNU_RVG)
endif()

if(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI)
set(ARCHCPUEXTFLAGS ${ARCHCPUEXTFLAGS}_zicsr_zifencei)
if(NOT DEFINED GCCVER)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
"${GCC_VERSION_OUTPUT}")
set(GCCVER ${CMAKE_MATCH_1})
endif()
if(GCCVER GREATER_EQUAL 12 OR CONFIG_ARCH_TOOLCHAIN_CLANG)
set(ARCHCPUEXTFLAGS ${ARCHCPUEXTFLAGS}_zicsr_zifencei)
endif()
endif()

if(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)
Expand Down
7 changes: 6 additions & 1 deletion arch/risc-v/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
endif

ifeq ($(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI),y)
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
ifeq ($(GCCVER),)
export GCCVER = ${shell $(CROSSDEV)gcc --version | grep gcc | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1 | cut -d"." -f1 }
endif
ifeq ($(shell expr $(GCCVER) \>= 12), 1)
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
endif
endif

ARCH_RV_EXPERIMENTAL_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)))
Expand Down

0 comments on commit 2f23220

Please sign in to comment.