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下编译错误 #75

Open
kenlee1988 opened this issue Mar 2, 2021 · 5 comments
Open

鲲鹏ARM下编译错误 #75

kenlee1988 opened this issue Mar 2, 2021 · 5 comments
Labels
compile Software compilation problem

Comments

@kenlee1988
Copy link

鲲鹏ARM下编译错误

代码是最新的dev-2.2分支代码,
gcc版本为7.3.0
$MVYH83DOJ6X98ZS NK3 90
XU4EK$VQPGD%YCECW$JX(A1

@huawux huawux added the compile Software compilation problem label Mar 5, 2021
@TendisDev TendisDev added the beginner level Simple question or need support label Mar 5, 2021
@jimking0301
Copy link

我也出现了一样的错误

我尝试着找了一些方案,看到其中一个解释是这么说的

The C and C++ standards allows the character type char to be signed or unsigned, depending on the platform and compiler. Most systems, including x86 GNU/Linux and Microsoft Windows, use signed char, but those based on PowerPC and ARM processors typically use unsigned char.(29) This can lead to unexpected results when porting programs between platforms which have different defaults for the type of char.

@TendisDev TendisDev added the fixed fixed already label Apr 21, 2021
@TendisDev
Copy link
Collaborator

The compile problem has been fixed. Please checkout the latest version.

@cmwl
Copy link

cmwl commented Nov 3, 2021

新版本未解决,需手动将src/tendisplus/utils/base64.cpp中的DecodeTable与ch变量的定义新增signed

@piaoxue1949
Copy link

piaoxue1949 commented Nov 29, 2021

我也在鲲鹏arm上编译,基于centos8.3.2011(docker),由于gcc版本较高,遇到较多问题,整理了一下,有遇到类似问题的可以参照一下。

Centos8编译Tendis

1 编译Tendis

1 安装基础环境

yum install -y python38-devel gcc-c++ flex bison tbb-devel numactl-devel autoconf diffutils

2 下载tendis源码

git clone https://github.com/Tencent/tendis.git --recursive
git submodule update --init --recursive
# 切换到标签分支
git stash && git checkout 2.4.2-rocksdb-v5.13.4
# 加权限,解决未来时间的问题
find ./ -name "*.sh" | xargs chmod 777 && find . |xargs touch

3安装doxygen库

git clone https://github.com/doxygen/doxygen.git && \
cd doxygen && \
cmake -G "Unix Makefiles" .. && \
make -j 8 && make install

4编译tendis

mkdir bulid
cd build
cmake ../

5 编译错误处理

1 Werror报错

/opt/Tendis/src/tendisplus/utils/base64.cpp:70:12: error: comparison is always false due to limited range of data type [-Werror=type-limits]
     if (ch < 0) {
         ~~~^~~
cc1plus: some warnings being treated as errors
make[2]: *** [src/tendisplus/utils/CMakeFiles/utils_common.dir/build.make:160: src/tendisplus/utils/CMakeFiles/utils_common.dir/base64.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2805: src/tendisplus/utils/CMakeFiles/utils_common.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

在build.make同目录下的flags.make中增加忽略选项,形如-Wno-error=class-memaccess。主要有

CMakeLists.txt
-Wno-error=class-memaccess

src/tendisplus/utils/CMakeFiles/utils_common.dir/flags.make
-Wno-error=narrowing -Wno-error=type-limits

src/tendisplus/cluster/CMakeFiles/migrate.dir/flags.make
-Wno-error=parentheses

src/tendisplus/replication/CMakeFiles/repl_manager.dir/flags.make
-Wno-error=format-truncation

2 代码报错

(1)

/opt/Tendis/src/tendisplus/utils/test_util.cpp: In function ‘std::shared_ptr<tendisplus::ServerEntry> tendisplus::makeServerEntryOld(const std::shared_ptr<tendisplus::ServerParams>&)’:
/opt/Tendis/src/tendisplus/utils/test_util.cpp:243:57: error: no matching function for call to ‘tendisplus::RocksKVStore::RocksKVStore(const char [8], const std::shared_ptr<tendisplus::ServerParams>&, std::nullptr_t, bool)’
new RocksKVStore(CATALOG_NAME, cfg, nullptr, false))),
^
In file included from /opt/Tendis/src/tendisplus/server/server_entry.h:28,
from /opt/Tendis/src/tendisplus/utils/test_util.h:18,
from /opt/Tendis/src/tendisplus/utils/test_util.cpp:14:
/opt/Tendis/src/tendisplus/storage/rocks/rocks_kvstore.h:211:3: note: candidate: ‘tendisplus::RocksKVStore::RocksKVStore(const string&, const std::shared_ptr<tendisplus::ServerParams>&, std::shared_ptr<rocksdb::Cache>, std::shared_ptr<rocksdb::RateLimiter>, bool, tendisplus::KVStore::StoreMode, tendisplus::RocksKVStore::TxnMode, uint32_t)’
RocksKVStore(const std::string& id,
^~~~~~~~~~~~
/opt/Tendis/src/tendisplus/storage/rocks/rocks_kvstore.h:211:3: note:   no known conversion for argument 4 from ‘bool’ to ‘std::shared_ptr<rocksdb::RateLimiter>’
make[2]: *** [src/tendisplus/utils/CMakeFiles/test_util.dir/build.make:76: src/tendisplus/utils/CMakeFiles/test_util.dir/test_util.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2941: src/tendisplus/utils/CMakeFiles/test_util.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

修改/opt/Tendis/src/tendisplus/utils/test_util.cpp,将RocksKVStore传参中nullptr前加block_cache

3 链接报错

(1)

/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
make[2]: *** [src/tendisplus/cluster/CMakeFiles/cluster_test.dir/build.make:158: bin/cluster_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:4229: src/tendisplus/cluster/CMakeFiles/cluster_test.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

​ 由于缺少libstdc++.a文件,故将build.make同目录中的link.txt中的-static-libstdc++ 改成 -lstdc++。主要有以下文件:

src/tendisplus/server/CMakeFiles/tendisplus.dir/link.txt

src/tendisplus/replication/CMakeFiles/binlog_tool.dir/link.txt

src/tendisplus/cluster/CMakeFiles/cluster_test.dir/link.txt

2 编译redis-cli

1 获取redis稳定版并解压

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable

2 编译

make

3 报错处理

如果报错:jemalloc/jemalloc.h:没有那个文件或目录,可以尝试如下编译:

make MALLOC=libc

报错原因:
关于分配器allocator, 如果有MALLOC这个环境变量,会有用这个环境变量去建立Redis。
libc并不是默认的分配器, 默认的是 jemalloc, 因为 jemalloc 被证明比libc有更少的 fragmentation problems。
但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数。

3 提取程序

1 提取tendis

mkdir -p /opt/tendis-v2.4.2-rocksdb-v5.13.4/bin/deps
cp /opt/Tendis/build/bin/binlog_tool /opt/Tendis/build/bin/tendisplus  /opt/tendis-v2.4.2-rocksdb-v5.13.4/bin/
cp /usr/lib64/libstdc++.so.6.0.25 /usr/lib64/libnuma.so.1.0.0 /usr/lib64/libnuma.so.1 /usr/lib64/libtbb.so.2 /opt/Tendis/tendis-v2.4.2-rocksdb-v5.13.4/bin/deps/
cd /opt/Tendis/tendis-v2.4.2-rocksdb-v5.13.4/bin/deps/
ln -s libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6
ls -s libstdc++.so.6.0.25 /usr/lib64/libstdc++.so

2 提取redis-cli

cp /opt/redis-stable/src/redis-cli /opt/Tendis/build/bin/

3 导出程序文件夹

使用docker cp命令拷出/opt/tendis-v2.4.2-rocksdb-v5.13.4

4 编译docker镜像

1.从官方镜像提取脚本文件,

从tencentdbforkv/tendisplus:v2.4.0镜像中提取/data1/tendis/scripts文件夹,放在tendis-v2.4.2-rocksdb-v5.13.4目录

2.还原官方Dockerfile文件,并按需修改

FROM centos:8.3.2011

RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo && \
yum clean all && yum makecache && yum repolist && yum install -y net-tools

ENV CLUSTER=no REDIS_PASSWORD=test

WORKDIR /data1/

COPY tendis-v2.4.2-rocksdb-v5.13.4.tar.gz /data1/

RUN tar -vxf tendis-v2.4.2-rocksdb-v5.13.4.tar.gz && ln -fs tendis-v2.4.2-rocksdb-v5.13.4 tendis && rm -rf tendis-v2.4.2-rocksdb-v5.13.4.tar.gz && ln -s /data1/tendis/bin/redis-cli /usr/bin/redis-cli


EXPOSE 51002

CMD ["/bin/sh", "-c", "cd /data1/tendis/scripts && sh start.sh && tail -f /data1/tendis/51002/tendisplus.conf"]

3.编译docker镜像。


也可以直接拉这个arm版本镜像,用法和官方一致。
docker pull xrds1949/tendisplus:2.4.2

@raffertyyu raffertyyu removed beginner level Simple question or need support fixed fixed already labels Jul 8, 2022
@takenliu
Copy link
Collaborator

takenliu commented Jun 12, 2024

参考这个issue:
#270 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compile Software compilation problem
Projects
None yet
Development

No branches or pull requests

8 participants