Fail to compile vqsort with clang 16 on Darwin M1
Hi maintainers, Thank you for making this great library. When compiling this project on MacOS M1 with clang 16, I got this error "Calling convention SVE_VectorCall is unsupported on Darwin" The full error message is:
**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:
It seems the compilation of vqsort failed. When compiling with Clang 14, the same code compiles successfully.
Hi, thanks for your kind words :)
Unfortunately there are currently various compiler bugs relating to SVE. I'd recommend building with -DHWY_DISABLED_TARGETS=HWY_ALL_SVE. Hope this helps?
In our case, vcpkg is used to compile highway as a dependency. It is non trivial to pass -DHWY_DISABLED_TARGETS=HWY_ALL_SVE to vcpkg.
So, we end up using Clang 15/14.
I understand, thanks for the follow up. FYI discussions are underway on addressing the compiler bug.
I understand, thanks for the follow up. FYI discussions are underway on addressing the compiler bug.
I have updated hwy/detect_targets.h to mark the SVE targets as broken on macOS as none of the current Apple A64 CPU's (at least up to and including A4 and M18) support SVE or SVE2 in pull request #2367.
The changes to hwy/detect_targets.h in pull request #2367 should fix compilation errors on macOS on A64.