Remove the coroutines workaround from Nearby and drop experimental/coroutines.

In Prod LLVM release branch 515643669.1 ( cl/517696539 ) the experimental coroutines implementation is dropped. The `experimental/coroutines` header is removed.

Nearby doesn't use coroutines, but it uses libraries that depend on the existence of coroutine function definitions. Specifically, WinRT needs certain coroutine function definitions in order to compile.

Ordinarily, WinRT relied on the coroutine function definitions provided in the MSVC STL' `experimental/coroutines` header. The introduction of libc++ complicated this dependency for Nearby, because libc++' `experimental/coroutines` header took the place of the MSVC version, and (correctly, for C++17) provided none of the coroutine function definitions.

To resolve these issues, we implemented a patch of WinRT. The patch provided placeholder definitions, which allowed WinRT to pass compilation. This patch was submitted in cl/495104919. The patch was necessary to enable the Nearby migration from MSVC STL to libc++.

--

The removal of `experimental/coroutines` from libc++ makes this patch unnecessary. However, the patch will not compile without libc++' `experimental/coroutines` header.

The presence of libc++' `experimental/coroutines` header had prevented the corresponding MSVC STL' header from defining the functions for which the patch makes placeholders. Without the libc++' `experimental/coroutines` header, the MSVC STL header is employed and makes these definitions. The patch then redefines these functions, which causes a compilation failure.

--

This CL makes two changes: 1) It eliminates the patch, and 2) It eliminates the libc++ `experimental/coroutines` file from the Lexan libc++ distribution. This allows Nearby to function identically before and after the release of Lexan 515643669.1.

This change prevents a break from occurring when Lexan 515643669.1 is released.

PiperOrigin-RevId: 518119913
This commit is contained in:
hai007
2023-03-20 17:20:47 -07:00
committed by Copybara-Service
parent a7a3eb8a92
commit d0b258971d
3 changed files with 0 additions and 72 deletions
@@ -1,38 +0,0 @@
*** third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h 2022-12-07 15:29:09.000000000 -0500
--- third_party/nearby/internal/platform/implementation/windows/generated/winrt/base-no-coroutines.h 2022-12-07 15:28:53.000000000 -0500
***************
*** 35,40 ****
--- 35,67 ----
#include <format>
#endif
+ #if defined(_LIBCPP_VERSION) && __cplusplus < 202002
+ // If the C++ standard is cxx17, coroutines are not available in libc++.
+ // To compile WinRT without coroutines, define some placeholder types.
+ // These placeholders should not be used. If they are used, they should fail.
+ namespace std::experimental {
+ template <typename T = void>
+ struct coroutine_handle {
+ coroutine_handle() { throw std::logic_error("Not implemented."); }
+ coroutine_handle(std::nullptr_t __h) {
+ throw std::logic_error("Not implemented.");
+ }
+ static coroutine_handle from_address(void*) {
+ throw std::logic_error("Not implemented.");
+ }
+ void operator()() const { throw std::logic_error("Not implemented."); }
+ void* address() const { throw std::logic_error("Not implemented."); }
+ };
+
+ class suspend_always {};
+ class suspend_never {};
+
+ template <typename _Result, typename...>
+ struct coroutine_traits;
+
+ } // namespace std::experimental
+ #endif
+
#ifdef __cpp_lib_coroutine
#include <coroutine>
@@ -1,7 +0,0 @@
#!/bin/bash
patch \
--forward \
-r - \
third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h \
third_party/nearby/internal/platform/implementation/windows/generated/base-no-coroutines.patch
@@ -35,33 +35,6 @@
#include <format>
#endif
#if defined(_LIBCPP_VERSION) && __cplusplus < 202002
// If the C++ standard is cxx17, coroutines are not available in libc++.
// To compile WinRT without coroutines, define some placeholder types.
// These placeholders should not be used. If they are used, they should fail.
namespace std::experimental {
template <typename T = void>
struct coroutine_handle {
coroutine_handle() { throw std::logic_error("Not implemented."); }
coroutine_handle(std::nullptr_t __h) {
throw std::logic_error("Not implemented.");
}
static coroutine_handle from_address(void*) {
throw std::logic_error("Not implemented.");
}
void operator()() const { throw std::logic_error("Not implemented."); }
void* address() const { throw std::logic_error("Not implemented."); }
};
class suspend_always {};
class suspend_never {};
template <typename _Result, typename...>
struct coroutine_traits;
} // namespace std::experimental
#endif
#ifdef __cpp_lib_coroutine
#include <coroutine>