编译环境: ubuntu系统aarch64
Clickhouse版本: ClickHouse-21.9.5.16-stable
1 安装Clang-8
1.1 echo “deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main” | sudo tee /etc/apt/sources.list.d/llvm.list
1.2 apt-get update
1.3 apt-get install clang-8
2 安装 Git 和 CMake 和 Ninja
apt-get install git cmake ninja-build
3 下载github代码
地址:https://github.com/ClickHouse/ClickHouse/releases/
下载两个包:
wget https://github.com/ClickHouse/ClickHouse/releases/download/v21.9.5.16-stable/ClickHouse_sources_with_submodules.tar.gz
wget https://github.com/ClickHouse/ClickHouse/archive/refs/tags/v21.9.5.16-stable.tar.gz
4 解压
解压源码
tar -zxvf ClickHouse-21.9.5.16-stable.tar.gz
修改名字
mv ClickHouse-21.9.5.16-stable ClickHouse
解压子模块
tar -zxvf ClickHouse_sources_with_submodules.tar.gz
5 开始编译
5.1进入目录:cd ClickHouse/
5.2 下载交叉编译工具
wget ‘https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz?revision=2e88a73f-d233-4f96-b1f4-d8b36e9bb0b9&la=en’ -O gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz
5.3执行下面一系列脚本命令
mkdir build-arm66
cp gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz cmake/linux/…/toolchain/linux-aarch64/
cd cmake/linux/…/toolchain/linux-aarch64/
tar xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz --strip-components=1
5.4 进入目录:cd ClickHouse/
5.5 最后两步
编译
CC=clang-10 CXX=clang+±10 cmake . -Bbuild-arm66 -DENABLE_S2_GEOMETRY=0 -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake
编译完成如下图:
构建
ninja clickhouse -C build-arm66
最后编译完成