Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

wqfish
Copy link

@wqfish wqfish commented Sep 18, 2025

The code fails to build with RUSTFLAGS='-C target-cpu=x86-64-v3' on Linux. The error message indicates that -mpclmul is missing:

  cargo:warning=In file included from rocksdb/util/crc32c.cc:52:                                      
  cargo:warning=rocksdb/util/crc32c.cc: In function 'uint64_t rocksdb::crc32c::CombineCRC(size_t, uint64_t, uint64_t, uint64_t, const uint64_t*)':                                                           
  cargo:warning=rocksdb/util/crc32c.cc:553:21: error: '__builtin_ia32_pclmulqdq128' needs isa option -mpclmul -msse2                                                                                         
  cargo:warning=  553 |   const auto res0 = _mm_clmulepi64_si128(crc0_xmm, multiplier, 0x00);         
  cargo:warning=      |                     ^~~~~~~~~~~~~~~~~~~~                                      
  cargo:warning=rocksdb/util/crc32c.cc:555:21: error: '__builtin_ia32_pclmulqdq128' needs isa option -mpclmul -msse2                                                                                         
  cargo:warning=  555 |   const auto res1 = _mm_clmulepi64_si128(crc1_xmm, multiplier, 0x10);         
  cargo:warning=      |                     ^~~~~~~~~~~~~~~~~~~~

It looks like RocksDB defines __PCLMUL__ as long as __AVX__ is detected:

https://github.com/facebook/rocksdb/blob/631fb8670b077aa80c3953ceb3ed5c82649db515/port/lang.h#L78-L83

So we have to do the same: add -mpclmul if avx is detected.

The code fails to build with `RUSTFLAGS='-C target-cpu=x86-64-v3'`. The error
message indicates that `-mpclmul` is missing.

It looks like RocksDB defines `__PCLMUL__` as long as `__AVX__` is detected:

https://github.com/facebook/rocksdb/blob/631fb8670b077aa80c3953ceb3ed5c82649db515/port/lang.h#L78-L83

So we have to do the same: add `-mpclmul` if `avx` is detected.
config.flag_if_supported("-mlzcnt");
}
if !target.contains("android") && target_features.contains(&"pclmulqdq") {
if !target.contains("android")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be:

Suggested change
if !target.contains("android")
if target.contains("windows")

?
As I can see it's related to MSVC?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, I'm not familiar with android and why it's here in the first place, so I didn't touch it.

Second, while the comments in port/lang.h mentions MSVC, that section of code is not guarded by any #if/#ifdef, so it applies to everything. I actually ran into this failure when building on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants