Skip to content

Commit 2b7033b

Browse files
committed
Symlink to /usr/bin/xcrun so that xcrun binary
is usable during build (used for compiling Metal shaders) Fixes #6117
1 parent c47cf41 commit 2b7033b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.devops/nix/package.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
config,
55
stdenv,
66
mkShell,
7+
runCommand,
78
cmake,
89
ninja,
910
pkg-config,
@@ -87,6 +88,11 @@ let
8788
]
8889
);
8990

91+
xcrunHost = runCommand "xcrunHost" {} ''
92+
mkdir -p $out/bin
93+
ln -s /usr/bin/xcrun $out/bin
94+
'';
95+
9096
# apple_sdk is supposed to choose sane defaults, no need to handle isAarch64
9197
# separately
9298
darwinBuildInputs =
@@ -157,6 +163,14 @@ effectiveStdenv.mkDerivation (
157163
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python}/bin/python"
158164
'';
159165

166+
# With PR#6015 https://github.com/ggerganov/llama.cpp/pull/6015,
167+
# `default.metallib` is compiled with Metal compiler from XCode
168+
# and we need to escape sandbox on MacOS to access Metal compiler.
169+
# `xcrun` is used find the path of the Metal compiler, which is varible
170+
# and not on $PATH
171+
# see https://github.com/ggerganov/llama.cpp/pull/6118 for discussion
172+
__noChroot = effectiveStdenv.isDarwin && useMetalKit;
173+
160174
nativeBuildInputs =
161175
[
162176
cmake
@@ -173,6 +187,8 @@ effectiveStdenv.mkDerivation (
173187
]
174188
++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [
175189
glibc.static
190+
] ++ optionals (effectiveStdenv.isDarwin && useMetalKit) [
191+
xcrunHost
176192
];
177193

178194
buildInputs =

0 commit comments

Comments
 (0)