@@ -99,6 +99,33 @@ set(GGML_SANITIZE_UNDEFINED ${WHISPER_SANITIZE_UNDEFINED})
9999set (GGML_ALL_WARNINGS ${WHISPER_ALL_WARNINGS} )
100100set (GGML_FATAL_WARNINGS ${WHISPER_FATAL_WARNINGS} )
101101
102+ # -------------------- KUNPENG / ARM64 friendly defaults --------------------
103+ # This block provides a safe default -march for Huawei Kunpeng 920 (aarch64)
104+ # and allows users to override via -DWHISPER_ARM_MARCH=... when running cmake.
105+ # Kunpeng 920 (ARMv8.2-A) typically supports: dotprod, crc, crypto, fp16
106+ # but does NOT support jscvt / fcma; avoid enabling those.
107+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64" )
108+ # If user didn't set a custom march, choose a conservative default compatible with Kunpeng 920
109+ if (NOT DEFINED WHISPER_ARM_MARCH)
110+ set (WHISPER_ARM_MARCH "armv8.2-a+dotprod+crc+crypto+fp16fml" CACHE STRING "ARM march to use for building on ARM64 (Kunpeng-friendly default)" )
111+ endif ()
112+
113+ # Allow opt-out: user can explicitly pass -DWHISPER_ARM_MARCH="native" or other value
114+ if (NOT WHISPER_ARM_MARCH STREQUAL "" )
115+ # Only append march flags if they are not already present in CMAKE_C_FLAGS/CXX_FLAGS
116+ string (FIND "${CMAKE_C_FLAGS} " "-march" _found_c)
117+ if (_found_c EQUAL -1)
118+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${WHISPER_ARM_MARCH} " )
119+ endif ()
120+ string (FIND "${CMAKE_CXX_FLAGS} " "-march" _found_cxx)
121+ if (_found_cxx EQUAL -1)
122+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${WHISPER_ARM_MARCH} " )
123+ endif ()
124+
125+ endif ()
126+ endif ()
127+ # ---------------------------------------------------------------------------
128+
102129# transition helpers
103130function (whisper_option_depr TYPE OLD NEW)
104131 if (${OLD} )
0 commit comments