TiKV Compilation Failure

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

Original topic: TiKV 编译失败

| username: TiDBer_0kgaJpXh

[TiDB Usage Environment] Testing
[TiDB Version] tikv: origin/release-8.2
[Reproduction Steps]

  1. git clone xx
  2. git checkout -b release-8.2 origin/release-8.2
  3. cargo check --workspace

error: failed to run custom build command for librocksdb_sys v0.1.0 (https://github.com/tikv/rust-rocksdb.git#224bed6f)

/home/andy/.cargo/git/checkouts/rust-rocksdb-a9a28e74c6ead8ef/224bed6/librocksdb_sys/rocksdb/encryption/encryption.cc:90:39: error: use of undeclared identifier ‘block_index’; did you mean ‘block_size’?
90 | uint64_t iv_low = initial_iv_low_ + block_index;
| ^~~~~~~~~~~
| block_size
/home/andy/.cargo/git/checkouts/rust-rocksdb-a9a28e74c6ead8ef/224bed6/librocksdb_sys/rocksdb/encryption/encryption.cc:81:16: note: ‘block_size’ declared here
81 | const size_t block_size = BlockSize();
| ^
/home/andy/.cargo/git/checkouts/rust-rocksdb-a9a28e74c6ead8ef/224bed6/librocksdb_sys/rocksdb/encryption/encryption.cc:91:46: error: use of undeclared identifier ‘block_index’; did you mean ‘block_size’?
91 | if (std::numeric_limits<uint64_t>::max() - block_index < initial_iv_low_) {
| ^~~~~~~~~~~
| block_size
/home/andy/.cargo/git/checkouts/rust-rocksdb-a9a28e74c6ead8ef/224bed6/librocksdb_sys/rocksdb/encryption/encryption.cc:81:16: note: ‘block_size’ declared here
81 | const size_t block_size = BlockSize();

There are also some other errors, such as no matching function for call to ‘bit_cast’ 294 | return bit_cast<int64_t>(ToHost64(bit_cast<uint64_t>(x))); |

My compilation environment:

clang --version
clang version 18.1.6 (https://gitee.com/mirrors/llvm-project.git 1118c2e05e67a36ed8ca250524525cdb66a55256)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

clang++ --version
clang version 18.1.6 (https://gitee.com/mirrors/llvm-project.git 1118c2e05e67a36ed8ca250524525cdb66a55256)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin