Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling the Source Code

  1. Go to the installation directory. Change it with the actual one.
    1
    /homecd 
    
  2. Download the source code.
    1
    2
    3
    4
    git clone --recursive --shallow-submodules https://github.com/ClickHouse/ClickHouse.git -b v24.3.11.7-lts --single-branch --depth=1
    cd ClickHouse
    git submodule sync
    git submodule update --init --recursive
    
    This step takes a longer time because a large number of files need to be synchronized. After the source code is pulled and sub-modules are updated, start compilation. The following is a check script. Create it in the /home/ClickHouse directory to perform a check. Ensure that each file directory contains files and is not empty.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    #!/bin/bash
    base_dir=$(cd $(dirname "$0")&&pwd)
    for dir in $(ls -d "$base_dir" /contrib/*/); 
    do
       file_count=$(ls -1 "$dir" | wc -l)
       if [ "$file_count" -eq 0 ]; then
           echo "Directory with 0 files: $dir"
       fi
    done
    
  3. Modify compilation options.
    1. Go to the /home/ClickHouse/cmake directory and open the cpu_features.cmake file.
      1
      2
      cd /home/ClickHouse/cmake
      vi cpu_features.cmake
      
    2. Press i to enter the insert mode and modify the NO_ARMV81_OR_HIGHER compilation option (line 26 in the current version) as follows:
      1
      set (COMPILER_FLAGS "${COMPILER_FLAGS} -march=armv8.2-a+simd+crypto+dotprod")
      

      SIMD instructions are added to NO_ARMV81_OR_HIGHER, and -DENABLE_THINLTO=ON is also added to compilation options. This can improve the performance.

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Build and compile ClickHouse.
    1
    2
    3
    cd /home/ClickHouse/
    mkdir build
    cmake -DPARALLEL_COMPILE_JOBS=32 -DENABLE_CLICKHOUSE_SELF_EXTRACTING=1 -DNO_ARMV81_OR_HIGHER=1 -DENABLE_BUILD_PROFILING=ON -DPARALLEL_LINK_JOBS=32 -DENABLE_THINLTO=ON -DENABLE_TESTS=OFF -DENABLE_RUST=OFF -S . -B build
    

    If the following information is displayed, the build is successful:

    After the build is complete, the structure of the build directory is as follows:

    1
    cmake --build build -j 32
    
  5. Install ClickHouse.

    After the compilation is complete, the following binary files are generated in the build/programs directory. For details about how to deploy the binary ClickHouse, see ClickHouse Deployment Guide (openEuler).