Commit 512af68a by James Y Knight Committed by Copybara-Service

Correct std::optional/variant/any auto-detection for Apple platforms.

In Xcode 14.3, Apple modified the OS versions which support these
three types to exclude iOS 11 and watchOS 4. Update abseil accordingly.

Those versions of the OS did _not_ actually support the types, and any
binaries which used these types, built with prior Xcode versions,
would've crashed on startup on an actual iOS 11 or watchOS 4 device
due to missing symbols. As of Xcode 14.3, using them is now, correctly,
a build failure.

This change also drops the conditionals for pre-Xcode 12.5, as that is
no longer a supported version.

PiperOrigin-RevId: 546005629
Change-Id: Ib0430307ac2ada4910f07c54cfd6e99db8ca1905
parent a0299fa2
...@@ -522,41 +522,29 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || ...@@ -522,41 +522,29 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#error "absl endian detection needs to be set up for your compiler" #error "absl endian detection needs to be set up for your compiler"
#endif #endif
// macOS < 10.13 and iOS < 11 don't let you use <any>, <optional>, or <variant> // macOS < 10.13 and iOS < 12 don't support <any>, <optional>, or <variant>
// even though the headers exist and are publicly noted to work, because the // because the libc++ shared library shipped on the system doesn't have the
// libc++ shared library shipped on the system doesn't have the requisite // requisite exported symbols. See
// exported symbols. See https://github.com/abseil/abseil-cpp/issues/207 and // https://github.com/abseil/abseil-cpp/issues/207 and
// https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
// //
// libc++ spells out the availability requirements in the file // libc++ spells out the availability requirements in the file
// llvm-project/libcxx/include/__config via the #define // llvm-project/libcxx/include/__config via the #define
// _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. // _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. The set of versions has been
// // modified a few times, via
// Unfortunately, Apple initially mis-stated the requirements as macOS < 10.14
// and iOS < 12 in the libc++ headers. This was corrected by
// https://github.com/llvm/llvm-project/commit/7fb40e1569dd66292b647f4501b85517e9247953 // https://github.com/llvm/llvm-project/commit/7fb40e1569dd66292b647f4501b85517e9247953
// which subsequently made it into the XCode 12.5 release. We need to match the // and
// old (incorrect) conditions when built with old XCode, but can use the // https://github.com/llvm/llvm-project/commit/0bc451e7e137c4ccadcd3377250874f641ca514a
// corrected earlier versions with new XCode. // The second has the actually correct versions, thus, is what we copy here.
#if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \ #if defined(__APPLE__) && \
((_LIBCPP_VERSION >= 11000 && /* XCode 12.5 or later: */ \ ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 110000) || \ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 40000) || \ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))
__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 110000))) || \
(_LIBCPP_VERSION < 11000 && /* Pre-XCode 12.5: */ \
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))))
#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1 #define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
#else #else
#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0 #define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment