Skip to content

Commit 6f8e6e1

Browse files
authored
feat(build): add arm64 support for openEuler OS (deepseek-ai#107)
- Enable compilation on arm64 (aarch64) architecture by conditionally adjusting compiler flags. - Ensure proper linkage with compiler-rt and libgcc on ARM to resolve missing symbol issues. - Update README.md with installation instructions for openEuler 2403sp1. Signed-off-by: Haomai Wang <[email protected]>
1 parent 49e0ad5 commit 6f8e6e1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ endif()
6767
# Remove project root from the __FILE__ macro variable
6868
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.)
6969

70-
add_compile_options(-msse4.2 -mavx2)
70+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
71+
add_compile_options(-msse4.2 -mavx2)
72+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
73+
# ARM architecture detected:
74+
# Clang on ARM uses built-in runtime library (compiler-rt) to provide symbols like '__muloti4'.
75+
# Without explicitly specifying '-rtlib=compiler-rt', linking may fail due to missing '__muloti4'.
76+
# '-unwindlib=libgcc' ensures proper exception unwinding compatibility.
77+
add_compile_options(-march=armv8-a)
78+
message(STATUS "ARM architecture detected, linking with compiler-rt and libgcc.")
79+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rtlib=compiler-rt -unwindlib=libgcc")
80+
endif()
7181
add_compile_definitions(ROCKSDB_NAMESPACE=rocksdb_internal)
7282
include(cmake/Sanitizers.cmake)
7383
include(cmake/CompileFlags.cmake)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ apt install cmake libuv1-dev liblz4-dev liblzma-dev libdouble-conversion-dev lib
7979
apt install cmake libuv1-dev liblz4-dev liblzma-dev libdouble-conversion-dev libdwarf-dev libunwind-dev \
8080
libaio-dev libgflags-dev libgoogle-glog-dev libgtest-dev libgmock-dev clang-format-14 clang-14 clang-tidy-14 lld-14 \
8181
libgoogle-perftools-dev google-perftools libssl-dev gcc-12 g++-12 libboost-all-dev
82+
83+
# for openEuler 2403sp1
84+
yum install cmake libuv-devel lz4-devel xz-devel double-conversion-devel libdwarf-devel libunwind-devel \
85+
libaio-devel gflags-devel glog-devel gtest-devel gmock-devel clang-tools-extra clang lld \
86+
gperftools-devel gperftools openssl-devel gcc gcc-c++ boost-devel
8287
```
8388

8489
Install other build prerequisites:

0 commit comments

Comments
 (0)