Skip to content

Commit

Permalink
arch/risc-v: add llvm experimental extensions into command line
Browse files Browse the repository at this point in the history
LLVM supports (to various degrees) a number of experimental extensions.
All experimental extensions have experimental- as a prefix. There is
explicitly no compatibility promised between versions of the toolchain,
and regular users are strongly advised not to make use of experimental
extensions before they reach ratification.

Fix compile error:
riscv64-unknown-elf-clang: error: invalid arch name 'rv64gcv_zfh_zvfh', requires '-menable-experimental-extensions' for experimental extension 'zvfh'

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and xiaoxiang781216 committed Apr 19, 2024
1 parent d11b1ba commit d59f918
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/risc-v/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,18 @@ config ARCH_RV_ISA_ZICSR_ZIFENCEI
clang < 17 or GCC < 11.3.0, for which this is not possible or need
special treatment.

config ARCH_RV_EXPERIMENTAL_EXTENSIONS
string "LLVM RISC-V Experimental Extensions"
default ""
depends on RISCV_TOOLCHAIN_CLANG
---help---
This option allows the platform to enable experimental extensions,
LLVM supports (to various degrees) a number of experimental extensions.
All experimental extensions have experimental- as a prefix. There is
explicitly no compatibility promised between versions of the toolchain,
and regular users are strongly advised not to make use of experimental
extensions before they reach ratification.

config ARCH_RV_ISA_VENDOR_EXTENSIONS
string "Vendor Custom RISC-V Instruction Set Architecture Extensions"
default ""
Expand Down
6 changes: 6 additions & 0 deletions arch/risc-v/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
endif()
endif()

if(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)
set(ARCHCPUEXTFLAGS
${ARCHCPUEXTFLAGS}_${CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS})
add_compile_options(-menable-experimental-extensions)
endif()

if(CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS)
set(ARCHCPUEXTFLAGS
${ARCHCPUEXTFLAGS}_${CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS})
Expand Down
6 changes: 6 additions & 0 deletions arch/risc-v/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
endif
endif

ARCH_RV_EXPERIMENTAL_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)))
ifneq ($(ARCH_RV_EXPERIMENTAL_EXTENSIONS),)
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_$(ARCH_RV_EXPERIMENTAL_EXTENSIONS)
ARCHOPTIMIZATION += -menable-experimental-extensions
endif

ARCH_RV_ISA_VENDOR_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_ISA_VENDOR_EXTENSIONS)))
ifneq ($(ARCH_RV_ISA_VENDOR_EXTENSIONS),)
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_$(ARCH_RV_ISA_VENDOR_EXTENSIONS)
Expand Down

0 comments on commit d59f918

Please sign in to comment.