llama-cpp: fix cross compilation (#561060)

This commit is contained in:
Gaétan Lepage
2026-09-08 08:17:28 +00:00
committed by GitHub

View File

@@ -1,5 +1,6 @@
{
lib,
buildPackages,
autoAddDriverRunpath,
cmake,
fetchFromGitHub,
@@ -81,6 +82,8 @@ let
vulkan-headers
vulkan-loader
];
buildCc = buildPackages.stdenv.cc;
in
effectiveStdenv.mkDerivation (finalAttrs: {
pname = "llama-cpp";
@@ -120,6 +123,11 @@ effectiveStdenv.mkDerivation (finalAttrs: {
shaderc
];
depsBuildBuild = optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
# llama-ui-embed under tools/ui needs a host compiler
buildCc
];
buildInputs =
optionals cudaSupport cudaBuildInputs
++ optionals openclSupport [ clblast ]
@@ -185,6 +193,9 @@ effectiveStdenv.mkDerivation (finalAttrs: {
++ optionals metalSupport [
(cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
(cmakeBool "LLAMA_METAL_EMBED_LIBRARY" true)
]
++ optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
(cmakeFeature "HOST_CXX_COMPILER" (lib.getExe' buildCc "${buildCc.targetPrefix}c++"))
];
postInstall = optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''