odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.53k stars 157 forks source link

Benchmarks do not compile on Apple Silicon (MacOs on Arm) #474

Closed WANG-lp closed 3 months ago

WANG-lp commented 3 months ago

Hi there, I tried to compile Quill on my MacBook (M3Max) but the following compile error occurred:

$ mkdir build && cd build
$ cmake -DQUILL_BUILD_BENCHMARKS=ON ..
$ make -j
[  0%] Built target quill
[  8%] Building CXX object benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_rdtsc_clock.dir/quill_hot_path_rdtsc_clock.cpp.o
[ 41%] Building CXX object benchmarks/compile_time/qwrapper/CMakeFiles/qwrapper_compile_time_bench.dir/include/qwrapper/qwrapper.cpp.o
[ 41%] Building CXX object benchmarks/backend_throughput/CMakeFiles/BENCHMARK_quill_backend_throughput.dir/quill_backend_throughput.cpp.o
[ 41%] Building CXX object benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_system_clock.dir/quill_hot_path_system_clock.cpp.o
[ 41%] Building CXX object benchmarks/backend_throughput/CMakeFiles/BENCHMARK_quill_backend_throughput_no_buffering.dir/quill_backend_throughput_no_buffering.cpp.o
In file included from In file included from /Users/will/Workspace/quill/benchmarks/hot_path_latency/quill_hot_path_rdtsc_clock.cpp/Users/will/Workspace/quill/benchmarks/hot_path_latency/quill_hot_path_system_clock.cpp::66:
:
In file included from In file included from /Users/will/Workspace/quill/benchmarks/hot_path_latency/hot_path_bench.h/Users/will/Workspace/quill/benchmarks/hot_path_latency/hot_path_bench.h::2626:
:
In file included from In file included from /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h::1313:
:
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/ia32intrin.h:200:/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/ia32intrin.h:200:1010::  fatal error: fatal error: use of undeclared identifier '__builtin_ia32_readeflags_u32'
use of undeclared identifier '__builtin_ia32_readeflags_u32'
  return __builtin_ia32_readeflags_u32();  return __builtin_ia32_readeflags_u32();

         ^         ^

11 error error generated generated.
.
make[2]: make[2]: *** [benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_system_clock.dir/quill_hot_path_system_clock.cpp.o] Error 1*** [benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_rdtsc_clock.dir/quill_hot_path_rdtsc_clock.cpp.o] Error 1

make[1]: *** [benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_rdtsc_clock.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [benchmarks/hot_path_latency/CMakeFiles/BENCHMARK_quill_hot_path_system_clock.dir/all] Error 2
[ 50%] Linking CXX static library libqwrapper_compile_time_bench.a
[ 58%] Linking CXX executable BENCHMARK_quill_backend_throughput
[ 66%] Linking CXX executable BENCHMARK_quill_backend_throughput_no_buffering
[ 66%] Built target qwrapper_compile_time_bench
[ 66%] Built target BENCHMARK_quill_backend_throughput
[ 66%] Built target BENCHMARK_quill_backend_throughput_no_buffering
make: *** [all] Error 2

Does the undeclared identifier (__builtin_ia32_readeflags_u32) only exist on the X86 platform?

Any idea? Thank you in advance.

odygrd commented 3 months ago

Hello, i do not have an apple silicon laptop to reproduce. The github actions are using macos-14 and according to github are apple silicon and it is compiling there.

Image: macos-14-arm64

https://github.com/odygrd/quill/actions/runs/9526838179/job/26262743386

Is it only related to the benchmarks? can you please check if the examples are building ?

I expect benchmarks to be x86 only but the examples and everything else should work fine on arm

WANG-lp commented 3 months ago

quill examples compile smoothly.

Do you have any suggestions for modifying the benchmark to run on the ARM platform?

odygrd commented 3 months ago

my guess is that it is related to __rdtscp eg : https://github.com/odygrd/quill/blob/master/benchmarks/hot_path_latency/hot_path_bench.h#L79

if you try to replace all calls to __rdtscp to chrono::system_clock:now() or something equivalent and remove the <x86intrin.h> include they will probably compile

WANG-lp commented 3 months ago

yeah, it works after removing the <x86intrin.h> and replacing the rdtscp call, cheers!