Skip to content

Commit aa43aab

Browse files
dulmandakhfacebook-github-bot
authored andcommitted
Bump NDK to 21.4.7075529 (#31731)
Summary: This PR bumps NDK_VERSION to 21.4.7075529, and patches FileUtil.cpp from folly based on patch from facebook/folly#1593. We can remove the patch once PR lands in Folly and bump Folly version in RN. FYI, NDK 20 is deprecated and 21 is LTS release. ## Changelog [Android] [Changed] - Bump NDK to 21.4.7075529 Pull Request resolved: #31731 Reviewed By: mdvacca Differential Revision: D29166690 Pulled By: ShikaSD fbshipit-source-id: 0792691404f718aaf5af1369f66f0cba046b4e20
1 parent 512c185 commit aa43aab

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ jobs:
510510
name: Install rsync, zip
511511
command: |
512512
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
513-
apt-get update -y && apt-get install rsync zip -y
513+
apt-get update -y && apt-get install patch rsync zip -y
514514
515515
# Install Buck
516516
- install_buck_tooling
@@ -621,7 +621,7 @@ jobs:
621621
- ANDROID_BUILD_VERSION: 30
622622
- ANDROID_TOOLS_VERSION: 30.0.2
623623
- GRADLE_OPTS: -Dorg.gradle.daemon=false
624-
- NDK_VERSION: 20.1.5948944
624+
- NDK_VERSION: 21.4.7075529
625625
steps:
626626
- checkout
627627

ReactAndroid/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy
9696
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
9797
includeEmptyDirs = false
9898
into("$thirdPartyNdkDir/folly")
99+
doLast {
100+
ant.patch(
101+
patchfile: "src/main/jni/third-party/folly/FileUtil.cpp.patch",
102+
originalFile: "$thirdPartyNdkDir/folly/folly/FileUtil.cpp"
103+
)
104+
}
99105
}
100106

101107
task downloadFmt(dependsOn: createNativeDepsDirectories, type: Download) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--- FileUtil.cpp.orig 2021-06-16 20:53:12.000000000 +0800
2+
+++ FileUtil.cpp 2021-06-16 20:53:37.000000000 +0800
3+
@@ -35,7 +35,26 @@
4+
using namespace fileutil_detail;
5+
6+
int openNoInt(const char* name, int flags, mode_t mode) {
7+
+#if defined(__ANDROID__)
8+
+ // NDK bionic with FORTIFY has this definition:
9+
+ // https://android.googlesource.com/platform/bionic/+/9349b9e51b/libc/include/bits/fortify/fcntl.h
10+
+ // ```
11+
+ // __BIONIC_ERROR_FUNCTION_VISIBILITY
12+
+ // int open(const char* pathname, int flags, mode_t modes, ...) __overloadable
13+
+ // __errorattr(__open_too_many_args_error);
14+
+ // ```
15+
+ // This is originally to prevent open() with incorrect parameters.
16+
+ //
17+
+ // However, combined with folly wrapNotInt, template deduction will fail.
18+
+ // In this case, we create a custom Open lambda to bypass the error.
19+
+ // The solution is referenced from
20+
+ // https://github.com/llvm/llvm-project/commit/0a0e411204a2baa520fd73a8d69b664f98b428ba
21+
+ //
22+
+ auto Open = [&]() { return open(name, flags, mode); };
23+
+ return int(wrapNoInt(Open));
24+
+#else
25+
return int(wrapNoInt(open, name, flags, mode));
26+
+#endif
27+
}
28+
29+
static int filterCloseReturn(int r) {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ org.gradle.daemon=true
44
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
55
org.gradle.parallel=true
66

7-
ANDROID_NDK_VERSION=20.1.5948944
7+
ANDROID_NDK_VERSION=21.4.7075529
88
android.useAndroidX=true
99
kotlin_version=1.4.21

template/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
minSdkVersion = 21
77
compileSdkVersion = 30
88
targetSdkVersion = 30
9-
ndkVersion = "20.1.5948944"
9+
ndkVersion = "21.4.7075529"
1010
}
1111
repositories {
1212
google()

0 commit comments

Comments
 (0)