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:
parent
c8d26b4b14
commit
bd4f721a59
3 changed files with 29 additions and 5 deletions
|
@ -9,6 +9,10 @@ config ARCH
|
|||
default "riscv64" if 64BIT
|
||||
default "riscv32"
|
||||
|
||||
config COMPRESSED_ISA
|
||||
bool
|
||||
default y if 64BIT
|
||||
|
||||
menu "RISCV Processor Options"
|
||||
|
||||
config INCLUDE_RESET_VECTOR
|
||||
|
|
|
@ -49,11 +49,7 @@ elseif("${ARCH}" STREQUAL "arc")
|
|||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
elseif("${ARCH}" STREQUAL "riscv")
|
||||
if(CONFIG_64BIT)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mabi=lp64 -march=rv64imac -mcmodel=medany)
|
||||
else()
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mabi=ilp32 -march=rv32ima)
|
||||
endif()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target_riscv.cmake)
|
||||
elseif("${ARCH}" STREQUAL "x86")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target_x86.cmake)
|
||||
endif()
|
||||
|
|
24
cmake/compiler/gcc/target_riscv.cmake
Normal file
24
cmake/compiler/gcc/target_riscv.cmake
Normal 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})
|
Loading…
Add table
Add a link
Reference in a new issue