diff -NaurdwB ./c10/util/Exception.cpp ./c10/util/Exception.cpp --- ./c10/util/Exception.cpp 2026-07-22 13:47:49 +++ ./c10/util/Exception.cpp 2026-07-22 14:03:50 @@ -9,16 +9,35 @@ #include #include +/* +#============================================================================== +# 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, common/init). See also Logging.cpp in this directory. #ifdef C10_USE_GLOG -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 #endif namespace c10 { @@ -265,7 +284,9 @@ // During static initialization (before InitGoogleLogging), glog's global // flags may not be constructed yet. Accessing them causes SIOF crashes // (T253115013, D96553733). Fall back to stderr in that case. - if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized()) { + // See 'Patch to fix' comment above + // if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized()) { + if (!::google::IsGoogleLoggingInitialized()) { std::cerr << warning.source_location().file << ':' << warning.source_location().line << ": Warning: " << warning.msg() << " (function " diff -NaurdwB ./c10/util/Logging.cpp ./c10/util/Logging.cpp --- ./c10/util/Logging.cpp 2026-07-22 13:53:45 +++ ./c10/util/Logging.cpp 2026-07-22 13:54:02 @@ -385,15 +385,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 { @@ -401,7 +420,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);