Skip to content

Commit

Permalink
Symlink to /usr/bin/xcrun so that xcrun binary
Browse files Browse the repository at this point in the history
is usable during build (used for compiling Metal shaders)

Fixes #6117
  • Loading branch information
josephst committed Mar 21, 2024
1 parent c47cf41 commit 2b7033b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .devops/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
config,
stdenv,
mkShell,
runCommand,
cmake,
ninja,
pkg-config,
Expand Down Expand Up @@ -87,6 +88,11 @@ let
]
);

xcrunHost = runCommand "xcrunHost" {} ''
mkdir -p $out/bin
ln -s /usr/bin/xcrun $out/bin
'';

# apple_sdk is supposed to choose sane defaults, no need to handle isAarch64
# separately
darwinBuildInputs =
Expand Down Expand Up @@ -157,6 +163,14 @@ effectiveStdenv.mkDerivation (
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python}/bin/python"
'';

# With PR#6015 https://github.com/ggerganov/llama.cpp/pull/6015,
# `default.metallib` is compiled with Metal compiler from XCode
# and we need to escape sandbox on MacOS to access Metal compiler.
# `xcrun` is used find the path of the Metal compiler, which is varible
# and not on $PATH
# see https://github.com/ggerganov/llama.cpp/pull/6118 for discussion
__noChroot = effectiveStdenv.isDarwin && useMetalKit;

nativeBuildInputs =
[
cmake
Expand All @@ -173,6 +187,8 @@ effectiveStdenv.mkDerivation (
]
++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [
glibc.static
] ++ optionals (effectiveStdenv.isDarwin && useMetalKit) [
xcrunHost
];

buildInputs =
Expand Down

0 comments on commit 2b7033b

Please sign in to comment.