From fab11704cda62ff2d6b5e308b741e759ae816035 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Tue, 8 Sep 2026 19:22:51 -0700 Subject: [PATCH] [libyuv] Use Armv8.5-A architecture flags for SME and SVE2 build targets Update BUILD.gn, CMakeLists.txt, and BUILD.bazel to specify Armv8.5-A baseline architecture flags rather than Armv9: - BUILD.gn: update :libyuv_sve to -march=armv8.5-a+i8mm+sve2 and :libyuv_sme to -march=armv8.5-a+i8mm+sme. - CMakeLists.txt: update SME check and compile options to -march=armv8.5-a+i8mm+sme (SVE target already uses armv8.5-a). - BUILD.bazel: update ENABLE_SVE_COPTS to -march=armv8.5-a+i8mm+sve2. Using -march=armv9-a enabled baseline SVE in the compiler, causing Clang to emit non-streaming SVE instructions (such as cntd in function prologues prior to smstart) in SME translation units. On processors such as Apple M4/M5 that support SME but not SVE, executing these prologue instructions resulted in SIGILL crashes. Test: ninja -C out/arm64.release libyuv libyuv_unittest Bug: 558654023 Change-Id: Ic7f62842bc9bd71608cc78ad11fd5e2214ef5e8e TAG=agy CONV=a70f0e53-caf2-4fbe-a024-1616ed25ba9a Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8376021 Commit-Queue: Wan-Teh Chang Reviewed-by: Wan-Teh Chang --- BUILD.bazel | 2 +- BUILD.gn | 9 +++++---- CMakeLists.txt | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index a033be0e7..e8ce1c262 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -36,7 +36,7 @@ SUPPORTS_SVE_COPTS = [ ] ENABLE_SVE_COPTS = [ - "-march=armv9-a+i8mm+sve2", + "-march=armv8.5-a+i8mm+sve2", ] SVE_COPTS = select({ diff --git a/BUILD.gn b/BUILD.gn index 9dc188345..e6913efdc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -248,8 +248,8 @@ if (libyuv_use_sve) { # The -march arguments below are incompatible with libc++ modules. use_libcxx_modules = false - # SVE2 is an Armv9-A feature. - cflags = [ "-march=armv9-a+i8mm+sve2" ] + # SVE2 is an Armv9-A feature, but use Armv8.5-A for compatibility. + cflags = [ "-march=armv8.5-a+i8mm+sve2" ] } } @@ -268,8 +268,9 @@ if (libyuv_use_sme) { # The -march arguments below are incompatible with libc++ modules. use_libcxx_modules = false - # SME is an Armv9-A feature. - cflags = [ "-march=armv9-a+i8mm+sme" ] + # SME is an Armv9-A feature, but use Armv8.5-A for compatibility with + # processors like Apple M4/M5 that support SME without SVE. + cflags = [ "-march=armv8.5-a+i8mm+sme" ] } } diff --git a/CMakeLists.txt b/CMakeLists.txt index 17f6cbda9..1622b5c05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,12 +114,12 @@ if(NOT MSVC) target_compile_options(${ly_lib_name}_sve PRIVATE -march=armv8.5-a+i8mm+sve2) list(APPEND ly_lib_parts $) - set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=armv9-a+i8mm+sme") - set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) # Check whether the compiler can compile SME functions; this fails # with Clang for Windows. + set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=armv8.5-a+i8mm+sme") + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) check_c_source_compiles(" __arm_locally_streaming void func(void) { } int main(void) { return 0; } @@ -133,7 +133,7 @@ int main(void) { return 0; } ${ly_src_dir}/rotate_sme.cc ${ly_src_dir}/row_sme.cc ${ly_src_dir}/scale_sme.cc) - target_compile_options(${ly_lib_name}_sme PRIVATE -march=armv9-a+i8mm+sme) + target_compile_options(${ly_lib_name}_sme PRIVATE -march=armv8.5-a+i8mm+sme) list(APPEND ly_lib_parts $) else() add_definitions(-DLIBYUV_DISABLE_SME)