Summary of Pitfalls in Compiling TiFlash

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TiFlash 编译踩坑总结

| username: RinChanNOWWW

Here is a brief summary of the issues encountered while compiling TiFlash.

P.S. Differences may vary greatly depending on the platform and environment. This article is for reference only.

Development Environment:

  • OS: Ubuntu 18.04 LTS (Bionic Beaver)
  • Kernel: x86_64 Linux 4.15.0-112-generic

Issues and Solutions

  1. CMake version is too low

CMake version needs to be 3.21.0 or above.

  1. Compilation fails due to warnings being treated as errors because of the -Werror option.

Reason: Improper compiler version used.

Solution: Only use gcc 7.x and clang 13+. This is also mentioned in the README and should not be ignored.

  1. Compilation fails due to a method in the standard library being deprecated.

Reason and solution are the same as above.

  1. TiFlash startup fails due to an assert failure in vector, causing a core dump.

Reason: Mixing of libc++ and libstdc++. You can use the ldd command to check the dynamic library dependencies of the binary and lib files to see if there is any mixing. If the libstdc++ library exists in the environment, it will be included by default when compiling tiflash-proxy.

Solution: Update the code to the version of this PR fix(cmake): make sure libc++ is utilized by tiflash-proxy by SchrodingerZhu · Pull Request #5281 · pingcap/tiflash · GitHub. Explicitly specify the stdlib during compilation, i.e., modify the CXXFLAGS in contrib/tiflash-proxy-cmake/CMakeLists.txt: “CXXFLAGS=-fuse-ld=lld -w -stdlib=libc++”

  1. Compilation of raftstore-proxy fails with error: linking with xxxxx/tiflash/build/contrib/tiflash-proxy-cmake/tiflash-linker failed: exit status: 1 due to duplicate symbols causing the link to fail.

Reason: (Explanation received from an expert) If c++ libX statically links libA, libA will not be packaged into libX, but Rust will. Manually printing a crypto in build.rs in rocksdb caused rustc to search for the system’s direct bundle. Then, specifying the dependency on openssl-sys led to a conflict.

Solution:

| username: Tank001 | Original post link

Learning, :+1: