Skip to content

Commit

Permalink
riscv: toolchain arguments for a 64-bit build
Browse files Browse the repository at this point in the history
For now we enforce the medany code model for 64-bit builds as we get
reloc issues otherwise. The instruction set and ABI are also set to
soft-float usage.

The ilp32 ABI is explicitly specified on 32-bit build to make sure
it is not using a wrong default if the same toolchain is used for both
32- and 64-bit builds. The archittecture options are the same as the
SDK's riscv32 toolchain default in that case.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information
Nicolas Pitre authored and galak committed Aug 9, 2019
1 parent 55c3585 commit c351492
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/riscv/CMakeLists.txt
Expand Up @@ -2,4 +2,8 @@


add_subdirectory(core) add_subdirectory(core)


if(CONFIG_64BIT)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf64-littleriscv)
else()
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littleriscv) set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littleriscv)
endif()
6 changes: 6 additions & 0 deletions cmake/compiler/gcc/target.cmake
Expand Up @@ -69,6 +69,12 @@ elseif("${ARCH}" STREQUAL "arc")
list(APPEND TOOLCHAIN_C_FLAGS list(APPEND TOOLCHAIN_C_FLAGS
-mcpu=${GCC_M_CPU} -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()
endif() endif()


if(NOT no_libgcc) if(NOT no_libgcc)
Expand Down

0 comments on commit c351492

Please sign in to comment.