cmake: add explicit metal version options #6370
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if you want to build
llama.cpp
binaries with metal enabled, you can only compile the metal libraries to be compatible with the minimum mac os version and metal shading language standard associated with your current machines SDK. This is the default behavior of of thexcrun metal
command.This presents a problem if you ever want to build llama.cpp from a newer machine (say a Mac running macOS 14.x with default metal shading language 3.1), and have it be able to run on an older machine (say a Mac running macOS 13.x with default metal shading language 3.0).
With the current state of
llama.cpp
, trying to perform the exact build above from macOS 14.x and running on macOS 13.x results in the following error during model load:By providing the new CMake options
LLAMA_METAL_MACOSX_VERSION_MIN
andLLAMA_METAL_STD
, you can now explicitly set the macOS min version and metal shading library standard that your build will support:and you will be notified in the output of that cmake command:
Doing this allows for both macOS 13.x and macOS 14.x to run llama.cpp binaries built from macOS 14.x without metal incompatibility errors.
The default behavior of builds without those options set will remain the same (since default value of these variables is
""
, and therefore will be ignored in the logic to add the flags toXC_FLAGS
).