Skip to content

Commit

Permalink
CMakeLists: Add a RISCV_NONE toolchain
Browse files Browse the repository at this point in the history
Add a RISCV_NONE toolchain to target an embedded environment. This
allows building libspdm libraries with mbedtls.

Signed-off-by: Alistair Francis <[email protected]>
  • Loading branch information
alistair23 committed Nov 7, 2023
1 parent d836331 commit e1a6c5b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE("TOOLCHAIN = RISCV_GNU")
elseif(TOOLCHAIN STREQUAL "RISCV64_GCC")
MESSAGE("TOOLCHAIN = RISCV64_GCC")
elseif(TOOLCHAIN STREQUAL "RISCV_NONE")
MESSAGE("TOOLCHAIN = RISCV_NONE")
elseif(TOOLCHAIN STREQUAL "RISCV_XPACK")
MESSAGE("TOOLCHAIN = RISCV_XPACK")
elseif(TOOLCHAIN STREQUAL "ARC_GCC")
Expand Down Expand Up @@ -417,6 +419,30 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")

SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--start-group <LINK_LIBRARIES> -Wl,--end-group")

elseif(TOOLCHAIN STREQUAL "RISCV_NONE")
SET(CMAKE_C_COMPILER riscv64-elf-gcc)
ADD_COMPILE_OPTIONS(-nostdlib -lgcc)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_COMPILE_OPTIONS(-g)
endif()

if(ARCH STREQUAL "riscv32")
ADD_COMPILE_OPTIONS(-march=rv32imac_zicsr -mabi=ilp32)
elseif(ARCH STREQUAL "riscv64")
ADD_COMPILE_OPTIONS(-march=rv64imac_zicsr -mabi=lp64)
else()
ADD_COMPILE_OPTIONS(-march=error -mabi=error)
endif()

SET(CMAKE_AR riscv64-elf-ar)

SET(CMAKE_LINKER riscv64-elf-gcc)
SET(CMAKE_EXE_LINKER_FLAGS "-no-pie" )

SET(MBEDTLS_FLAGS -nostdlib -lgcc)

SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--start-group <LINK_LIBRARIES> -Wl,--end-group")

elseif(TOOLCHAIN STREQUAL "RISCV_XPACK")
SET(CMAKE_C_COMPILER riscv-none-elf-gcc)
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
Expand Down

0 comments on commit e1a6c5b

Please sign in to comment.