From 2637dfe3731adc093742c4451d1919163a0f70c7 Mon Sep 17 00:00:00 2001 From: Alan Tseng Date: Wed, 2 Sep 2026 14:12:28 +0800 Subject: [PATCH] ggml-cpu : conditionally add SpacemiT IME kernel sources (#27961) When building with gcc < 15, CMakeLists.txt unconditionally adds ime2_kernels.cpp, which fails to compile. FindSMTIME.cmake only defines RISCV64_SPACEMIT_IME2 when the IME2 instructions are detected, and gcc 14 only has IME1, so ime2_kernels.cpp hits its #error. This PR fixes it by using IN_LIST to add each kernel source according to the spec that was actually detected. --- ggml/src/ggml-cpu/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-cpu/CMakeLists.txt b/ggml/src/ggml-cpu/CMakeLists.txt index 5442e12501..17540faa66 100644 --- a/ggml/src/ggml-cpu/CMakeLists.txt +++ b/ggml/src/ggml-cpu/CMakeLists.txt @@ -455,12 +455,16 @@ function(ggml_add_cpu_backend_variant_impl tag_name) ggml-cpu/spacemit/repack.h ggml-cpu/spacemit/ime_env.cpp ggml-cpu/spacemit/ime_env.h - ggml-cpu/spacemit/ime1_kernels.cpp - ggml-cpu/spacemit/ime2_kernels.cpp ggml-cpu/spacemit/ime_kernels.h ggml-cpu/spacemit/rvv_kernels.cpp ggml-cpu/spacemit/rvv_kernels.h ) + if ("RISCV64_SPACEMIT_IME1" IN_LIST RISCV64_SPACEMIT_IME_SPEC) + list(APPEND GGML_CPU_SOURCES ggml-cpu/spacemit/ime1_kernels.cpp) + endif() + if ("RISCV64_SPACEMIT_IME2" IN_LIST RISCV64_SPACEMIT_IME_SPEC) + list(APPEND GGML_CPU_SOURCES ggml-cpu/spacemit/ime2_kernels.cpp) + endif() endif() if(NOT GGML_CPU_ALL_VARIANTS) set(MARCH_STR "rv64gc")