Note: also partially backports 44a74127954d ("Remove checks for C++ standard versions C++17 and below") From f7c8ff511c30dc4310a72b3da4b4a345efe1fba0 Mon Sep 17 00:00:00 2001 From: Tor Arne Vestbø Date: Wed, 7 Jun 2023 02:31:42 +0200 Subject: [PATCH] Opt out of standard library memory_resource on macOS < 14 and iOS < 17 Although the header is available, and the compiler reports that the standard library supports memory_resource, the feature is only available on macOS 14 and iOS 17, as reported by https://developer.apple.com/xcode/cpp/ As long as our deployment target is lower we can't unconditionally use this feature. It's not clear whether the expectation is that consumers of the standard library on these platforms will have to runtime check their uses of these APIs. Includes e84c0df50f51c61aa49b47823582b0f8de406e3d for fixing missing line continuations. Task-number: QTBUG-114316 Change-Id: I50c1425334b9b9842b253442e2b3aade637783ea --- src/corelib/global/qcompilerdetection.h | 20 +++++++++++++------- src/corelib/tools/qduplicatetracker_p.h | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h --- src/corelib/global/qcompilerdetection.h +++ src/corelib/global/qcompilerdetection.h @@ -1050,16 +1050,22 @@ # endif // !_HAS_CONSTEXPR # endif // !__GLIBCXX__ && !_LIBCPP_VERSION # endif // Q_OS_QNX -# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \ - && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) +# if defined(Q_CC_CLANG) && defined(Q_OS_DARWIN) +# if defined(__GNUC_LIBSTD__) && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) // Apple has not updated libstdc++ since 2007, which means it does not have // or std::move. Let's disable these features -# undef Q_COMPILER_INITIALIZER_LISTS -# undef Q_COMPILER_RVALUE_REFS -# undef Q_COMPILER_REF_QUALIFIERS +# undef Q_COMPILER_INITIALIZER_LISTS +# undef Q_COMPILER_RVALUE_REFS +# undef Q_COMPILER_REF_QUALIFIERS // Also disable , since it's clearly not there -# undef Q_COMPILER_ATOMICS -# endif +# undef Q_COMPILER_ATOMICS +# endif +# if defined(__cpp_lib_memory_resource) \ + && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000) \ + || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 170000)) +# undef __cpp_lib_memory_resource // Only supported on macOS 14 and iOS 17 +# endif +# endif // defined(Q_CC_CLANG) && defined(Q_OS_DARWIN) # if defined(Q_CC_CLANG) && defined(Q_CC_INTEL) && Q_CC_INTEL >= 1500 // ICC 15.x and 16.0 have their own implementation of std::atomic, which is activated when in Clang mode // (probably because libc++'s on OS X failed to compile), but they're missing some diff --git a/src/corelib/tools/qduplicatetracker_p.h b/src/corelib/tools/qduplicatetracker_p.h --- src/corelib/tools/qduplicatetracker_p.h +++ src/corelib/tools/qduplicatetracker_p.h @@ -52,7 +52,7 @@ #include -#if QT_HAS_INCLUDE() && __cplusplus > 201402L +#ifdef __cpp_lib_memory_resource # include # include #else