Compiling the Source Code
- Go to the installation directory using the following command. You can replace /home with your actual installation path.
1cd /home
- 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 process is time-consuming because a large number of files need to be synchronized.
- After the source code is downloaded and the submodules are updated, perform the following steps to check the integrity of the source code.
- Create a check script in the /home/ClickHouse directory.
1vi file_check.sh - Press i to enter the insert mode and add the following content to the file. Check that each file directory contains files and is not empty.
#!/bin/bash base_dir=$(cd $(dirname "$0")&&pwd) flag=0 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" flag=1 fi done if [ $flag -eq 0 ]; then echo "Check completed. No empty folder found in the contrib directory." fi - Press Esc, type :wq!, and press Enter to save the file and exit.
- Run the script.
1 2
chmod +x file_check.sh ./file_check.sh
Upon successful validation, the message "Check complete. No empty folder found in the contrib directory." is displayed.
- Create a check script in the /home/ClickHouse directory.
- Modify compilation options.
- Go to the /home/ClickHouse/cmake directory and open the cpu_features.cmake file.
1 2
cd /home/ClickHouse/cmake vi cpu_features.cmake
- Press i to enter the insert mode and modify the NO_ARMV81_OR_HIGHER compilation option (line 26 in the current version) as follows:
1set (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 added to the compilation options. This can improve the performance.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Go to the /home/ClickHouse/cmake directory and open the cpu_features.cmake file.
- Build and compile ClickHouse.
1 2 3
cd /home/ClickHouse/ mkdir build cmake -DPARALLEL_COMPILE_JOBS=`nproc` -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 (run the ls ./build command to view it).

1cmake --build build -j `nproc`
After the compilation is complete, the following files are generated in the build/programs directory (run the ll ./build/programs command to view the files).

- Install ClickHouse. When the message "Enter password for the default user" is displayed, press Enter.
./build/programs/clickhouse install

Parent topic: Porting Guide (openEuler)