Closed
Description
For Discussion
The purpose of this issue is to create a "single point of truth" regarding the efforts related to building React Native using Clang and against libc++, in order to coordinate and recap all the efforts connected to this subject.
Background
Android NDK is about to drop GCC and GNU STL support in favor of Clang and libc++ in version 18. Below are notable changes in NDK
Version 11
- GCC in the NDK is now deprecated in favor of Clang. We strongly recommend switching to Clang.
Version 13
- GCC is no longer supported. It will not be removed from the NDK just yet, but is no longer receiving backports. It cannot be removed until after libc++ has become stable enough to be the default, as some parts of gnustl are still incompatible with Clang. It will likely be removed after that point.
- NDK_TOOLCHAIN_VERSION now defaults to Clang.
Version 14
- This release ends active support for GCC
Version 16
- libc++ is out of beta and is now the preferred STL in the NDK. Starting in r17, libc++ is the default STL for CMake and standalone toolchains. If you manually selected a different STL, we strongly encourage you to move to libc++. For more details, see this blog post.
Version 17
- GCC is no longer supported. It will be removed in NDK r18.
- libc++ is now the default STL for CMake and standalone toolchains
gnustl and stlport are deprecated and will be removed in NDK r18.
Documentations
- Clang Migration Notes - https://android.googlesource.com/platform/ndk/+/master/docs/ClangMigration.md
- C++ Library Support - https://developer.android.com/ndk/guides/cpp-support
TODO
- Use CMake to build C++ code
- Upgrade Folly ([META] Upgrading Folly #20302)
- Compile RN using Clang
- Compile JSC and RN using Clang against libc++, because gnustl and libc++ ABI are incompatible
How to
Compile with Clang
Open ReactAndroid/src/main/jni/Application.mk
and remove or comment out NDK_TOOLCHAIN_VERSION
Compile with against libc++
Open ReactAndroid/src/main/jni/Application.mk
and set APP_STL := c++_shared
Related issues
- Roadmap of future Android [META] Roadmap of future Android(s) #19297
- Upgrading JSC - [META] Upgrading JSC #19737
Related PRs
- Bump NDK toolchain to GCC 4.9 and generalize C++ compiler flags (merged ccdd450) bump NDK toolchain to 4.9 #19945
- Bump Android NDK version to r17b (merged 6117a6c) Bump Android NDK to r17b #20357
Activity