-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to build highway with Apple's clang 16 #2317
Comments
I have filed the clang bug with Apple as FB14947714. A standalone reproducer is:
with the |
Thanks for filing the clang bug :) If you are not using VQSort, how about defining VQSORT_ENABLED to 0 as a workaround? (This requires a small patch which I'll send shortly.) |
PiperOrigin-RevId: 670233915
@jan-wassenberg I'm a Homebrew maintainer, so I can't really presume what our users use or do not use. I'm not sure what triggers the crash, haven't been able to reduce it so far. |
Got it, thanks. I was able to repro on Godbolt. This looks like a catastrophic compiler bug, it seems unable to mangle its own definition of vaddq_u64:
It is caused by the |
The Godbolt error is a little misleading as it is using a Linux sysroot rather than the macOS SDK, but it does showcase it crashes nonetheless. The stack trace seen in the crash logs on actual macOS aligns with what was posted in llvm/llvm-project#97198 (comment) rather than being about mangling. It's crashing in the arm64 SVE code. The reason it wasn't an issue before is because the SVE parts were never compiled before because the Apple Clang didn't have dynamic dispatch enabled (previously LLVM 15 based): Lines 621 to 623 in cce7182
So previously it would only ever compile NEON:
Apple Clang 16 now aligns with LLVM 17 so this code path is now enabled and thus SVE is now compiled. This now triggers the crashing code. However, no Apple arm64 CPU supports SVE as far as I'm aware of and Clang seems to have always crashed when compiling arm64 SVE on macOS - see llvm/llvm-project#49751 where upstream states ARM SVE is not supported on macOS yet. Upstream also asked why SVE was being used here: llvm/llvm-project#97198 (comment). I'd still call it a compiler bug - it shouldn't ever be crashing like that - but we can work around it. The below seems to fix the crash issue for me: diff --git a/hwy/detect_targets.h b/hwy/detect_targets.h
index a8d4a13f..e0ffb33a 100644
--- a/hwy/detect_targets.h
+++ b/hwy/detect_targets.h
@@ -223,8 +223,12 @@
#endif
// SVE[2] require recent clang or gcc versions.
+//
+// SVE is not supported on Apple arm64 CPUs and also crashes the compiler:
+// https://github.com/llvm/llvm-project/issues/97198
#if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 1100) || \
- (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000)
+ (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \
+ (HWY_OS_APPLE && HWY_ARCH_ARM_A64)
#define HWY_BROKEN_SVE (HWY_SVE | HWY_SVE2 | HWY_SVE_256 | HWY_SVE2_128)
#else
#define HWY_BROKEN_SVE 0 I can send a PR if something like that is OK. If ARM SVE is ever supported in the future a condition can be added with the minimum supported Clang version. |
Thanks, I'm back and agree with your analysis. Indeed M4 still doesn't have SVE, I thought it was mandatory in armv9 but they seem to have gone back on that. We'd welcome such a pull request, and while at it we can change to |
With the latest git version of highway, on macOS 15 Beta, with Apple's system compiler (clang 16 beta), I configure with:
then build with
and get the following crash:
The text was updated successfully, but these errors were encountered: