Skip to content

Commit

Permalink
Bump NDK to 21.4.7075529 (#31731)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dulmandakh authored and facebook-github-bot committed Jun 17, 2021
1 parent 512c185 commit aa43aab
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ jobs:
name: Install rsync, zip
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
apt-get update -y && apt-get install rsync zip -y
apt-get update -y && apt-get install patch rsync zip -y
# Install Buck
- install_buck_tooling
Expand Down Expand Up @@ -621,7 +621,7 @@ jobs:
- ANDROID_BUILD_VERSION: 30
- ANDROID_TOOLS_VERSION: 30.0.2
- GRADLE_OPTS: -Dorg.gradle.daemon=false
- NDK_VERSION: 20.1.5948944
- NDK_VERSION: 21.4.7075529
steps:
- checkout

Expand Down
6 changes: 6 additions & 0 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ 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) {
Expand Down
29 changes: 29 additions & 0 deletions ReactAndroid/src/main/jni/third-party/folly/FileUtil.cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- 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) {
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true

ANDROID_NDK_VERSION=20.1.5948944
ANDROID_NDK_VERSION=21.4.7075529
android.useAndroidX=true
kotlin_version=1.4.21
2 changes: 1 addition & 1 deletion template/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
ndkVersion = "21.4.7075529"
}
repositories {
google()
Expand Down

0 comments on commit aa43aab

Please sign in to comment.