|
36 | 36 | # It's necessary to consistently use backendStdenv when building with CUDA support,
|
37 | 37 | # otherwise we get libstdc++ errors downstream.
|
38 | 38 | effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv,
|
39 |
| - enableStatic ? effectiveStdenv.hostPlatform.isStatic |
| 39 | + enableStatic ? effectiveStdenv.hostPlatform.isStatic, |
| 40 | + precompileMetalShaders ? false |
40 | 41 | }@inputs:
|
41 | 42 |
|
42 | 43 | let
|
@@ -166,12 +167,12 @@ effectiveStdenv.mkDerivation (
|
166 | 167 | '';
|
167 | 168 |
|
168 | 169 | # With PR#6015 https://github.com/ggerganov/llama.cpp/pull/6015,
|
169 |
| - # `default.metallib` is compiled with Metal compiler from XCode |
| 170 | + # `default.metallib` may be compiled with Metal compiler from XCode |
170 | 171 | # and we need to escape sandbox on MacOS to access Metal compiler.
|
171 | 172 | # `xcrun` is used find the path of the Metal compiler, which is varible
|
172 | 173 | # and not on $PATH
|
173 | 174 | # see https://github.com/ggerganov/llama.cpp/pull/6118 for discussion
|
174 |
| - __noChroot = effectiveStdenv.isDarwin && useMetalKit; |
| 175 | + __noChroot = effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders; |
175 | 176 |
|
176 | 177 | nativeBuildInputs =
|
177 | 178 | [
|
@@ -234,7 +235,10 @@ effectiveStdenv.mkDerivation (
|
234 | 235 | # Should likely use `rocmPackages.clr.gpuTargets`.
|
235 | 236 | "-DAMDGPU_TARGETS=gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102"
|
236 | 237 | ]
|
237 |
| - ++ optionals useMetalKit [ (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") ] |
| 238 | + ++ optionals useMetalKit [ |
| 239 | + (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") |
| 240 | + (cmakeBool "LLAMA_METAL_EMBED_LIBRARY" (!precompileMetalShaders)) |
| 241 | + ] |
238 | 242 | ++ optionals useBlas [ (lib.cmakeFeature "LLAMA_BLAS_VENDOR" "OpenBLAS") ];
|
239 | 243 |
|
240 | 244 | # TODO(SomeoneSerge): It's better to add proper install targets at the CMake level,
|
|
0 commit comments