Skip to content

Commit f86d04e

Browse files
Add RISC-V architecture support
This commit adds full support for RISC-V 64-bit architecture to brpc. Changes include: - Add RISC-V atomic operations implementation - Add RISC-V architecture detection in build system - Add RISC-V context switching (bthread support) - Add RISC-V clock cycle counter support (rdcycle) - Update CMake and Makefile for RISC-V compilation All core functionalities have been tested and verified in QEMU RISC-V environment, including: - Atomic operations (32-bit and 64-bit) - Memory barriers - Context switching - Clock cycle counting Co-authored-by: gong-flying <gongxiaofei24@iscas.ac.cn>
1 parent 0708333 commit f86d04e

11 files changed

Lines changed: 312 additions & 606 deletions

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
170170
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64"))
171171
# segmentation fault in libcontext
172172
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-gcse")
173+
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64"))
174+
# RISC-V specific optimizations
175+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64gc")
173176
endif()
174177
if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0))
175178
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-aligned-new")

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
4444
CXXFLAGS+=-msse4 -msse4.2
4545
endif
4646
endif
47+
# RISC-V specific optimizations
48+
ifeq ($(shell uname -m),riscv64)
49+
CXXFLAGS+=-march=rv64gc
50+
endif
4751
#not solved yet
4852
ifeq ($(CC),gcc)
4953
ifeq ($(shell test $(GCC_VERSION) -ge 70000; echo $$?),0)

0 commit comments

Comments
 (0)