microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
13.37k stars 2.74k forks source link

v1.17.0 + requires macOS deployment target >= than 13.3 due to C++ 20 #21033

Open ola-ableton opened 1 week ago

ola-ableton commented 1 week ago

Describe the issue

It seems that moving to C++20 for macOS builds has bumped the minimum macOS that the library can run on. I didn't see this mentioned in the release notes. macOS 13.3 is not that old.

https://stackoverflow.com/questions/76932735/unable-to-use-to-chars-with-clang-on-macos

In file included from /onnxruntime/onnxruntime/include/onnxruntime/core/common/common.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/chrono:800:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__chrono/formatter.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__chrono/ostream.h:30:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__format/format_functions.h:29:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__format/formatter_floating_point.h:73:32: error: 'to_chars' is unavailable: introduced in macOS 13.3
  to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt, __precision);

To reproduce

try and compile explicitly setting a lower deployment target with --apple_deploy_target

Urgency

No response

Platform

Mac

OS Version

11

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.17.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

ola-ableton commented 1 week ago

https://github.com/microsoft/onnxruntime/commit/0141e27ca1e9954da2630f817709e2eebcd88dde

snnn commented 1 week ago

So, you were not using our official packages, you built the binaries from source by yourself and you didn't use the "--apple_deploy_target" flag?

ola-ableton commented 1 week ago

I am building a custom build but I did use the -apple_deploy_target.

We need to support macOS 11 or higher but if you specify

-apple_deploy_target=11.0

the build will fail with the above error

It's necessary to set at least

-apple_deploy_target=13.3

for the C++ 20 code to compile.

This will be a problem for many other users I imagine. Fortunately we can stay on version 1.16.3 which is the last release that didn't require C++ 20 on macOS.

snnn commented 1 week ago

As long as you need to deploy the code to a different machine, you always need to set the deploy target's OS version. No matter what ONNX Runtime version you use, or no matter the target OS is Windows or MacOS. Because there is no other way to get this information.

ola-ableton commented 1 week ago

I understand that you need to set the deploy target to the minimum OS that you want to support. That wasn't the reason for my issue.

Since https://github.com/microsoft/onnxruntime/commit/0141e27ca1e9954da2630f817709e2eebcd88dde onnxruntime can only target macOS 13.3 or higher due to the introduction of C++ 20 for macOS. That really limits the machines that are supported since macOS 13.3 is not that old. Many users don't upgrade their operating systems regularly, apple still supports macOS 12 for instance - https://endoflife.date/macos.

This limitation is not mentioned in the commit or the release notes for onnxruntime 1.17.0 or higher.

Perhaps this issue doesn't appear if you compile against a different macOS SDK. I have been compiling against the 14.5 SDK that comes with the latest stable Xcode, but if i am not mistaken I don't think your onnxruntime builds of 1.17.0 + are suitable for macOS < 13.3. If that is intended, then it should be mentioned in the release notes. If it's not intended then maybe it's worth reconsidering if it's necessary to compile with C++20 just on macOS, since the other platforms don't use it yet.

I'm happy to be corrected if I am wrong here. Thanks for your work maintaining onnxruntime.

snnn commented 1 week ago

Interesting .. I thought it works fine with macOS 11. Because in our pipeline we set MACOSX_DEPLOYMENT_TARGET to '11.0'. See: https://github.com/microsoft/onnxruntime/blob/main/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml#L34

snnn commented 1 week ago

Our binaries were built on macOS 12 with XCode 14.2. https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md If it doesn't support macOS 12, we wouldn't be able to run the tests.

snnn commented 1 week ago

Could it because your macOS SDK version is too new?

ola-ableton commented 1 week ago

It's possible. I will try and get an older SDK tomorrow and see if compiling against that makes any difference