Skip to content

Weakly link error domains to allow building non-Metal-supporting targets#354

Merged
davidkoski merged 1 commit intoml-explore:mainfrom
shareup:fix-simulator-build
Feb 10, 2026
Merged

Weakly link error domains to allow building non-Metal-supporting targets#354
davidkoski merged 1 commit intoml-explore:mainfrom
shareup:fix-simulator-build

Conversation

@atdrendel
Copy link
Contributor

@atdrendel atdrendel commented Feb 9, 2026

Proposed changes

Addresses #341 by using_MTL_PRIVATE_DEF_WEAK_CONST to weakly link MTLIOErrorDomain and MTLTensorDomain, which allows Simulator builds for libraries that include MLX Swift.

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)

Copilot AI review requested due to automatic review settings February 9, 2026 23:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the vendored Metal-cpp headers to weakly resolve two Metal error-domain constants so projects depending on MLX Swift can link successfully on targets (notably iOS Simulator) where those symbols are not present.

Changes:

  • Switch MTL::TensorDomain to use _MTL_PRIVATE_DEF_WEAK_CONST (dlsym-based) instead of _MTL_PRIVATE_DEF_CONST.
  • Switch MTL::IOErrorDomain to use _MTL_PRIVATE_DEF_WEAK_CONST instead of _MTL_PRIVATE_DEF_CONST.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Source/Cmlx/metal-cpp/Metal/MTLTensor.hpp Weakly resolves MTLTensorDomain to avoid link-time failures when the symbol isn’t available.
Source/Cmlx/metal-cpp/Metal/MTLIOCommandQueue.hpp Weakly resolves MTLIOErrorDomain to avoid link-time failures when the symbol isn’t available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@davidkoski davidkoski left a comment

Choose a reason for hiding this comment

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

Thank you! This needs to be included in the combined .hpp file for the xcodeproj but I will rebase #353 on this and update that there.

@davidkoski davidkoski merged commit 5a7b694 into ml-explore:main Feb 10, 2026
12 of 13 checks passed
@atdrendel atdrendel deleted the fix-simulator-build branch February 10, 2026 21:43
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.

3 participants