From 0af5c68a0ca2f63632ad61c6a388ddf6a7d563d4 Mon Sep 17 00:00:00 2001 From: Joseph Stahl <1269177+josephst@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:08:28 -0400 Subject: [PATCH] cmake - copy default.metallib to install directory When metal files are compiled to default.metallib, Cmake needs to add this to the install directory so that it's visible to llama-cpp Also, update package.nix to use absolute path for default.metallib (it's not finding the bundle) --- .devops/nix/package.nix | 2 ++ CMakeLists.txt | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index f93b25b24..2d64a6808 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -156,6 +156,8 @@ effectiveStdenv.mkDerivation ( postPatch = '' substituteInPlace ./ggml-metal.m \ --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";" + substituteInPlace ./ggml-metal.m \ + --replace '[bundle pathForResource:@"default" ofType:@"metallib"];' "@\"$out/bin/default.metallib\";" # TODO: Package up each Python script or service appropriately. # If we were to migrate to buildPythonPackage and prepare the `pyproject.toml`, diff --git a/CMakeLists.txt b/CMakeLists.txt index b25cfd2fc..d101d3a58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1260,6 +1260,12 @@ if (LLAMA_METAL) GROUP_READ WORLD_READ DESTINATION ${CMAKE_INSTALL_BINDIR}) + if (NOT LLAMA_METAL_EMBED_LIBRARY) + install( + FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/default.metallib + DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endif() endif() #