Skip to content

Commit

Permalink
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 13703a5 commit ddb4c01
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions ports/onnxruntime/fix-sources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,38 @@ 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__) && (__clang_major__ >= 15) && (__clang_minor__ >= 0) // 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__) && (__clang_major__ >= 15) && (__clang_minor__ >= 0) // 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());
}

0 comments on commit ddb4c01

Please sign in to comment.