Skip to content

Change CMake config to enable universal binary for Mac#50243

Closed
janeyx99 wants to merge 2 commits intopytorch:masterfrom
janeyx99:enable-minimal-cross-compilation
Closed

Change CMake config to enable universal binary for Mac#50243
janeyx99 wants to merge 2 commits intopytorch:masterfrom
janeyx99:enable-minimal-cross-compilation

Conversation

@janeyx99
Copy link
Copy Markdown
Contributor

@janeyx99 janeyx99 commented Jan 7, 2021

This PR is a step towards enabling cross compilation from x86_64 to arm64.

The following has been added:

  1. When cross compilation is detected, compile a local universal fatfile to use as protoc.
  2. For the simple compile check in MiscCheck.cmake, make sure to compile the small snippet as a universal binary in order to run the check.

Test plan:

Kick off a minimal build on a mac intel machine with the macOS 11 SDK with this command:

CMAKE_OSX_ARCHITECTURES=arm64 USE_MKLDNN=OFF USE_QNNPACK=OFF USE_PYTORCH_QNNPACK=OFF BUILD_TEST=OFF USE_NNPACK=OFF python setup.py install

(If you run the above command before this change, or without macOS 11 SDK set up, it will fail.)

Then check the platform of the built binaries using this command:

lipo -info build/lib/libfmt.a

Output:

  • Before this PR, running a regular build via python setup.py install (instead of using the flags listed above):
    Non-fat file: build/lib/libfmt.a is architecture: x86_64
    
  • Using this PR:
    Non-fat file: build/lib/libfmt.a is architecture: arm64
    

@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Jan 7, 2021

💊 CI failures summary and remediations

As of commit 8f5ab7c (more details on the Dr. CI page):


  • 3/3 failures possibly* introduced in this PR
    • 2/3 non-CircleCI failure(s)

1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test2 Run tests 🔁 rerun

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

This comment has been revised 29 times.

@janeyx99 janeyx99 force-pushed the enable-minimal-cross-compilation branch from 49e2fe2 to a49f4d5 Compare January 7, 2021 23:58
@janeyx99 janeyx99 force-pushed the enable-minimal-cross-compilation branch from a49f4d5 to 2748649 Compare January 8, 2021 17:06
@janeyx99 janeyx99 requested review from a team and malfet January 8, 2021 18:12
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@janeyx99 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@samestep

This comment has been minimized.

Comment thread cmake/Summary.cmake Outdated
@janeyx99

This comment has been minimized.

@janeyx99 janeyx99 changed the title Added some changes to enable universal binary for mac Change CMake config to enable universal binary for Mac Jan 8, 2021
@samestep

This comment has been minimized.

@janeyx99

This comment has been minimized.

Comment thread CMakeLists.txt Outdated
Comment thread cmake/Summary.cmake Outdated
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@janeyx99 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@janeyx99 merged this pull request in c2d37cd.

facebook-github-bot pushed a commit that referenced this pull request Feb 12, 2021
Summary:
Tests cross-compilation of ARM64 architecture in MacOS CI.

This should be merged after PR #50243 and #50922 (adding a fix).

The reason we pin the wheel to be version 0.36.2 is because lower versions cannot handle c38 as a tag for the wheel.

Pull Request resolved: #49751

Reviewed By: albanD

Differential Revision: D26411133

Pulled By: janeyx99

fbshipit-source-id: 00a5cf597aee10adea1547579270cb3b38732563
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Tests cross-compilation of ARM64 architecture in MacOS CI.

This should be merged after PR pytorch#50243 and pytorch#50922 (adding a fix).

The reason we pin the wheel to be version 0.36.2 is because lower versions cannot handle c38 as a tag for the wheel.

Pull Request resolved: pytorch#49751

Reviewed By: albanD

Differential Revision: D26411133

Pulled By: janeyx99

fbshipit-source-id: 00a5cf597aee10adea1547579270cb3b38732563
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
This PR is a step towards enabling cross compilation from x86_64 to arm64.

The following has been added:
1. When cross compilation is detected, compile a local universal fatfile to use as protoc.
2. For the simple compile check in MiscCheck.cmake, make sure to compile the small snippet as a universal binary in order to run the check.

**Test plan:**

Kick off a minimal build on a mac intel machine with the macOS 11 SDK with this command:
```
CMAKE_OSX_ARCHITECTURES=arm64 USE_MKLDNN=OFF USE_QNNPACK=OFF USE_PYTORCH_QNNPACK=OFF BUILD_TEST=OFF USE_NNPACK=OFF python setup.py install
```
(If you run the above command before this change, or without macOS 11 SDK set up, it will fail.)

Then check the platform of the built binaries using this command:
```
lipo -info build/lib/libfmt.a
```
Output:
- Before this PR, running a regular build via `python setup.py install` (instead of using the flags listed above):
  ```
  Non-fat file: build/lib/libfmt.a is architecture: x86_64
  ```
- Using this PR:
  ```
  Non-fat file: build/lib/libfmt.a is architecture: arm64
  ```

Pull Request resolved: pytorch#50243

Reviewed By: malfet

Differential Revision: D25849955

Pulled By: janeyx99

fbshipit-source-id: e9853709a7279916f66aa4c4e054dfecced3adb1
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Tests cross-compilation of ARM64 architecture in MacOS CI.

This should be merged after PR pytorch#50243 and pytorch#50922 (adding a fix).

The reason we pin the wheel to be version 0.36.2 is because lower versions cannot handle c38 as a tag for the wheel.

Pull Request resolved: pytorch#49751

Reviewed By: albanD

Differential Revision: D26411133

Pulled By: janeyx99

fbshipit-source-id: 00a5cf597aee10adea1547579270cb3b38732563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants