Skip to content

Commit 7c23f3f

Browse files
lizhennenglizhenneng
andauthored
ggml-cpu: detect correct cpu flags for arm64 (#16229) (#16239)
When using GCC 9 and GCC 12 on the arm64 platform of ubuntu 2004, the command "gcc -mcpu=native -E -v -" fails to detect the correct CPU flags, which results in compilation failures for certain extended instructions, but the correct CPU flags can be obtained by using gcc -march. Signed-off-by: lizhenneng <[email protected]> Co-authored-by: lizhenneng <[email protected]>
1 parent 8c0d6bb commit 7c23f3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ggml/src/ggml-cpu/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
118118
# so we check for them manually and enable them if available
119119

120120
execute_process(
121-
COMMAND ${CMAKE_C_COMPILER} -mcpu=native -E -v -
121+
COMMAND ${CMAKE_C_COMPILER} -march=native -E -v -
122122
INPUT_FILE "/dev/null"
123123
OUTPUT_QUIET
124124
ERROR_VARIABLE ARM_MCPU
125125
RESULT_VARIABLE ARM_MCPU_RESULT
126126
)
127127
if (NOT ARM_MCPU_RESULT)
128-
string(REGEX MATCH "-mcpu=[^ ']+" ARM_MCPU_FLAG "${ARM_MCPU}")
128+
string(REGEX MATCH "-march=[^ ']+" ARM_MCPU_FLAG "${ARM_MCPU}")
129129
endif()
130130
if ("${ARM_MCPU_FLAG}" STREQUAL "")
131-
set(ARM_MCPU_FLAG -mcpu=native)
132-
message(STATUS "ARM -mcpu not found, -mcpu=native will be used")
131+
set(ARM_MCPU_FLAG -march=native)
132+
message(STATUS "ARM -mcpu not found, -march=native will be used")
133133
endif()
134134

135135
include(CheckCXXSourceRuns)

0 commit comments

Comments
 (0)