cpu.cmake: Do more elaborate test of whether SVE can be compiled
For Windows targets, Clang will successfully compile simpler
SVE functions, but if the function requires backing up and restoring
SVE registers (as part of the AAPCS calling convention), Clang
will fail to generate unwind data for this function, resulting
in an error.
This issue is tracked upstream in Clang in
https://github.com/llvm/llvm-project/issues/80009.
Check whether the compiler can compile such a function, and
disable SVE if it is unable to handle that case.
Change-Id: I307d7398cedd1942c39ef034431a51696264ff47
diff --git a/build/cmake/cpu.cmake b/build/cmake/cpu.cmake
index 489dbcb..e16e9ec 100644
--- a/build/cmake/cpu.cmake
+++ b/build/cmake/cpu.cmake
@@ -56,8 +56,18 @@
#endif
#include <arm_sve.h>
#include <arm_neon_sve_bridge.h>" HAVE_SVE_HEADERS)
+ # Check whether the compiler can compile SVE functions that require
+ # backup/restore of SVE registers according to AAPCS. Clang for Windows used
+ # to fail this, see https://github.com/llvm/llvm-project/issues/80009.
+ aom_check_source_compiles("arm_sve_preserve" "
+#include <arm_sve.h>
+void other(void);
+svfloat32_t func(svfloat32_t a) {
+ other();
+ return a;
+}" CAN_COMPILE_SVE)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS})
- if(HAVE_SVE_HEADERS EQUAL 0)
+ if(HAVE_SVE_HEADERS EQUAL 0 OR CAN_COMPILE_SVE EQUAL 0)
set(ENABLE_SVE 0)
set(ENABLE_SVE2 0)
endif()