Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm环境编译兼容性问题踩坑 #1138

Closed
jrt101 opened this issue Jan 11, 2022 · 1 comment
Closed

arm环境编译兼容性问题踩坑 #1138

jrt101 opened this issue Jan 11, 2022 · 1 comment

Comments

@jrt101
Copy link

jrt101 commented Jan 11, 2022

pika在arm环境编译

  • what: pika在arm环境编译
  • where: centos8 aarch64
  • when: 2022.1.4
  • who: 无名
  • why: 记录
  • how:
  • release: 3.6.6

1.安装依赖

yum -y install epel-release
yum install gcc-c++ gcc make cmake vim wget git which  -y
dnf --enablerepo=powertools install glog-devel  -y
dnf --enablerepo=powertools install snappy-devel -y
yum -y install gflags-devel
yum install -y  diffutils
dnf --enablerepo=powertools install protobuf-devel
yum install rsync -y 

2.组件编译

2.1 下载源码

[root@3d852ecb608f /]# cd /usr/local/
[root@3d852ecb608f local]# ls
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@3d852ecb608f local]# git clone https://github.com/OpenAtomFoundation/pika.git && cd pika
Cloning into 'pika'...
remote: Enumerating objects: 11217, done.
remote: Counting objects: 100% (266/266), done.
remote: Compressing objects: 100% (214/214), done.
remote: Total 11217 (delta 77), reused 127 (delta 49), pack-reused 10951
Receiving objects: 100% (11217/11217), 84.52 MiB | 17.43 MiB/s, done.
Resolving deltas: 100% (8138/8138), done.
[root@3d852ecb608f pika]#

2.2 切换版本

[root@3d852ecb608f pika]# git checkout v3.3.6
Note: switching to 'v3.3.6'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 9e74c8c vsersion 3.3.6
[root@3d852ecb608f pika]#

2.3初始化

初始化依赖外网,最好挂vpn

[root@3d852ecb608f pika]# git submodule init
Submodule 'third/blackwidow' (https://github.com/Qihoo360/blackwidow.git) registered for path 'third/blackwidow'
Submodule 'third/glog' (https://github.com/Qihoo360/glog.git) registered for path 'third/glog'
Submodule 'third/pink' (https://github.com/Qihoo360/pink.git) registered for path 'third/pink'
Submodule 'third/rocksdb' (https://github.com/facebook/rocksdb.git) registered for path 'third/rocksdb'
Submodule 'third/slash' (https://github.com/Qihoo360/slash.git) registered for path 'third/slash'
[root@3d852ecb608f pika]# git submodule update
Cloning into '/usr/local/pika/third/blackwidow'...
Cloning into '/usr/local/pika/third/glog'...
Cloning into '/usr/local/pika/third/pink'...
Cloning into '/usr/local/pika/third/rocksdb'...
Cloning into '/usr/local/pika/third/slash'...
Submodule path 'third/blackwidow': checked out '7565ce9f09f9528b90984feefe6ad850bf87fe90'
Submodule path 'third/glog': checked out 'ecdbd7cda69e1ff304ac02f7f277715a162e1474'
Submodule path 'third/pink': checked out 'fb34df9c885a12ac2f31a19760e93e451ffc4714'
Submodule path 'third/rocksdb': checked out '004237e62790320d8e630456cbeb6f4a1f3579c2'
Submodule path 'third/slash': checked out 'c1315c0d5ed2a60b21cc1db4b9f29ee833e7d2a3'

2.4 编译

PORTABLE=1 make

日志

/usr/local/pika/src/pika_admin.cc: In member function ‘void InfoCmd::InfoReplication(std::__cxx11::string&)’:
/usr/local/pika/src/pika_admin.cc:964:7: warning: this statement may fall through [-Wimplicit-fallthrough]
       if (!all_partition_sync) {
       ^~
/usr/local/pika/src/pika_admin.cc:967:5: note: here
     case PIKA_ROLE_SINGLE :
     ^~~~
  CC       pika_repl_bgworker.o
  CC       pika_zset.o
  CC       pika_repl_client_thread.o
  CC       pika_slave_node.o
  CCLD     pika

3.启动

[root@3d852ecb608f pika]# ./output/bin/pika -c ./conf/pika.conf

4.问题解决

4.1问题一:

问题1:使用PORTABLE=1 make编译报如下错:

make[1]: Entering directory `/jrt/pika/third/slash/slash'
g++: error: unrecognized command line option '-msse'
g++: error: unrecognized command line option '-msse4.2'
g++: error: unrecognized command line option '-msse'
g++: error: unrecognized command line option '-msse4.2'
g++: error: unrecognized command line option '-msse'
g++: error: unrecognized command line option '-msse4.2'
g++: error: unrecognized command line option '-msse'
g++: error: unrecognized command line option '-msse4.2'
g++: error: unrecognized command line option '-msse'
g++: error: unrecognized command line option '-msse4.2'
g++: error: unrecognized command line option '-msse'

问题解决

-msse -msse4.2是x86专属的识别硬件参数,arm没有,利用grep -r msse找到所有带这个参数的文本,进入文本删除该两个参数,若语法中引号中只有该参数,删除该参数时并删除引号
[root@598939ec6129 pika]# grep -r msse
Makefile:PLATFORM_CXXFLAGS= -std=c++11 -fno-builtin-memcmp -msse -msse4.2 
third/blackwidow/benchmark/Makefile:CXXFLAGS=-O2 -std=c++11 -fno-builtin-memcmp -msse -msse4.2
third/blackwidow/tests/Makefile:CXXFLAGS= -g -std=c++11 -fno-builtin-memcmp -msse -msse4.2
third/blackwidow/Makefile:CXXFLAGS= -g -std=c++11 -fno-builtin-memcmp -msse -msse4.2 -pipe -fPIC
third/blackwidow/examples/Makefile:CXXFLAGS=-O2 -std=c++11 -fno-builtin-memcmp -mss -msse4.2
third/rocksdb/build_tools/build_detect_platform:  COMMON_FLAGS="$COMMON_FLAGS -msse4.2"
third/rocksdb/CMakeLists.txt:    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
third/rocksdb/CMakeLists.txt:  set(CMAKE_REQUIRED_FLAGS "-msse4.2")
third/rocksdb/CMakeLists.txt:      PROPERTIES COMPILE_FLAGS "-msse4.2")
third/pink/pink/Makefile:CXXFLAGS= -g -std=c++11 -fno-builtin-memcmp -msse -msse4.2 -pipe -fPIC
third/pink/pink/examples/Makefile:CXXFLAGS=-O2 -std=c++11 -fno-builtin-memcmp -msse -msse4.2
third/slash/slash/Makefile:CXXFLAGS= -g -std=c++11 -fno-builtin-memcmp -msse -msse4.2 -pipe -fPIC
third/slash/slash/examples/Makefile:CXXFLAGS= -O2 -std=c++11 -fno-builtin-memcmp -msse -msse4.2
[root@598939ec6129 pika]# 

4.2问题2:

问题2:使用PORTABLE=1 make编译报如下错:

memtable/skiplistrep.cc:28:28:   required from here
./memtable/inlineskiplist.h:282:11: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::atomic<rocksdb::InlineSkipList<const rocksdb::MemTableRep::KeyComparator&>::Node*>’ with no trivial copy-assignment [-Werror=class-memaccess]
     memcpy(&next_[0], &height, sizeof(int));
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./memtable/inlineskiplist.h:47,
                 from memtable/skiplistrep.cc:6:
/usr/include/c++/8/atomic:352:12: note: ‘struct std::atomic<rocksdb::InlineSkipList<const rocksdb::MemTableRep::KeyComparator&>::Node*>’ declared here
     struct atomic<_Tp*>
            ^~~~~~~~~~~~
  CC       monitoring/thread_status_updater.o
  CC       monitoring/thread_status_updater_debug.o
  CC       monitoring/thread_status_util.o
  CC       monitoring/thread_status_util_debug.o
  CC       options/cf_options.o
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1809: memtable/skiplistrep.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/opt/pika/third/rocksdb'
make: *** [Makefile:229: /opt/pika/third/rocksdb/librocksdb.a] Error 2

问题解决

#在inlineskiplist.h中约282行,StashHeight函数中增加(void*),具体见下文
vim /usr/local/pika/third/rocksdb/memtable/inlineskiplist.h

 void StashHeight(const int height) {
    assert(sizeof(int) <= sizeof(next_[0]));
    memcpy((void*)&next_[0], (void*)&height, sizeof(int));
  }
 
#参考链接:https://www.cnblogs.com/saikaimei/p/14396369.html

4.3问题3:

问题3:执行./output/bin/pika -c ./conf/pika.conf启动服务时只是回显版本,服务未正常启动

问题解决:

yum install rsync -y 
#进入pika代码主目录
src/pika.cc 约138行 char c 改为 signed char c
PORTABLE=1 make
./output/bin/pika -c ./conf/pika.conf
#查端口
yum install net-tools
netstat -nltp
@jrt101 jrt101 changed the title 就写arm环境编译兼容性问题 ,导致aarch64编译完,启动后服务没启动 arm环境编译兼容性问题 ,导致aarch64编译完,启动后服务没启动 Jan 11, 2022
@wanghenshui
Copy link
Collaborator

wanghenshui commented Jan 11, 2022

  • 问题1 等待cmake集成之后,修改slash解决兼容性问题
  • 问题2 等待集成cmake之后,升级rocskdb (需要修改blackwidow适配新的rocksdb)
  • 问题3已经解决,使用master分支

@wanghenshui wanghenshui changed the title arm环境编译兼容性问题 ,导致aarch64编译完,启动后服务没启动 arm环境编译兼容性问题踩坑 Jan 11, 2022
@wanghenshui wanghenshui mentioned this issue Feb 22, 2023
78 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants