RISCV compiler: Set mabi and march via Kconfig options

The mabi and march options of the compiler and linker commands
were previously hardcoded and depended only on the 64BIT config
option. This update allows these flags to be set by the config
options currently available, plus an additional option to
specify the compressed ISA.

Signed-off-by: Jaron Kelleher <jkelleher@fb.com>
This commit is contained in:
Jaron Kelleher 2020-03-04 11:04:26 -08:00 committed by Anas Nashif
commit bd4f721a59
3 changed files with 29 additions and 5 deletions

View file

@ -9,6 +9,10 @@ config ARCH
default "riscv64" if 64BIT default "riscv64" if 64BIT
default "riscv32" default "riscv32"
config COMPRESSED_ISA
bool
default y if 64BIT
menu "RISCV Processor Options" menu "RISCV Processor Options"
config INCLUDE_RESET_VECTOR config INCLUDE_RESET_VECTOR

View file

@ -49,11 +49,7 @@ elseif("${ARCH}" STREQUAL "arc")
-mcpu=${GCC_M_CPU} -mcpu=${GCC_M_CPU}
) )
elseif("${ARCH}" STREQUAL "riscv") elseif("${ARCH}" STREQUAL "riscv")
if(CONFIG_64BIT) include(${CMAKE_CURRENT_LIST_DIR}/target_riscv.cmake)
list(APPEND TOOLCHAIN_C_FLAGS -mabi=lp64 -march=rv64imac -mcmodel=medany)
else()
list(APPEND TOOLCHAIN_C_FLAGS -mabi=ilp32 -march=rv32ima)
endif()
elseif("${ARCH}" STREQUAL "x86") elseif("${ARCH}" STREQUAL "x86")
include(${CMAKE_CURRENT_LIST_DIR}/target_x86.cmake) include(${CMAKE_CURRENT_LIST_DIR}/target_x86.cmake)
endif() endif()

View file

@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
set(riscv_mabi "lp")
set(riscv_march "rv")
if(CONFIG_64BIT)
string(CONCAT riscv_mabi ${riscv_mabi} "64")
string(CONCAT riscv_march ${riscv_march} "64ima")
list(APPEND TOOLCHAIN_C_FLAGS -mcmodel=medany)
else()
string(CONCAT riscv_mabi "i" ${riscv_mabi} "32")
string(CONCAT riscv_march ${riscv_march} "32ima")
endif()
if(CONFIG_FLOAT)
string(CONCAT riscv_march ${riscv_march} "f")
endif()
if(CONFIG_COMPRESSED_ISA)
string(CONCAT riscv_march ${riscv_march} "c")
endif()
list(APPEND TOOLCHAIN_C_FLAGS -mabi=${riscv_mabi} -march=${riscv_march})
list(APPEND TOOLCHAIN_LD_FLAGS -mabi=${riscv_mabi} -march=${riscv_march})