Skip to content

cmake file changes for macOS universal2 support #8953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 4, 2021
Merged

cmake file changes for macOS universal2 support #8953

merged 6 commits into from
Sep 4, 2021

Conversation

snnn
Copy link
Member

@snnn snnn commented Sep 3, 2021

Description:

"Universal2" allows us creating a single binary that runs natively on both Apple silicon and Intel-based Mac computers. There are two ways of doing this:

  1. Build for the two archs at the same time with "-arch arm64 -arch x86_64".
  2. Build two binaries separately, then use a tool to combine them together after the build.

The second one already works. The first one is what I'm providing. You can try the new thing in a way like:

python3 tools/ci_build/build.py --skip_submodule_sync --build_dir b --cmake_extra_defines 'CMAKE_OSX_ARCHITECTURES=x86_64;arm64' --parallel

To find more information about Universal2, please
https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

Motivation and Context

  • Why is this change required? What problem does it solve?
  • If it fixes an open issue, please link to the issue here.

@snnn snnn requested a review from a team as a code owner September 3, 2021 00:12
@snnn
Copy link
Member Author

snnn commented Sep 3, 2021

This PR is split from #8754

@guoyu-wang
Copy link
Contributor

Can you also disable this when the onnxruntime_BUILD_APPLE_FRAMEWORK is set to true? We are stitching static libs together, however, it won't work for universal lib

@snnn
Copy link
Member Author

snnn commented Sep 3, 2021

Can you also disable this when the onnxruntime_BUILD_APPLE_FRAMEWORK is set to true? We are stitching static libs together, however, it won't work for universal lib

Disable what? Sorry I lose the context.

@guoyu-wang
Copy link
Contributor

guoyu-wang commented Sep 3, 2021

Can you also disable this when the onnxruntime_BUILD_APPLE_FRAMEWORK is set to true? We are stitching static libs together, however, it won't work for universal lib

Disable what? Sorry I lose the context.

If we try to build universal binary when onnxruntime_BUILD_APPLE_FRAMEWORK is true, the output static framework will not be usable. since we stitch multiple static libraries together, but that would not work for universal static libraries, if CMAKE_OSX_ARCHITECTURES_LEN > 1 and onnxruntime_BUILD_APPLE_FRAMEWORK is true build should fail.

@snnn snnn merged commit 60c98a8 into master Sep 4, 2021
@snnn snnn deleted the snnn/cmake branch September 4, 2021 20:30
@RajalakshmiSR
Copy link
Contributor

@snnn This affects POWER10 build. mlas_common_srcs in cmake/onnxruntime_mlas.cmake is used to add some build option . I will create a PR to address this.

snnn added a commit that referenced this pull request Apr 27, 2023
### Description

In #8953 I introduced a change in our onnxruntime_mlas.cmake that it
enables "ASM_MASM" cmake language for all Windows build.
```cmake
enable_language(ASM_MASM)
```
Before the change, it is only enabled when onnxruntime_target_platform
equals to x64.

However, cmake 3.26 added a new language:  ASM_MARMASM.

According to cmake's manual,
ASM_MASM is for Microsoft Assembler
ASM_MARMASM is for Microsoft ARM Assembler. This one is new in cmake
3.26.

We should choose the right one according to
${onnxruntime_target_platform}.
ShukantPal pushed a commit to ShukantPal/onnxruntime that referenced this pull request May 7, 2023
### Description

In microsoft#8953 I introduced a change in our onnxruntime_mlas.cmake that it
enables "ASM_MASM" cmake language for all Windows build.
```cmake
enable_language(ASM_MASM)
```
Before the change, it is only enabled when onnxruntime_target_platform
equals to x64.

However, cmake 3.26 added a new language:  ASM_MARMASM.

According to cmake's manual,
ASM_MASM is for Microsoft Assembler
ASM_MARMASM is for Microsoft ARM Assembler. This one is new in cmake
3.26.

We should choose the right one according to
${onnxruntime_target_platform}.
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