Skip to content

Commit

Permalink
[onnxruntime] fixing Xcode 15.3 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed May 11, 2024
1 parent 3ae0754 commit 7330080
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
64 changes: 47 additions & 17 deletions ports/onnxruntime/fix-sources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,62 @@ index 04f2679..9c4de02 100644
#include <vector>
#include <utility>
diff --git a/onnxruntime/core/common/logging/sinks/ostream_sink.cc b/onnxruntime/core/common/logging/sinks/ostream_sink.cc
index 0db3d87..ae80616 100644
index 0db3d87..ca3867a 100644
--- a/onnxruntime/core/common/logging/sinks/ostream_sink.cc
+++ b/onnxruntime/core/common/logging/sinks/ostream_sink.cc
@@ -23,9 +23,10 @@ struct Color {
@@ -45,7 +45,12 @@ void OStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger
}
#endif

void OStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id, const Capture& message) {
+#if !defined(__APPLE__) // Xcode 15.3+
// operator for formatting of timestamp in ISO8601 format including microseconds
using date::operator<<;
-
- msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
+#if defined(__APPLE__) // Xcode 15.3 errors with ambiguous 'operator <<'
+ msg << std::format("{}", timestamp);
+#else
+ msg << timestamp;
+#endif
// Two options as there may be multiple calls attempting to write to the same sink at once:
// 1) Use mutex to synchronize access to the stream.
// 2) Create the message in an ostringstream and output in one call.
+ msg << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
<< message.Location().ToString() << "] " << message.Message();

#ifndef ORT_MINIMAL_BUILD
diff --git a/onnxruntime/core/platform/apple/logging/apple_log_sink.mm b/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
index 8dbd8ee..6eef0c7 100644
index 8dbd8ee..1500df3 100644
--- a/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
+++ b/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
@@ -13,7 +13,9 @@
namespace logging {

@@ -15,7 +15,12 @@
void AppleLogSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id, const Capture& message) {
+#if !defined(__APPLE__) // Xcode 15.3+
using date::operator<<;
+#endif
std::ostringstream msg;
msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
- msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
+#if defined(__APPLE__) // Xcode 15.3 errors with ambiguous 'operator <<'
+ msg << std::format("{}", timestamp);
+#else
+ msg << timestamp;
+#endif
+ msg << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
<< message.Location().ToString() << "] " << message.Message();
NSLog(@"%s", msg.str().c_str());
}
diff --git a/onnxruntime/core/common/logging/sinks/ostream_sink.cc b/onnxruntime/core/common/logging/sinks/ostream_sink.cc
index ca3867a..0ab3560 100644
--- a/onnxruntime/core/common/logging/sinks/ostream_sink.cc
+++ b/onnxruntime/core/common/logging/sinks/ostream_sink.cc
@@ -4,6 +4,7 @@
#include "core/common/logging/sinks/ostream_sink.h"
#include "date/date.h"

+#include <format>
namespace onnxruntime {
namespace logging {

diff --git a/onnxruntime/core/platform/apple/logging/apple_log_sink.mm b/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
index 1500df3..08db426 100644
--- a/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
+++ b/onnxruntime/core/platform/apple/logging/apple_log_sink.mm
@@ -6,6 +6,7 @@
#import <Foundation/Foundation.h>

#include <sstream>
+#include <format>

#include "date/date.h"

1 change: 0 additions & 1 deletion test/self-hosted.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"openvino",
"directml",
"python",
"training",
"xnnpack"
],
"platform": "x64 & windows"
Expand Down

0 comments on commit 7330080

Please sign in to comment.