Skip to content

Commit 45c0663

Browse files
Fix mlasi_sve.h preprocessor guards to allow clang compilation (microsoft#28507)
### Description The outer `#ifndef __clang__` in `mlasi_sve.h` (line 20 to line 679) was intended to wrap the GCC-specific `#pragma GCC` directives, but it also ends up hiding every SVE kernel declaration and the typedefs from clang. The `#ifdef __clang__` block that defines `MLAS_SVE_TARGET` for clang's per-function `__attribute__((target("...")))` syntax is unreachable for the same reason. This moves the closing `#endif` up to right after the GCC pragmas so only the pragmas are GCC-only, and the rest of the header (typedefs, kernel declarations, MLAS_SVE_TARGET) is visible to both compilers. ### Motivation and Context Without this, building MLAS with clang for aarch64 fails at platform.cpp - the `MLAS_USE_SVE` runtime-dispatch block references `MlasSveErfKernel`, `MlasSveLogisticKernel`, and friends, all undeclared from clang's perspective. Confirmed working with clang 20.1.8.
1 parent ad6d34c commit 45c0663

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

onnxruntime/core/mlas/lib/sve/mlasi_sve.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Module Name:
2020
#ifndef __clang__
2121
#pragma GCC push_options
2222
#pragma GCC target("arch=armv8.2-a+sve")
23+
#endif
2324

2425
// Use Clang-specific per-function attribute
2526
#ifdef __clang__
@@ -676,5 +677,4 @@ MlasSveCompareGreaterThan(svbool_t Pred, MLAS_SVFLOAT32 A, MLAS_SVFLOAT32 B)
676677
#pragma GCC pop_options
677678
#endif
678679

679-
#endif
680680

0 commit comments

Comments
 (0)