ggml: fix s390x all cpu build (#30140)

Signed-off-by: Aaron Teo <aaron.teo1@ibm.com>
This commit is contained in:
Aaron Teo 2026-10-10 14:07:52 +08:00 • committed by GitHub
parent f2918cabbf
commit b797c82c7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -462,6 +462,8 @@ function(ggml_add_cpu_backend_variant tag_name)
set(GGML_INTERNAL_${feat} ON)
endforeach()
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
set(GGML_NATIVE OFF)
foreach (feat VXE2 NNPA)
set(GGML_INTERNAL_${feat} OFF)
endforeach()
@ -569,6 +571,14 @@ if (GGML_CPU_ALL_VARIANTS)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
ggml_add_cpu_backend_variant(z15 Z15 VXE2)
ggml_add_cpu_backend_variant(z16 Z16 VXE2 NNPA)
# check if compiler supports "-march=z17" codename
check_cxx_compiler_flag("-march=z17" GGML_CXX_SUPPORTS_Z17)
if (GGML_CXX_SUPPORTS_Z17)
ggml_add_cpu_backend_variant(z17 Z17 VXE2 NNPA)
else()
ggml_add_cpu_backend_variant(arch15 Z17 VXE2 NNPA)
endif()
else()
message(FATAL_ERROR "Unsupported s390x target OS: ${CMAKE_SYSTEM_NAME}")
endif()

View file

@ -593,7 +593,12 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
foreach (ZHW RANGE 15 17)
if(DEFINED GGML_INTERNAL_Z${ZHW})
message(STATUS "z${ZHW} cross-compile target")
list(APPEND ARCH_FLAGS -march=z${ZHW})
if (ZHW EQUAL 17)
# z17 is an alias of arch15, use the arch level for wider toolchain support
list(APPEND ARCH_FLAGS -march=arch15)
else()
list(APPEND ARCH_FLAGS -march=z${ZHW})
endif()
endif()
endforeach()
endif()