Skip to content

Commit

Permalink
C++ 20 all the things (facebook#39454)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#39454

1. Build with C++ 20 everywhere.
2. Update folly by three months to avoid a warning (we are still multiple years behind).
3. Adds some headers now included to the folly podspec
4. Replaces a deprecated atomic usage with equivalent.
5. Fixes deprecated implicit capturing `this` by value in lambdas

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49271685

fbshipit-source-id: bc0707df5451cad3ca495e716a245a648f6dba47
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Sep 14, 2023
1 parent 78bc863 commit 7b6bb75
Show file tree
Hide file tree
Showing 126 changed files with 264 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ target_compile_options(
-DLOG_TAG=\\"ReactNative\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -165,7 +165,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -244,7 +244,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -330,7 +330,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -416,7 +416,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -510,7 +510,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -596,7 +596,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down Expand Up @@ -690,7 +690,7 @@ target_compile_options(
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"OTHER_CPLUSPLUSFLAGS" => other_cflags,
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"DEFINES_MODULE" => "YES"
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -47,7 +47,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTBlob"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Image/React-RCTImage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -48,7 +48,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTImage"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.framework = ["Accelerate", "UIKit"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -51,7 +51,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTLinking"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -47,7 +47,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTAnimation"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(" ")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -51,7 +51,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTNetwork"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.frameworks = "MobileCoreServices"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -48,7 +48,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTPushNotification"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.framework = "UserNotifications"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -51,7 +51,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTSettings"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTTypeSafety"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/Libraries/TypeSafety\""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

header_search_paths = [
"\"$(PODS_ROOT)/RCT-Folly\"",
Expand Down Expand Up @@ -50,7 +50,7 @@ Pod::Spec.new do |s|
s.header_dir = "RCTVibration"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.frameworks = "AudioToolbox"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'
socket_rocket_version = '0.6.0'
boost_compiler_flags = '-Wno-documentation'

Expand Down Expand Up @@ -77,7 +77,7 @@ Pod::Spec.new do |s|
"HEADER_SEARCH_PATHS" => header_search_paths,
"DEFINES_MODULE" => "YES",
"GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"FRAMEWORK_SEARCH_PATHS" => frameworks_search_paths.join(" ")
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'
socket_rocket_version = '0.6.0'

header_search_paths = [
Expand Down Expand Up @@ -46,7 +46,7 @@ Pod::Spec.new do |s|
s.header_dir = "CoreModules"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => header_search_paths.join(" ")
}
s.framework = "UIKit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'

Pod::Spec.new do |s|
s.name = "FBReactNativeSpec"
Expand All @@ -38,7 +38,7 @@ Pod::Spec.new do |s|

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\""
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
folly_version = '2021.10.25.00'
boost_compiler_flags = '-Wno-documentation'

header_search_paths = [
Expand Down Expand Up @@ -69,7 +69,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" + " " + folly_flags,
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
}.merge!(ENV['USE_FRAMEWORKS'] != nil ? {
"PUBLIC_HEADERS_FOLDER_PATH" => "$(CONTENTS_FOLDER_PATH)/Headers/React"
}: {})
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/third-party.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
// LICENSE file in the root directory of this source tree.
//

HEADER_SEARCH_PATHS = $(SRCROOT)/../third-party/boost_1_76_0 $(SRCROOT)/../third-party/folly-2021.07.22.00 $(SRCROOT)/../third-party/glog-0.3.5/src
HEADER_SEARCH_PATHS = $(SRCROOT)/../third-party/boost_1_76_0 $(SRCROOT)/../third-party/folly-2021.10.25.00 $(SRCROOT)/../third-party/glog-0.3.5/src
OTHER_CFLAGS = -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ target_compile_options(${CMAKE_PROJECT_NAME}
# due to use migrating away from
# #include <react/renderer/graphics/conversions.h>
# This can be removed for React Native 0.73
-Wno-error=cpp
-Wno-error=cpp
-fexceptions
-frtti
-std=c++17
-std=c++20
-DWITH_INSPECTOR=1
-DLOG_TAG=\"ReactNative\")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif(CCACHE_FOUND)

# Make sure every shared lib includes a .note.gnu.build-id header
add_link_options(-Wl,--build-id)
add_compile_options(-Wall -Werror -std=c++17)
add_compile_options(-Wall -Werror -std=c++20)

function(add_react_android_subdir relative_path)
add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path})
Expand Down Expand Up @@ -188,7 +188,7 @@ add_executable(reactnative_unittest
-Werror
-fexceptions
-frtti
-std=c++17
-std=c++20
-DHERMES_ENABLE_DEBUGGER)

target_link_libraries(reactnative_unittest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ target_compile_options(
-DLOG_TAG=\"Fabric\"
-fexceptions
-frtti
-std=c++17
-std=c++20
-Wall
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_compile_options(
hermes_executor
PRIVATE
$<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>
-std=c++17
-std=c++20
-fexceptions
)
target_include_directories(hermes_executor PRIVATE .)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ file(GLOB reactnativejni_SRC CONFIGURE_DEPENDS *.cpp)
add_compile_options(
-fexceptions
-Wno-unused-lambda-capture
-std=c++17
-std=c++20
-DWITH_INSPECTOR=1)

######################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\")
add_compile_options(-fexceptions -frtti -std=c++20 -Wall -DLOG_TAG=\"Fabric\")

file(GLOB mapbuffer_SRC CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/react/common/mapbuffer/*.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"ReactNative\")
add_compile_options(-fexceptions -frtti -std=c++20 -Wall -DLOG_TAG=\"ReactNative\")

file(GLOB react_newarchdefaults_SRC CONFIGURE_DEPENDS *.cpp)

Expand Down
Loading

0 comments on commit 7b6bb75

Please sign in to comment.