Skip to content

macOS: Errors when cross compiling for arm64 #6573

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

Closed
JanosGit opened this issue Feb 4, 2021 · 6 comments
Closed

macOS: Errors when cross compiling for arm64 #6573

JanosGit opened this issue Feb 4, 2021 · 6 comments
Assignees
Labels
core runtime issues related to core runtime feature request request for unsupported feature or enhancement

Comments

@JanosGit
Copy link

JanosGit commented Feb 4, 2021

Describe the bug
I want to compile onnxruntime for new arm64 macs to build a universal onnxruntime binary. I do that with this command:

python3 onnxruntime/tools/ci_build/build.py --build_dir build_arm64 --build --update --parallel --build_shared_lib --disable_nccl --skip-keras-test  --use_full_protobuf  --include_ops_by_config required_operators.config --skip_tests --disable_ml_ops --minimal_build  --osx_arch arm64 --config Release

which is basically the same command as successfully used for our x86_64 mac builds. During compilation it fails with

[ 21%] Building CXX object external/protobuf/cmake/CMakeFiles/libprotobuf.dir/__/src/google/protobuf/repeated_field.cc.o
Path/to/onnxruntime/onnxruntime/core/mlas/lib/aarch64/QgemmU8X8KernelNeon.S:86:16: error: brackets expression not supported on this target
        ldr x8,[sp,#.LGemmU8X8KernelFrame_ColumnSumBuffer]

The goal is to combine the x86_64 and arm64 build into a universal binary dylib using lipo.

Urgency
Medium. We are currently working on porting our dependencies to universal binaries to create native M1 optimised versions of our software but this is still work in progress

System information

  • OS Platform and Distribution: macOS 10.15.6
  • ONNX Runtime installed from (source or binary): Source
  • ONNX Runtime version: 1.6.0
  • Python version: 3.7.3
  • Visual Studio version (if applicable): -
  • GCC/Compiler version (if compiling from source): Apple clang 12.0.0

To Reproduce
Execute build command as above

Expected behavior
Successful compilation of an arm64 library

@snnn snnn added the core runtime issues related to core runtime label Feb 4, 2021
@guoyu-wang
Copy link
Contributor

guoyu-wang commented Feb 4, 2021

I have tried your build command (without the --include_ops_by_config required_operators.config) to build onnxruntime 1.6.0 release on a x64 macOS 10.15, and can finish the compile with no issue.
Are you using CMake 3.19+?

@JanosGit
Copy link
Author

JanosGit commented Feb 8, 2021

No, I was using the Xcode-supplied CMake 3.18... switching to the homebrew installed CMake 3.19 resolved it 🤦‍♂️ Would it be possible to add a check for the CMake version and aborting the build with a clear error when compiling for macOS/arm64 with CMake < 3.19 for people like me?

@guoyu-wang
Copy link
Contributor

guoyu-wang commented Feb 10, 2021

We do have the CMake version requirements listed here https://github.com/microsoft/onnxruntime/blob/master/BUILD.md#macos, however it will be nice to raise the error in the building script for this scenario.

@guoyu-wang guoyu-wang assigned guoyu-wang and unassigned tracysh Feb 10, 2021
@snnn
Copy link
Member

snnn commented Aug 15, 2021

I will submit a PR and publish a test package tomorrow.

@snnn snnn assigned snnn and unassigned guoyu-wang Aug 15, 2021
@snnn snnn added the feature request request for unsupported feature or enhancement label Aug 15, 2021
@snnn
Copy link
Member

snnn commented Aug 18, 2021

Once PR #8754 is merged, you can build it in a way like:

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

If you want a universal binary, please change the last part to

CMAKE_OSX_ARCHITECTURES='arm64;x86_64'

@faxu
Copy link
Contributor

faxu commented Apr 4, 2022

Closing this as compiling is now supported. Please reactivate if there are still issues.

@faxu faxu closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime feature request request for unsupported feature or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants