Skip to content
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

[Build] MacOS Build Script Fails With Compile Error #20137

Closed
afantino951 opened this issue Mar 29, 2024 · 1 comment
Closed

[Build] MacOS Build Script Fails With Compile Error #20137

afantino951 opened this issue Mar 29, 2024 · 1 comment
Labels
build build issues; typically submitted using template

Comments

@afantino951
Copy link
Contributor

Describe the issue

I am attempting to build according to the build documentation, but receive the below compile errors with the build script. I tried on both the main branch and the v1.17.1 release with the same output.

When I comment out the responsible lines according this patch file: commented.patch, it builds correctly. (But obviously fails the test suite).

Here is my clang version output.

$ clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

This is my first issue. If I am missing anything, please let me know. Thank you for your time.

Urgency

Not too urgent, but appreciate the help.

Target platform

MacOS M2 arm64

Build script

./build.sh --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync
and
./build.sh --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64

Error / output

[ 46%] Building CXX object CMakeFiles/onnxruntime_common.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/platform/posix/env.cc.o
/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/common/logging/sinks/ostream_sink.cc:48:7: error: use of overloaded operator '<<' is ambiguous (with operand types 'std::ostringstream' (aka 'basic_ostringstream<char>') and 'const Timestamp' (aka 'const time_point<std::chrono::system_clock>'))
  msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
  ~~~ ^  ~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__chrono/ostream.h:46:1: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>, _Duration = std::chrono::duration<long long, std::ratio<1, 1000000>>]
operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_time<_Duration> __tp) {
^
/Users/afa/Documents/Personal/onnxruntime/build/MacOS/RelWithDebInfo/_deps/date-src/include/date/date.h:4212:1: note: candidate function [with CharT = char, Traits = std::char_traits<char>, Duration = std::chrono::duration<long long, std::ratio<1, 1000000>>]
operator<<(std::basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp)
^
[ 46%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/get_execution_providers.cc.o
1 error generated.
make[2]: *** [CMakeFiles/onnxruntime_common.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/common/logging/sinks/ostream_sink.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 46%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/partitioning_utils.cc.o
[ 53%] Built target onnxruntime_optimizer
[ 53%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/utils.cc.o
[ 53%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/activation/activations.cc.o
[ 53%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/if.cc.o
[ 53%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/loop.cc.o
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/scan_8.cc.o
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/scan_9.cc.o
/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/platform/apple/logging/apple_log_sink.mm:18:7: error: use of overloaded operator '<<' is ambiguous (with operand types 'std::ostringstream' (aka 'basic_ostringstream<char>') and 'const Timestamp' (aka 'const time_point<std::chrono::system_clock>'))
  msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
  ~~~ ^  ~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__chrono/ostream.h:46:1: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>, _Duration = std::chrono::duration<long long, std::ratio<1, 1000000>>]
operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_time<_Duration> __tp) {
^
/Users/afa/Documents/Personal/onnxruntime/build/MacOS/RelWithDebInfo/_deps/date-src/include/date/date.h:4212:1: note: candidate function [with CharT = char, Traits = std::char_traits<char>, Duration = std::chrono::duration<long long, std::ratio<1, 1000000>>]
operator<<(std::basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp)
^
1 error generated.
make[2]: *** [CMakeFiles/onnxruntime_common.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/platform/apple/logging/apple_log_sink.mm.o] Error 1
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/scan_utils.cc.o
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/controlflow/utils.cc.o
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/cpu_execution_provider.cc.o
[ 54%] Building CXX object CMakeFiles/onnxruntime_providers.dir/Users/afa/Documents/Personal/onnxruntime/onnxruntime/core/providers/cpu/cpu_provider_factory.cc.o
make[1]: *** [CMakeFiles/onnxruntime_common.dir/all] Error 2

The build continues until linking libonnxruntime_providers.a, thent the python script output is:

[ 69%] Built target onnxruntime_providers
make: *** [all] Error 2
Traceback (most recent call last):
  File "/Users/afa/Documents/Personal/onnxruntime/tools/ci_build/build.py", line 2887, in <module>
    sys.exit(main())
  File "/Users/afa/Documents/Personal/onnxruntime/tools/ci_build/build.py", line 2779, in main
    build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, args.target)
  File "/Users/afa/Documents/Personal/onnxruntime/tools/ci_build/build.py", line 1659, in build_targets
    run_subprocess(cmd_args, env=env)
  File "/Users/afa/Documents/Personal/onnxruntime/tools/ci_build/build.py", line 839, in run_subprocess
    return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env)
  File "/Users/afa/Documents/Personal/onnxruntime/tools/python/util/run.py", line 49, in run
    completed_process = subprocess.run(
  File "/Users/afa/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/opt/homebrew/bin/cmake', '--build', '/Users/afa/Documents/Personal/onnxruntime/build/MacOS/RelWithDebInfo', '--config', 'RelWithDebInfo', '--', '-j12']' returned non-zero exit status 2.

Visual Studio Version

N/A (xcode-select version 2406.)

GCC / Compiler Version

Apple clang version 15.0.0 (clang-1500.3.9.4)

@afantino951 afantino951 added the build build issues; typically submitted using template label Mar 29, 2024
@afantino951
Copy link
Contributor Author

Ok I think I found the issue. The dependency date/date.h conflicts with the C++20 standard, and the maintainer seems adverse to updating this.

Will start looking into solutions.

tianleiwu pushed a commit that referenced this issue Apr 3, 2024
### Description
For C++ standards >= 20, use `std::chrono::operator<<` in place of
`date::operator<<` to fix ambiguous operator compile error.

### Motivation and Context
The external dependency HowardHinnant/date has a conflict with
std::chrono for >=C++20.
Solves #20137
rvinluan-sidefx pushed a commit to sideeffects/onnxruntime that referenced this issue Apr 26, 2024
### Description
For C++ standards >= 20, use `std::chrono::operator<<` in place of
`date::operator<<` to fix ambiguous operator compile error.

### Motivation and Context
The external dependency HowardHinnant/date has a conflict with
std::chrono for >=C++20.
Solves microsoft#20137
TedThemistokleous pushed a commit to TedThemistokleous/onnxruntime that referenced this issue May 7, 2024
### Description
For C++ standards >= 20, use `std::chrono::operator<<` in place of
`date::operator<<` to fix ambiguous operator compile error.

### Motivation and Context
The external dependency HowardHinnant/date has a conflict with
std::chrono for >=C++20.
Solves microsoft#20137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

1 participant