Skip to content

[META] Build with Clang (Android) #20342

Closed
@dulmandakh

Description

@dulmandakh

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

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

Related PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions