Skip to content

Pass deployment target when linking metallib#3501

Open
dhiltgen wants to merge 1 commit intoml-explore:mainfrom
dhiltgen:metal-link
Open

Pass deployment target when linking metallib#3501
dhiltgen wants to merge 1 commit intoml-explore:mainfrom
dhiltgen:metal-link

Conversation

@dhiltgen
Copy link
Copy Markdown
Contributor

@dhiltgen dhiltgen commented May 9, 2026

MLX compiles each Metal kernel AIR file with -mmacosx-version-min from CMAKE_OSX_DEPLOYMENT_TARGET, but the final metal driver invocation did not receive that deployment target.

With the macOS 26 SDK and CMAKE_OSX_DEPLOYMENT_TARGET=14.0, the metal driver otherwise invokes air-lld with the SDK default platform version and can stamp mlx.metallib as macOS 26 even though the input AIR files target macOS 14.

Repro:

cmake -S . -B build-macos14 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0

cmake --build build-macos14 --target mlx-metallib --parallel

strings -a build-macos14/mlx/backend/metal/kernels/mlx.metallib | grep -Eo 'air64[^[:space:]]*macosx[0-9.]+' | sort -u

Keep using metal as the linker front-end and pass -mmacosx-version-min through the final link step. Verified with macOS SDK 26.4 that the resulting library reports air64_v26-apple-macosx14.0.0.

Proposed changes

Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

MLX compiles each Metal kernel AIR file with -mmacosx-version-min from CMAKE_OSX_DEPLOYMENT_TARGET, but the final metal driver invocation did not receive that deployment target.

With the macOS 26 SDK and CMAKE_OSX_DEPLOYMENT_TARGET=14.0, the metal driver otherwise invokes air-lld with the SDK default platform version and can stamp mlx.metallib as macOS 26 even though the input AIR files target macOS 14.

Repro:

  cmake -S . -B build-macos14 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0

  cmake --build build-macos14 --target mlx-metallib --parallel

  strings -a build-macos14/mlx/backend/metal/kernels/mlx.metallib | grep -Eo 'air64[^[:space:]]*macosx[0-9.]+' | sort -u

Keep using metal as the linker front-end and pass -mmacosx-version-min through the final link step. Verified with macOS SDK 26.4 that the resulting library reports air64_v26-apple-macosx14.0.0.
Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants