diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d6e374fcde3..296cf57d4ac 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -13,6 +13,14 @@ config COMPRESSED_ISA bool default y if 64BIT +config RISCV_ATOMICS_ISA + bool "RISC-V atomics 'a' extension" + default y + +config RISCV_MUL_ISA + bool "RISC-V HW multiply 'm' extension" + default y + config FLOAT_HARD bool "Hard-float calling convention" default y diff --git a/cmake/compiler/gcc/target_riscv.cmake b/cmake/compiler/gcc/target_riscv.cmake index ae61a9a7330..e2e03c7fdf1 100644 --- a/cmake/compiler/gcc/target_riscv.cmake +++ b/cmake/compiler/gcc/target_riscv.cmake @@ -5,12 +5,19 @@ set(riscv_march "rv") if(CONFIG_64BIT) string(CONCAT riscv_mabi ${riscv_mabi} "64") - string(CONCAT riscv_march ${riscv_march} "64ima") + string(CONCAT riscv_march ${riscv_march} "64i") list(APPEND TOOLCHAIN_C_FLAGS -mcmodel=medany) list(APPEND TOOLCHAIN_LD_FLAGS -mcmodel=medany) else() string(CONCAT riscv_mabi "i" ${riscv_mabi} "32") - string(CONCAT riscv_march ${riscv_march} "32ima") + string(CONCAT riscv_march ${riscv_march} "32i") +endif() + +if (CONFIG_RISCV_MUL_ISA) + string(CONCAT riscv_march ${riscv_march} "m") +endif() +if (CONFIG_RISCV_ATOMICS_ISA) + string(CONCAT riscv_march ${riscv_march} "a") endif() if(CONFIG_FPU)