Skip to content

Commit a56d406

Browse files
committed
Disable folly coroutines for library pods in install_modules_dependencies
Libraries that set their own folly compiler flags (e.g. -DFOLLY_NO_CONFIG without -DFOLLY_CFG_NO_COROUTINES=1) enable folly coroutines under C++20. Since #58711, RCTTurboModule.h transitively includes folly/dynamic.h, so these libraries fail to build with 'folly/coro/Coroutine.h' file not found, because ReactNativeDependencies does not ship the folly/coro headers. Always append -DFOLLY_CFG_NO_COROUTINES=1 to the compiler flags set by install_modules_dependencies.
1 parent 44ffdba commit a56d406

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_installModulesDependencies_whenNewArchEnabledAndNewArchAndNoSearchPaths
130130
NewArchitectureHelper.install_modules_dependencies(spec, true, '2024.10.14.00')
131131

132132
# Assert
133-
assert_equal("-DRCT_NEW_ARCH_ENABLED=1", spec.compiler_flags)
133+
assert_equal("-DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags)
134134
assert_equal(
135135
[
136136
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
@@ -206,6 +206,7 @@ def test_installModulesDependencies_whenNewArchDisabledAndSearchPathsAndCompiler
206206

207207
# Assert
208208
assert_equal("#{NewArchitectureHelper.folly_compiler_flags}", Helpers::Constants.folly_config[:compiler_flags])
209+
assert_equal("-DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags)
209210
assert_equal([*other_flags_arr, '"$(PODS_ROOT)/Headers/Private/Yoga"', '$(PODS_ROOT)/glog', '$(PODS_ROOT)/boost', '$(PODS_ROOT)/DoubleConversion', '$(PODS_ROOT)/fast_float/include', '$(PODS_ROOT)/fmt/include', '$(PODS_ROOT)/SocketRocket', '$(PODS_ROOT)/RCT-Folly'], spec.pod_target_xcconfig["HEADER_SEARCH_PATHS"])
210211
assert_equal("c++20", spec.pod_target_xcconfig["CLANG_CXX_LANGUAGE_STANDARD"])
211212
assert_equal(

‎packages/react-native/scripts/cocoapods/new_architecture.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = He
107107
}
108108
end
109109
header_search_paths_string = header_search_paths.join(" ")
110-
spec.compiler_flags = compiler_flags.empty? ? self.computeFlags(new_arch_enabled).strip! : "#{compiler_flags} #{self.computeFlags(new_arch_enabled)}"
110+
# Libraries may pass their own folly flags, so always disable folly coroutines:
111+
# ReactNativeDependencies does not ship the folly/coro headers.
112+
module_compiler_flags = "#{self.computeFlags(new_arch_enabled).strip} -DFOLLY_CFG_NO_COROUTINES=1".strip
113+
spec.compiler_flags = compiler_flags.empty? ? module_compiler_flags : "#{compiler_flags} #{module_compiler_flags}"
111114
current_config["HEADER_SEARCH_PATHS"] = current_headers.empty? ?
112115
header_search_paths_string :
113116
"#{current_headers} #{header_search_paths_string}"

0 commit comments

Comments
 (0)