From fb21617c1f3ef49795597e006b68adfba6e54be0 Mon Sep 17 00:00:00 2001
From: George Steed <[EMAIL REDACTED]>
Date: Sat, 4 May 2024 13:20:42 +0100
Subject: [PATCH] cpu.cmake: Address issues in SVE feature tests
A test to check that SVE registers were correctly handled as function
parameters was added in 5ccdc66ab6eb8eb300eda854fab4ff250b2c2f92,
however this appears to have a couple of issues:
* Semicolons need to be escaped, else the compiler fails to compile due
to invalid syntax. We can fix this by prefixing each semicolon with a
backslash.
* The "other" function does not have a definition so the test program
will always fail to link even if it compiles to an object file. We can
work around this by instructing CMake to only try compiling up to a
static library rather than a full executable.
Change-Id: Ic37280d4b42b9031e68bed8a4b24c0eb51491827
---
build/cmake/cpu.cmake | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/build/cmake/cpu.cmake b/build/cmake/cpu.cmake
index e16e9ec6a..8d0acf3d2 100644
--- a/build/cmake/cpu.cmake
+++ b/build/cmake/cpu.cmake
@@ -49,7 +49,9 @@ if("${AOM_TARGET_CPU}" STREQUAL "arm64")
# SVE and SVE2 require that the Neon-SVE bridge header is also available.
if(ENABLE_SVE OR ENABLE_SVE2)
set(OLD_CMAKE_REQURED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AOM_SVE_FLAG}")
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
aom_check_source_compiles("arm_neon_sve_bridge_available" "
#ifndef __ARM_NEON_SVE_BRIDGE
#error 1
@@ -61,12 +63,13 @@ if("${AOM_TARGET_CPU}" STREQUAL "arm64")
# 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);
+void other(void)\;
svfloat32_t func(svfloat32_t a) {
- other();
- return a;
+ other()\;
+ return a\;
}" CAN_COMPILE_SVE)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS})
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${OLD_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(HAVE_SVE_HEADERS EQUAL 0 OR CAN_COMPILE_SVE EQUAL 0)
set(ENABLE_SVE 0)
set(ENABLE_SVE2 0)