Skip to content

Commit

Permalink
build: update riscv64 toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Apr 23, 2024
1 parent eb00663 commit 5c27933
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions cmake/x86_64-riscv64-gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,42 @@
#
# x86_64-riscv64-gcc.cmake for Simple-XX/SimpleKernel.

if (APPLE)
message(FATAL_ERROR "NOT support OSX, Please use linux")
elseif (UNIX)
if (NOT UNIX)
message(FATAL_ERROR "Only support Linux.")
endif ()

if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv64")
# GCC
find_program(Compiler_gcc g++)
if (NOT Compiler_gcc)
message(FATAL_ERROR "g++ not found.\n"
"Run `sudo apt-get install -y gcc g++` to install.")
else ()
message(STATUS "Found g++ ${Compiler_gcc}")
endif ()
elseif (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
find_program(Compiler_gcc riscv64-linux-gnu-g++)
if (NOT Compiler_gcc)
message(FATAL_ERROR "riscv64-linux-gnu-g++ not found.\n"
"Run `sudo apt install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu` to install.")
endif ()

set(TOOLCHAIN_PREFIX riscv64-linux-gnu-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_READELF ${TOOLCHAIN_PREFIX}readelf)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib)
elseif (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
find_program(Compiler_gcc_cr riscv64-linux-gnu-g++)
if (NOT Compiler_gcc_cr)
message(FATAL_ERROR "riscv64-linux-gnu-g++ not found.\n"
"Run `sudo apt install -y g++-riscv64-linux-gnu` to install.")
else ()
message(STATUS "Found riscv64-linux-gnu-g++ ${Compiler_gcc}")
message(STATUS "Found riscv64-linux-gnu-g++ ${Compiler_gcc_cr}")
endif ()

set(TOOLCHAIN_PREFIX riscv64-linux-gnu-)
Expand All @@ -25,4 +51,6 @@ elseif (UNIX)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib)
else ()
message(FATAL_ERROR "NOT support ${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif ()

0 comments on commit 5c27933

Please sign in to comment.