From 3e12f24aef468b6ff75a03c35664051e13639109 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 29 Jul 2026 14:35:02 +0000 Subject: [PATCH] Fix dynamic/String.h on libstdc++ old ABI (no std::pmr::string) libstdc++'s old (COW) ABI provides the std::pmr machinery but not std::pmr::basic_string, so String.h failed to compile on macOS 10.6 ppc with gcc 16. Back String with plain std::string there, ignoring the memory resource; constructor signatures are unchanged. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01FEKbRBcPZr4mY4ZZJ3K6SS --- thrift/lib/cpp2/dynamic/String.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/thrift/lib/cpp2/dynamic/String.h b/thrift/lib/cpp2/dynamic/String.h index 32468b0a..fb3552a7 100644 --- thrift/lib/cpp2/dynamic/String.h +++ thrift/lib/cpp2/dynamic/String.h @@ -20,6 +20,13 @@ #include #include +// libstdc++'s old (COW) ABI provides std::pmr containers but not +// std::pmr::basic_string; fall back to std::string and ignore +// the memory resource there. +#if defined(__GLIBCXX__) && !_GLIBCXX_USE_CXX11_ABI +#define THRIFT_DYNAMIC_STRING_NO_PMR 1 +#endif + namespace apache::thrift::dynamic { /** @@ -30,10 +37,16 @@ class String final { public: // Constructors String() : String(nullptr) {} +#ifdef THRIFT_DYNAMIC_STRING_NO_PMR + explicit String(std::pmr::memory_resource*) {} + explicit String(std::string_view sv, std::pmr::memory_resource* = nullptr) + : data_(sv) {} +#else explicit String(std::pmr::memory_resource* mr) : data_(mr ? mr : std::pmr::get_default_resource()) {} explicit String(std::string_view sv, std::pmr::memory_resource* mr = nullptr) : data_(sv, mr ? mr : std::pmr::get_default_resource()) {} +#endif // Copy and move String(const String&) = default; @@ -77,7 +90,11 @@ class String final { } private: +#ifdef THRIFT_DYNAMIC_STRING_NO_PMR + std::string data_; +#else std::pmr::string data_; +#endif }; } // namespace apache::thrift::dynamic