Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enabling <coroutine> from std library for folly when c++ version is 20
Summary: When upgrading the C++ version from 17 -> 20 for fbcode and xplat, the folly library coroutine depends on the <coroutine> header which has been added to the std library in v20 as opposed to <experimental/coroutine> header. This diff ensures that the given a c++ version, the right coroutine header is always selected Problem: The `LLVM_COROUTINES` flag is used to enable the folly coroutines library, and based on the c++ version, it should either include the <coroutine> (v20) or <experimental/coroutine> (v17) header. The current issue when upgrading however occurs in the if directive changed within this diff; It checks `!defined(LLVM_COROUTINES)` when determining which library to include. Because it has to be defined for folly to utilize coroutines, the check always fails, resulting in the experimental coroutine always being included. This results in compilation errors when it is not included in the header files for c++20. So a reasonable approach is needed to ensure that the right coroutine header, when present, is selected. Proposed Solution: - Within the if directive, check to determine if the current c++ version is 20 and above. This ensures that the flag `FOLLY_USE_STD_COROUTINE` is set if so, and folly uses the coroutines from the std library. Potential Issue: Not all c++20 toolchains might have coroutines (like bespoke embedded hardware compilers) - *Utilize the `LLVM_COROUTINES_CPP20` flag which would be set in the buckconfig to indicate that the toolchain supports c++20 coroutines. - Use either of the available coroutine feature macros `__cpp_impl_coroutine` or `__cpp_lib_coroutine` to check if coroutines are implemented in the standard library Reviewed By: Gownta Differential Revision: D68659268 fbshipit-source-id: 689570387c160bf71f362ceab23489c75d590e67
- Loading branch information