-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Description
Git commit
Operating systems
Linux
GGML backends
CPU
Problem description & steps to reproduce
The overall bug is that executing the install target with the project configured with GGML_CPU_KLEIDIAI fails due to KleidiAI's install target still being included despite never being built. Currently, the following snippet is used to prevent the KleidiAI library itself from being built after the source was downloaded and included:
# Remove kleidiai target after fetching it
if (TARGET kleidiai)
set_target_properties(kleidiai PROPERTIES EXCLUDE_FROM_ALL TRUE)
endif()However, this only removes it from the all target. When subsequently using the install target either via cmake --install <path> (after building) or cmake --build <path> --target install, CMake raises an error due to attempting to find and copy the non-existent KleidiAI library since it's still included in the install target.
I am not familiar with ggml's policy on minimum supported CMake version (I couldn't find it mentioned anywhere, if it exists), but the simplest fix that I found was modifying the FetchContent_Declare invocation to use the EXCLUDE_FROM_ALL option, which was added to FetchContent in CMake version 3.28. I believe this also makes the snippet above redundant.
FetchContent_Declare(KleidiAI_Download
URL ${KLEIDIAI_DOWNLOAD_URL}
DOWNLOAD_EXTRACT_TIMESTAMP NEW
URL_HASH MD5=${KLEIDIAI_ARCHIVE_MD5}
EXCLUDE_FROM_ALL)The alternative solution that seems to work that I'm aware of is manually populating and extracting the source files with FetchContent_Populate, though it requires using a form of the command that has been deprecated since CMake 3.30. I would be remiss if I did not mention, however, that I am not particularly practiced in CMake-foo so these suggestions can be disregarded if they're completely unsound. I'm certainly a bit confused that the EXCLUDE_FROM_ALL behavior differs between setting it for the target manually and setting it via the FetchContent parameters.
Brief background on how I ran into this issue: I was trying to build a project with llama-cpp-rs with KleidiAI kernels enabled but was stalled by this problem since the underlying build configuration uses the install target when building and linking.
First Bad Commit
No response
Compile command
cmake -S . -B build-install \
-DGGML_CPU_KLEIDIAI=on \
-DGGML_OPENMP=off \
-DGGML_LLAMAFILE=off \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/29.0.14206865/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DGGML_CCACHE=off \
-DCMAKE_INSTALL_PREFIX=./build-install/install
cmake --build build-install --target install -j12Relevant log output
-- Install configuration: "Release"
-- Installing: /teamg/scratch/llama.cpp/build-install/install/lib/libggml-cpu.so
CMake Error at build-install/_deps/kleidiai_download-build/cmake_install.cmake:52 (file):
file INSTALL cannot find
"/teamg/scratch/llama.cpp/build-install/bin/libkleidiai.so": No such file
or directory.
Call Stack (most recent call first):
build-install/ggml/src/cmake_install.cmake:71 (include)
build-install/ggml/cmake_install.cmake:47 (include)
build-install/cmake_install.cmake:47 (include)