Failed to Compile TiKV Offline

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

Original topic: 离线编译 tikv 失败

| username: TiDBer_jYQINSnf

I couldn’t access the external network, so I used cargo vendor to download a vendor. During this process, I resolved the version conflicts between crossbeam and encoding_rs.

Now, when compiling with Dockerfile, I encountered an error.

Modifications to Dockerfile:

Added the following at line 79:

ADD vendor vendor

Then, I placed the dependencies generated by cargo vendor into etc/cargo.config.dist.

Started compiling:

docker build .

Error:

    For compatibility with older versions of CMake, try_compile is not honoring
    caller config-specific compiler flags (e.g.  CMAKE_C_FLAGS_DEBUG) in the
    test project.
  Call Stack (most recent call first):
    /usr/share/cmake3/Modules/CMakeTestCXXCompiler.cmake:67 (CMAKE_DETERMINE_COMPILER_ABI)
    CMakeLists.txt:2 (project)
  This warning is for project developers.  Use -Wno-dev to suppress it.

     Called from: [3]   /usr/share/cmake3/Modules/CMakeDetermineCompilerABI.cmake
                  [2]   /usr/share/cmake3/Modules/CMakeTestCXXCompiler.cmake
                  [1]   /tikv/vendor/libtitan_sys/titan/CMakeLists.txt
  CMake Warning (dev) at /usr/share/cmake3/Modules/CMakeDetermineCompilerABI.cmake:48 (try_compile):
    Policy CMP0056 is not set: Honor link flags in try_compile() source-file
    signature.  Run "cmake --help-policy CMP0056" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.

    For compatibility with older versions of CMake, try_compile is not honoring
    caller link flags (e.g.  CMAKE_EXE_LINKER_FLAGS) in the test project.
  Call Stack (most recent call first):
    /usr/share/cmake3/Modules/CMakeTestCXXCompiler.cmake:67 (CMAKE_DETERMINE_COMPILER_ABI)
    CMakeLists.txt:2 (project)
  This warning is for project developers.  Use -Wno-dev to suppress it.

     Called from: [3]   /usr/share/cmake3/Modules/CMakeDetermineCompilerABI.cmake
                  [2]   /usr/share/cmake3/Modules/CMakeTestCXXCompiler.cmake
                  [1]   /tikv/vendor/libtitan_sys/titan/CMakeLists.txt
  CMake Error at cmake/rocksdb_flags.cmake:14 (find_package):
    By not providing "Findsnappy.cmake" in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by "snappy", but
    CMake did not find one.

    Could not find a package configuration file provided by "snappy" with any
    of the following names:

      snappyConfig.cmake
      snappy-config.cmake

    Add the installation prefix of "snappy" to CMAKE_PREFIX_PATH or set
    "snappy_DIR" to a directory containing one of the above files.  If "snappy"
    provides a separate development package or SDK, be sure it has been
    installed.
  Call Stack (most recent call first):
    CMakeLists.txt:31 (include)


     Called from: [2]   /tikv/vendor/libtitan_sys/titan/cmake/rocksdb_flags.cmake
                  [1]   /tikv/vendor/libtitan_sys/titan/CMakeLists.txt
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /tikv/vendor/cmake/src/lib.rs:894:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Then I tried adding the following at line 79:

yum install -y snappy snappy-devel

Recompiled, but still encountered the same error.

Could any expert help me take a look? Thank you!

| username: ffeenn | Original post link

It feels like a cmake version issue. Why do you need to compile the image yourself? Why bother? :rofl:

| username: TiDBer_jYQINSnf | Original post link

I used the Dockerfile from the repository for the compilation. If this Dockerfile doesn’t compile successfully, then the Dockerfile in the repository needs to be modified. Compiling it yourself allows for debugging and better learning. :stuck_out_tongue:

| username: ffeenn | Original post link

I saw this article mentioning a missing path. Try configuring it.
(1 message) By not providing “Findcatkin.cmake“ in CMAKE_MODULE_PATH this project has asked CMake to find a pa_anson0537’s blog - CSDN blog

| username: TiDBer_jYQINSnf | Original post link

Successfully compiled offline in the end.
Encountered several issues during the process:

  1. The code downloaded by cargo vendor was placed in the vendor directory of tikv, but there is a .gitignore file under tikv that ignores core* files, causing the core* content in the vendor directory to fail to be pushed to git, resulting in download failures on the other side.
  2. Using Cargo vendor to download all dependencies, but there were conflicts with two repository versions:
    The reason is that crates.io hosts an official version, but tikv made some bug fixes without changing the version number.
    Solution: Clone tikv’s modifications to a private repository, then change the version number to one that does not exist in crates.io.
  3. The titan sub-repository in rust_rocksdb always failed to compile, reporting that snappy could not be found, but it could compile without using vendor. Ultimately, I chose to comment out rust_rocksdb’s vendor in etc/cargo.config.dist and download the code directly from the repository during compilation.

3 is a compromise solution, meaning that code still needs to be downloaded online, but only one code repository needs to be downloaded, which is relatively easier to handle. I did not continue to find a final solution.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.