Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
42cb003f by Martin Storsjö at 2024-05-09T08:44:13+00:00
contrib: aom: Backport patches to improve the SVE detection

This backports
https://aomedia.googlesource.com/aom/+/5ccdc66ab6eb8eb300eda854fab4ff250b2c2f92
and
https://aomedia.googlesource.com/aom/+/fb21617c1f3ef49795597e006b68adfba6e54be0.

This makes libaom test compiling a more nontrivial function,
which according to AAPCS requires backing up and restoring SVE
registers.

On current versions of Clang when targeting Windows, compiling such
a function errors out. This added test makes libaom not try to
compile the SVE codepaths for this target.

See https://github.com/llvm/llvm-project/issues/80009 for reference
on toolchain support for SVE functions on Windows on aarch64.

- - - - -


3 changed files:

- + 
contrib/src/aom/0001-cpu.cmake-Do-more-elaborate-test-of-whether-SVE-can-.patch
- + contrib/src/aom/0002-cpu.cmake-Address-issues-in-SVE-feature-tests.patch
- contrib/src/aom/rules.mak


Changes:

=====================================
contrib/src/aom/0001-cpu.cmake-Do-more-elaborate-test-of-whether-SVE-can-.patch
=====================================
@@ -0,0 +1,51 @@
+From 17cb0f6be6807c73027cce0d941868b3e5ede54f Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <mar...@martin.st>
+Date: Wed, 1 May 2024 00:45:41 +0300
+Subject: [PATCH 1/2] 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
+(cherry picked from commit 5ccdc66ab6eb8eb300eda854fab4ff250b2c2f92)
+---
+ build/cmake/cpu.cmake | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/build/cmake/cpu.cmake b/build/cmake/cpu.cmake
+index 489dbcbf44..e16e9ec6a5 100644
+--- a/build/cmake/cpu.cmake
++++ b/build/cmake/cpu.cmake
+@@ -56,8 +56,18 @@ if("${AOM_TARGET_CPU}" STREQUAL "arm64")
+ #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()
+-- 
+2.34.1
+


=====================================
contrib/src/aom/0002-cpu.cmake-Address-issues-in-SVE-feature-tests.patch
=====================================
@@ -0,0 +1,58 @@
+From b349f7613350aa8a15c06470dc63c5d6a4a1222f Mon Sep 17 00:00:00 2001
+From: George Steed <george.st...@arm.com>
+Date: Sat, 4 May 2024 13:20:42 +0100
+Subject: [PATCH 2/2] 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
+(cherry picked from commit fb21617c1f3ef49795597e006b68adfba6e54be0)
+---
+ 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 e16e9ec6a5..8d0acf3d2b 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)
+-- 
+2.34.1
+


=====================================
contrib/src/aom/rules.mak
=====================================
@@ -15,6 +15,8 @@ $(TARBALLS)/libaom-$(AOM_VERSION).tar.gz:
 aom: libaom-$(AOM_VERSION).tar.gz .sum-aom
        $(UNPACK)
        $(APPLY) $(SRC)/aom/0002-cmake-win-fix-asm-flag-appending.patch
+       $(APPLY) 
$(SRC)/aom/0001-cpu.cmake-Do-more-elaborate-test-of-whether-SVE-can-.patch
+       $(APPLY) 
$(SRC)/aom/0002-cpu.cmake-Address-issues-in-SVE-feature-tests.patch
        $(MOVE)
 
 DEPS_aom =



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/42cb003f059998cf03e70d7cbaa13b8ebf9b05fd

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/42cb003f059998cf03e70d7cbaa13b8ebf9b05fd
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to