CMake: RISC-V build fixes

This commit is contained in:
Stenzek 2023-12-21 00:55:53 +10:00
parent 36643fe78b
commit 8206b2b74a
No known key found for this signature in database

View file

@ -183,11 +183,19 @@ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}"
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a")
endif() endif()
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "riscv64") elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "riscv64")
set(CPU_ARCH "riscv64") set(CPU_ARCH_RISCV64 TRUE)
message("Building RISC-V 64 binaries.") message("Building RISC-V 64 binaries.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-atomics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finline-atomics")
# Not done for us. Or we should inline atomics? # Still need this, apparently.
link_libraries("-latomic") link_libraries("-latomic")
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
# Frame pointers generate an annoying amount of code on leaf functions.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer")
endif()
else() else()
message(FATAL_ERROR "Unknown system processor: ${CMAKE_SYSTEM_PROCESSOR}") message(FATAL_ERROR "Unknown system processor: ${CMAKE_SYSTEM_PROCESSOR}")
endif() endif()