This is an archive of the discontinued LLVM Phabricator instance.

[RFC] Android runtimes build demonstration
Needs ReviewPublic

Authored by smeenai on Aug 24 2023, 4:57 PM.

Details

Summary

This demonstrates a possible Android runtimes build setup once
https://reviews.llvm.org/D158476 lands and runtimes library searching
accounts for versioned Android triples. Meta uses a similar setup
internally (except for using a standalone CMake toolchain file instead
of wrapping the NDK's; I'm not actually sure which one I prefer.)

I'm putting this up as a demonstration of aspects of the runtime build
(in particular delegating to separate toolchain and cache files, which I
find to be much more manageable than putting everything in the runtimes
cache file). If the Android toolchain maintainers think it could be
generally useful, I'd be happy for a maintainer to commandeer it and
change it as they see fit, or make any suggested changes myself.

There's some existing Android cache and toolchain files:

  • clang/cmake/caches/Android.cmake
  • clang/cmake/caches/Android-stage2.cmake
  • llvm/cmake/platforms/Android.cmake

As far as I can tell the toolchain file is pretty bit-rotted and the
cache files don't reflect the current NDK runtimes configuration (e.g.
the use of the __ndk1 inline namespace). I'm not changing them here,
but it'd be great if a maintainer could take a look and decide what to
do with them.

Diff Detail

Event Timeline

smeenai created this revision.Aug 24 2023, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 4:57 PM
Herald added a subscriber: danielkiss. · View Herald Transcript
smeenai requested review of this revision.Aug 24 2023, 4:57 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 24 2023, 4:57 PM

The manual androideabi normalization is only needed when building the runtimes, not when using them:

$ for i in {21..32}; do printf '%s ' $i; bin/clang --print-file-name=libclang_rt.builtins.a -target armv7-none-linux-androideabi$i; done
21 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
22 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
23 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
24 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
25 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
26 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
27 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
28 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android21/libclang_rt.builtins.a
29 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android29/libclang_rt.builtins.a
30 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android29/libclang_rt.builtins.a
31 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android29/libclang_rt.builtins.a
32 /data/users/smeenai/llvm-project/build/Release/lib/clang/18/lib/armv7-none-linux-android29/libclang_rt.builtins.a