apache / brpc

brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".
https://brpc.apache.org
Apache License 2.0
16.34k stars 3.96k forks source link

sizeof(Butex) == BAIDU_CACHELINE_SIZE static assertion failed #2699

Open sepcity opened 1 month ago

sepcity commented 1 month ago

Describe the bug (描述bug) when i build brpc-1.9.0 on openEuler-22.03SP3 aarch64 i got these errors

/usr/local/gcc-13.3.0/bin/g++ -c -I./src -I/hst/fsp_third_party/output/gflags/include/ -I/hst/fsp_third_party/output/leveldb/include/ -I/hst/fsp_third_party/output/openssl/include/ -I/hst/fsp_third_party/output/protobuf/include/ -I/hst/fsp_third_party/output/zlib/include/ -DGFLAGS_NS=google -fPIC src/bthread/butex.cpp -o src/bthread/butex.o In file included from ./src/butil/atomicops.h:34, from src/bthread/butex.cpp:22: src/bthread/butex.cpp:128:29: error: static assertion failed: butex_fits_in_one_cacheline 128 | BAIDU_CASSERT(sizeof(Butex) == BAIDU_CACHELINE_SIZE, butex_fits_in_one_cacheline); ./src/butil/macros.h:175:48: note: in definition of macro 'BAIDU_CASSERT' 175 | #define BAIDU_CASSERT(expr, msg) static_assert(expr, #msg) | ^~~~ src/bthread/butex.cpp:128:29: note: the comparison reduces to '(128 == 64)' 128 | BAIDU_CASSERT(sizeof(Butex) == BAIDU_CACHELINE_SIZE, butex_fits_in_one_cacheline); ./src/butil/macros.h:175:48: note: in definition of macro 'BAIDU_CASSERT' 175 | #define BAIDU_CASSERT(expr, msg) static_assert(expr, #msg) | ^~~~ make: *** [Makefile:305: src/bthread/butex.o] Error 1

To Reproduce (复现方法) ./config_brpc.sh make CXXFLAGS="-DGFLAGS_NS=google -fPIC"

Expected behavior (期望行为) build succeed

Versions (各种版本) OS:openEuler-22.03SP3 Compiler:gcc-13.3 brpc:1.9.0 protobuf:3.2.0

Additional context/screenshots (更多上下文/截图)

sepcity commented 1 month ago

it seems like sizeof(pthread_mutex_t) is 48 bytes on aarch64 but 40 bytes on x86_64

can i define BTHREAD_USE_FAST_PTHREAD_MUTEX to avoid this??