1yefuwang1 / vectorlite

Fast, SQL powered, in-process vector search for any language with an SQLite driver
https://1yefuwang1.github.io/vectorlite/
Apache License 2.0
269 stars 5 forks source link

Apple-Silion Macs don't support SVE instructions for Highway. #32

Open xiaobao520123 opened 1 month ago

xiaobao520123 commented 1 month ago

I'm using 2021 M1 Max MacBook Pro to compile vectorlite. One of its dependenies, highway, is using SVE which Apple-Silicon Macs don't support.

**Version of C++:**
/Library/Developer/CommandLineTools/usr/bin/c++ -v
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

**Error detail:**
[19/41] /Library/Developer/CommandLineTools/usr/bin/c++ -DHWY_STATIC_DEFINE -DTOOLCHAIN_MISS_ASM_HWCAP_H -DTOOLCHAIN_MISS_SYS_AUXV_H -I/Users/xiaobao/project/vectorlite/vcpkg/buildtrees/highway/src/1.2.0-9e5d3e7297.clean -fPIC -g -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\" -fmerge-all-constants -Wall -Wextra -Wconversion -Wsign-conversion -Wvla -Wnon-virtual-dtor -Wcast-align -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wfor-loop-analysis -Wgnu-redeclared-enum -Winfinite-recursion -Wself-assign -Wstring-conversion -Wtautological-overlap-compare -Wthread-safety-analysis -Wundefined-func-template -fno-cxx-exceptions -fno-slp-vectorize -fno-vectorize -fdiagnostics-show-option -fcolor-diagnostics -Wc++2a-extensions -fmath-errno -fno-exceptions -Wno-psabi -MD -MT CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o -MF CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o.d -o CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o -c /Users/xiaobao/project/vectorlite/vcpkg/buildtrees/highway/src/1.2.0-9e5d3e7297.clean/hwy/contrib/sort/vqsort_i32a.cc
FAILED: CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o 
/Library/Developer/CommandLineTools/usr/bin/c++ -DHWY_STATIC_DEFINE -DTOOLCHAIN_MISS_ASM_HWCAP_H -DTOOLCHAIN_MISS_SYS_AUXV_H -I/Users/xiaobao/project/vectorlite/vcpkg/buildtrees/highway/src/1.2.0-9e5d3e7297.clean -fPIC -g -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\" -fmerge-all-constants -Wall -Wextra -Wconversion -Wsign-conversion -Wvla -Wnon-virtual-dtor -Wcast-align -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wfor-loop-analysis -Wgnu-redeclared-enum -Winfinite-recursion -Wself-assign -Wstring-conversion -Wtautological-overlap-compare -Wthread-safety-analysis -Wundefined-func-template -fno-cxx-exceptions -fno-slp-vectorize -fno-vectorize -fdiagnostics-show-option -fcolor-diagnostics -Wc++2a-extensions -fmath-errno -fno-exceptions -Wno-psabi -MD -MT CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o -MF CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o.d -o CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o -c /Users/xiaobao/project/vectorlite/vcpkg/buildtrees/highway/src/1.2.0-9e5d3e7297.clean/hwy/contrib/sort/vqsort_i32a.cc
**fatal error: error in backend: Calling convention SVE_VectorCall is unsupported on Darwin.**
c++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
c++: note: diagnostic msg:
larsimmisch commented 1 month ago

I've run into the same problem. Following https://github.com/google/highway/issues/2356, I tried setting -DHWY_DISABLED_TARGETS=HWY_ALL_SVE in vectorlite/vcpkg/ports/highway/portfile.cmake, but that didn't work (seems that that flag would be passed to CMake, and does not affect preprocessor definitions)

Did you manage to get this to work?

xiaobao520123 commented 1 month ago

I've run into the same problem. Following google/highway#2356, I tried setting -DHWY_DISABLED_TARGETS=HWY_ALL_SVE in vectorlite/vcpkg/ports/highway/portfile.cmake, but that didn't work (seems that that flag would be passed to CMake, and does not affect preprocessor definitions)

Did you manage to get this to work?

yeah, I've contacted the author and he also suggested adding the flag to highway. But CMake would never pass this flag down into the library. So I installed LLVM 15 using Homebrew and switch the toolchain from Xcode to LLVM. And it works in my case to compile vectorlite on my M1 Max machine.

jan-wassenberg commented 4 weeks ago

Hi, Highway TL here. The recommended -DHWY_DISABLED_TARGETS=HWY_ALL_SVE is a compiler flag and can be passed there via CMake by export CXXFLAGS=-DHWY_DISABLED_TARGETS=HWY_ALL_SVE before running CMake.

FYI we are also in touch with Arm on fixing this compiler issue.