Files
macports-ports/python/py-pytorch/files/patch-glog-init-check.diff

54 lines
2.0 KiB
Diff

--- ./c10/util/Logging.cpp 2025-11-03 12:59:30
+++ ./c10/util/Logging.cpp 2025-11-03 13:04:47
@@ -298,15 +298,34 @@
google::GLOG_WARNING,
"The minimum log level that caffe2 will output.");
+/*
+#==============================================================================
+# Patch to fix reference to google-glog's IsGoogleLoggingInitialized().
+# In versions prior to 0.5.0, that function was in namespace
+# 'google::glog_internal_namespace_'. Then the function was hidden in 0.5.0,
+# breaking dependents which rely on it.
+#
+# Meanwhile, google-glog has an upstream fix, which exposes that API via
+# public namespace 'google'. (And MacPorts includes that in our 'google-glog'
+# port.)
+#
+# As for PyTorch, it still relies on the internal namespace, which doesn't
+# work with google-glob 0.5.0+. So, patch to utilize public API, until PyTorch
+# upstream provides a formal fix.
+#
+# -CNielsen 2022-02-16
+#==============================================================================
+*/
+
// Google glog's api does not have an external function that allows one to check
// if glog is initialized or not. It does have an internal function - so we are
// declaring it here. This is a hack but has been used by a bunch of others too
// (e.g. Torch).
-namespace google {
-namespace glog_internal_namespace_ {
-bool IsGoogleLoggingInitialized();
-} // namespace glog_internal_namespace_
-} // namespace google
+// namespace google {
+// namespace glog_internal_namespace_ {
+// bool IsGoogleLoggingInitialized();
+// } // namespace glog_internal_namespace_
+// } // namespace google
namespace c10 {
namespace {
@@ -314,7 +333,9 @@
void initGoogleLogging(char const* name) {
#if !defined(_MSC_VER)
// This trick can only be used on UNIX platforms
- if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
+ // See 'Patch to fix' comment above
+ // if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
+ if (!::google::IsGoogleLoggingInitialized())
#endif
{
::google::InitGoogleLogging(name);