编译 Apache Doris

假设你有一定计算机基础

如果你是 WSL

[wsl2]
memory=20GB  # 设置最大内存
swap=10GB    # 推荐swap为内存的50%

开始准备工作

ban@DESKTOP-ES3ISPK ~/p/doris (master) [1]> uname -a
Linux DESKTOP-ES3ISPK 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
ban@DESKTOP-ES3ISPK ~/p/doris (master)> lsb_release 
No LSB modules are available.
git clone --depth 1 https://github.com/apache/doris.git  

cd doris/

截止写文章时,得知流水线为 clang 16,尽可能本地与流水线保持一致

wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.24/ldb_toolchain_gen.sh -O ldb_toolchain_gen.sh   
sudo apt-get install build-essential libgmp-dev libmpfr-dev libmpc-dev
bash -x ldb_toolchain_gen.sh "$(pwd)/ldb_toolchain/"            

check

ban@DESKTOP-ES3ISPK ~/p/doris (master)> gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ban@DESKTOP-ES3ISPK ~/p/doris (master)> export PATH="/home/ban/project/doris/ldb_toolchain/bin:$PATH"                                                                                                 
ban@DESKTOP-ES3ISPK ~/p/doris (master)> gcc --version                                                                                                                                                 
gcc (Gentoo 14.2.1_p20241221 p7) 14.2.1 20241221
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

使其永久生效

echo 'export PATH="/home/ban/project/doris/ldb_toolchain/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
curl -fsSL "https://get.sdkman.io?rcupdate=false" | bash       
source ~/.sdkman/bin/sdkman-init.sh

check

sdk
echo "source \"$HOME/.sdkman/bin/sdkman-init.sh\"" >> ~/.bashrc  # 或 ~/.zshrc
exec $SHELL  # 重新加载shell

if fish

echo 'function sdk; bash -c "source ~/.sdkman/bin/sdkman-init.sh && sdk $argv"; end' >> ~/.config/fish/config.fish   
sdk install java 17.0.15-tem
mkdir ~/bin
wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz -P /tmp

tar -xzf /tmp/apache-maven-3.9.9-bin.tar.gz -C ~/bin/
export MAVEN_HOME=~/bin/apache-maven-3.9.9
export PATH=$MAVEN_HOME/bin:$PATH

# 可以写入环境变量
curl -L https://doris-thirdparty-repo.bj.bcebos.com/thirdparty/node-v12.13.0-linux-x64.tar.gz \
  | tar xz --strip-components=1 -C ~/bin/node
echo 'export PATH="$HOME/bin/node/bin:$PATH"' >> ~/.bashrc  
source ~/.bashrc

check

node -v  
sudo apt update && sudo apt install -y \
    byacc \
    patch \
    automake \
    libtool \
    make \
    which \
    file \
    libncurses-dev \
    gettext \
    unzip \
    bzip2 \
    zip \
    util-linux \
    wget \
    git \
    autoconf \
    bison \
    flex \
    g++ \
    pkg-config \
    gettext \
    autopoint \
    libprotobuf-dev \
    protobuf-compiler \
	libabsl-dev \
	libcurl4-openssl-dev \
	ninja-build

填充后放入 Doris 源码目录的 custom_env.sh (新建)

export JAVA_HOME=/home/ban/.sdkman/candidates/java/current
export PATH=$JAVA_HOME/bin:$PATH

# Maven
export MAVEN_HOME=/home/ban/bin/apache-maven-3.9.9
export PATH=$MAVEN_HOME/bin:$PATH

# Node.js
export NODE_HOME=/home/ban/bin/node
export PATH=$NODE_HOME/bin:$PATH

# LDB Toolchain
export LDB_TOOLCHAIN=/home/ban/project/doris/ldb_toolchain
export PATH=$LDB_TOOLCHAIN/bin:$PATH
curl -LsSf https://astral.sh/uv/install.sh | sh

exec $SHELL
# source $HOME/.local/bin/env.fish 

uv venv

source .venv/bin/activate
# source .venv/bin/activate.fish
# bash -x build.sh

bash -x build.sh -j 8  

最终还是选择下载预编译的三方库,自己编译可能遇到的问题太多了

wget https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-linux-x86_64.tar.xz -O doris-thirdparty-prebuilt-linux-x86_64.tar.xz

下载好后,解压会得到一个 installed/ 目录,将这个目录拷贝到 thirdparty/ 目录下,之后运行 build.sh 即可。

tar -xvf doris-thirdparty-prebuilt-linux-x86_64.tar.xz

mkdir -p ~/project/doris/thirdparty

cp -r installed ~/project/doris/thirdparty/

ls -lh ~/project/doris/thirdparty/installed/

Related Issues not found

Please contact @n-WN to initialize the comment