From ebe939b18aa859eb0f7f265222874c292ed771a4 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 6 Jul 2021 10:34:10 -0700 Subject: [PATCH] Upgrade folly to fix NDK 21 build issue (#31802) Summary: Upgrade folly for the https://github.com/facebook/folly/pull/1593 fix for NDK 21 failure ## Changelog [Android] [Changed] - Upgrade folly to 2021.06.28.00 Pull Request resolved: https://github.com/facebook/react-native/pull/31802 Test Plan: `./gradlew :ReactAndroid:installArchives` `./gradlew packages:rn-tester:android:app:installJscRelease` `./gradlew packages:rn-tester:android:app:installHermesRelease` Reviewed By: RSNara Differential Revision: D29547027 Pulled By: ShikaSD fbshipit-source-id: a10c7c65f459091bd0e7cca750a9b9e067189b73 --- ReactAndroid/build.gradle | 6 ---- ReactAndroid/gradle.properties | 2 +- .../src/main/jni/third-party/folly/Android.mk | 4 ++- .../jni/third-party/folly/FileUtil.cpp.patch | 29 ------------------- 4 files changed, 4 insertions(+), 37 deletions(-) delete mode 100644 ReactAndroid/src/main/jni/third-party/folly/FileUtil.cpp.patch diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 4fb1e8141693a0..80d11371b89d1e 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -96,12 +96,6 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") } includeEmptyDirs = false into("$thirdPartyNdkDir/folly") - doLast { - ant.patch( - patchfile: "src/main/jni/third-party/folly/FileUtil.cpp.patch", - originalFile: "$thirdPartyNdkDir/folly/folly/FileUtil.cpp" - ) - } } task downloadFmt(dependsOn: createNativeDepsDirectories, type: Download) { diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index 1e7e5aa03d0e17..fc55c4075fc2d3 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -17,7 +17,7 @@ SO_LOADER_VERSION=0.10.1 BOOST_VERSION=1_63_0 DOUBLE_CONVERSION_VERSION=1.1.6 -FOLLY_VERSION=2021.04.26.00 +FOLLY_VERSION=2021.06.28.00 FMT_VERSION=6.2.1 LIBEVENT_VERSION=2.1.12 GLOG_VERSION=0.3.5 diff --git a/ReactAndroid/src/main/jni/third-party/folly/Android.mk b/ReactAndroid/src/main/jni/third-party/folly/Android.mk index 469d35aad6e297..dacf2118dc66b6 100644 --- a/ReactAndroid/src/main/jni/third-party/folly/Android.mk +++ b/ReactAndroid/src/main/jni/third-party/folly/Android.mk @@ -86,11 +86,13 @@ LOCAL_SRC_FILES := \ folly/io/async/AsyncTimeout.cpp \ folly/io/async/EventBase.cpp \ folly/io/async/EventBaseBackendBase.cpp \ + folly/io/async/EventBaseLocal.cpp \ folly/io/async/EventHandler.cpp \ folly/io/async/HHWheelTimer.cpp \ folly/io/async/Request.cpp \ folly/io/async/TimeoutManager.cpp \ folly/io/async/VirtualEventBase.cpp \ + folly/lang/Exception.cpp \ folly/memory/MallctlHelper.cpp \ folly/portability/SysMembarrier.cpp \ folly/synchronization/AsymmetricMemoryBarrier.cpp \ @@ -106,7 +108,7 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare +LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -Wno-unused-variable LOCAL_CFLAGS += $(FOLLY_FLAGS) diff --git a/ReactAndroid/src/main/jni/third-party/folly/FileUtil.cpp.patch b/ReactAndroid/src/main/jni/third-party/folly/FileUtil.cpp.patch deleted file mode 100644 index be906b3c1b1a8b..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/folly/FileUtil.cpp.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- FileUtil.cpp.orig 2021-06-16 20:53:12.000000000 +0800 -+++ FileUtil.cpp 2021-06-16 20:53:37.000000000 +0800 -@@ -35,7 +35,26 @@ - using namespace fileutil_detail; - - int openNoInt(const char* name, int flags, mode_t mode) { -+#if defined(__ANDROID__) -+ // NDK bionic with FORTIFY has this definition: -+ // https://android.googlesource.com/platform/bionic/+/9349b9e51b/libc/include/bits/fortify/fcntl.h -+ // ``` -+ // __BIONIC_ERROR_FUNCTION_VISIBILITY -+ // int open(const char* pathname, int flags, mode_t modes, ...) __overloadable -+ // __errorattr(__open_too_many_args_error); -+ // ``` -+ // This is originally to prevent open() with incorrect parameters. -+ // -+ // However, combined with folly wrapNotInt, template deduction will fail. -+ // In this case, we create a custom Open lambda to bypass the error. -+ // The solution is referenced from -+ // https://github.com/llvm/llvm-project/commit/0a0e411204a2baa520fd73a8d69b664f98b428ba -+ // -+ auto Open = [&]() { return open(name, flags, mode); }; -+ return int(wrapNoInt(Open)); -+#else - return int(wrapNoInt(open, name, flags, mode)); -+#endif - } - - static int filterCloseReturn(int r) {