Switch to the libc++ toolchain prebuilt

Android currently uses external/libcxx and external/libcxxabi for its
libc++ STL, but these repositories haven't been updated since January
2019. Instead, build libc++ as part of the Android Clang build, and use
a prebuilt libc++ for device and host Soong builds.

The Clang prebuilt already had Soong modules, "libc++_host" and
"libc++abi_host", that imported libc++[abi].{so,dylib} for Darwin+Linux
host only. The clang-tools (e.g. vndk/tools/header-checker, versioner)
need to link against the LLVM prebuilt (e.g. libclang-cpp.so), so they
also must use the newer libc++.so that libclang-cpp.so uses. Generalize
these imports by renaming the llvm_host_prebuilt_library_shared Soong
module type to llvm_prebuilt_library_shared, and renaming the modules:

 * libc++_host --> libc++
 * libc++abi_host --> libc++abi_shared

Avoid renaming the ABI module to just "libc++abi" because the old
external/libcxxabi also defined a "libc++abi" module, but it was a
static library instead. Add a new "libc++abi_static" module. It isn't
clear if these ABI modules are really needed, though. The old
"libc++abi" didn't appear used anywhere in Android's bp/mk files, and
the libc++abi object files are exported from libc++[_static]. The ABI
modules are now host-only, but it may be sensible to remove them
altogether.

Soong also has an NDK libc++ (in prebuilts/ndk/Android.bp), which will
be switched later to the Clang prebuilt.

Previously, the LLVM_BUILD_HOST_TOOLS environment variable set
"enabled" to false for both llvm_host_prebuilt_library_shared (e.g.
libc++_host) and the llvm_host_defaults module (i.e. clang-tools), but
now it only affects the latter. This environment variable can probably
be removed entirely eventually, leaving the clang-tools modules enabled
unconditionally.

Bug: http://b/332594828
Test: treehugger
Change-Id: I78714516f2734e7bc8d0e80e71cd62bc8113a365
2 files changed
tree: dfb7382f9288fb0fc0c1d22f1f3a2512a32f82f8
  1. clang-3289846/
  2. clang-r475365b/
  3. clang-r487747c/
  4. clang-r498229b/
  5. clang-r510928/
  6. clang-r522817/
  7. clang-stable/
  8. docs/
  9. kleaf/
  10. llvm-binutils-stable/
  11. mlgo-models/
  12. profiles/
  13. soong/
  14. .gitignore
  15. Android.bp
  16. BINUTILS_KERNEL_DEPRECATION.md
  17. BUILD.bazel
  18. CleanSpec.mk
  19. GCC_4_9_DEPRECATION.md
  20. go.mod
  21. METADATA
  22. OWNERS
  23. README.md
  24. RELEASE_NOTES.md
README.md

Android Clang/LLVM Prebuilts

For the latest version of this doc, please make sure to visit: Android Clang/LLVM Prebuilts Readme Doc

LLVM Users

Prebuilt Versions

More Information

We have a public mailing list that you can subscribe to: android-llvm@googlegroups.com

See also our release notes.