Commit 4d5b7ad4 authored by Filipe Brandenburger's avatar Filipe Brandenburger Committed by Facebook GitHub Bot

Detect and enable C++ couroutine support on CMake build with GCC

Summary:
This change updates the CMake config to detect whether GCC's `-fcoroutines` flag is supported and enable it for the build. This is required to enable support for Folly coroutines.

Followed the instructions in GCC page about C++ coroutines to get them enabled.
https://gcc.gnu.org/wiki/cxx-coroutines

NOTE: This Wiki page used to indicate that exceptions had to be disabled to enable subroutines, but this only applied to experimental support for coroutines and it's no longer the case.

This was uncovered by the fbthrift build, which needs Folly coroutines to implement streaming. A new fbthrift test using a stream type uncovered this missing feature in our build on Fedora.

Reviewed By: yfeldblum

Differential Revision: D30026779

fbshipit-source-id: 3324c2fc52fe5db793bdaba9c81f41bfe6ef2242
parent fb5c25d9
......@@ -234,6 +234,23 @@ if (NOT ${LIBAIO_FOUND} AND NOT ${LIBURING_FOUND})
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_cxx_compiler_flag(-fcoroutines COMPILER_HAS_F_COROUTINES)
if (COMPILER_HAS_F_COROUTINES)
message(
STATUS
"GCC has support for C++ coroutines, setting flag for Folly build."
)
add_compile_options(-fcoroutines)
else()
message(
STATUS
"GCC does not have support for C++ coroutines, "
"disabling Folly coroutine support."
)
endif()
endif()
if (${LIBSODIUM_FOUND})
string(FIND "${CMAKE_LIBRARY_ARCHITECTURE}" "x86_64" IS_X86_64_ARCH)
if (${IS_X86_64_ARCH} STREQUAL "-1")
......
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