From e6add1efc4d85fa4e9fa869391ac460aed2113d7 Mon Sep 17 00:00:00 2001 From: usama Date: Wed, 21 May 2025 15:19:06 -0700 Subject: [PATCH] [compiler-rt][cmake] Test COMPILER_RT_HAS_AARCH64_SME with arm64 architecture only. Apple configures CMake only once for compiler-rt, even when building for multiple architectures. As a result, we need to explicitly test for arm64 specific attributes by building for that architecture rdar://149068965 --- compiler-rt/cmake/Modules/BuiltinTests.cmake | 13 +++++++++++++ compiler-rt/cmake/builtin-config-ix.cmake | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler-rt/cmake/Modules/BuiltinTests.cmake b/compiler-rt/cmake/Modules/BuiltinTests.cmake index 63c5f47cb5010..093a1c758e278 100644 --- a/compiler-rt/cmake/Modules/BuiltinTests.cmake +++ b/compiler-rt/cmake/Modules/BuiltinTests.cmake @@ -134,3 +134,16 @@ function(builtin_check_c_compiler_source output source) endif() endif() endfunction() + +function(builtin_check_c_compiler_source_with_flags output source flags) + if(NOT DEFINED ${output}) + message(STATUS "Performing Test ${output}") + try_compile_only(result SOURCE ${source} FLAGS ${flags}) + set(${output} ${result} CACHE INTERNAL "Compiler supports ${output} with ${flags}") + if(${result}) + message(STATUS "Performing Test ${output} - Success") + else() + message(STATUS "Performing Test ${output} - Failed") + endif() + endif() +endfunction() diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake index d3cf621c144b6..eeeb8d1c793b0 100644 --- a/compiler-rt/cmake/builtin-config-ix.cmake +++ b/compiler-rt/cmake/builtin-config-ix.cmake @@ -41,14 +41,14 @@ asm(\".arch armv8-a+lse\"); asm(\"cas w0, w1, [x2]\"); ") -builtin_check_c_compiler_source(COMPILER_RT_HAS_AARCH64_SME +builtin_check_c_compiler_source_with_flags(COMPILER_RT_HAS_AARCH64_SME " void foo(void) __arm_streaming_compatible { asm(\".arch armv9-a+sme2\\n\" \"smstart\\n\" \"ldr zt0, [sp]\"); } -") +" "-target ${LLVM_TARGET_TRIPLE} -arch arm64") check_include_files("sys/auxv.h" COMPILER_RT_HAS_AUXV)