libc++ on Android needs to be linked against libandroid_support on API
levels less than 21 to provide needed functions that aren't in the libc
on those platforms (e.g. posix_memalign for libcxxabi). libc++ from the
NDK is a linker script that pulls in libandroid_support, but for
building libc++ itself, we need to explicitly add libandroid_support as
a dependency. Moreover, libc++ headers reference the functions provided
by libandroid_support, so it needs to be added as a public dependency.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 45074 Build 46716: arc lint + arc unit
Event Timeline
I'm experimenting with building my own libc++ for Android (using LLVM's runtimes build setup) for testing purposes. I know the NDK's libc++ is built with ndk-build, but having (best-effort) support for Android in libc++'s CMake seems reasonable too.
libcxx/CMakeLists.txt | ||
---|---|---|
784 | This should probably be PRIVATE rather than PUBLIC. The consumer doesn't need it if their minSdkVersion is 21+. The real constraint might be describable with a generator expression, but I'm not sure. (if we don't generate config files for this it doesn't matter anyway) |
libcxx/CMakeLists.txt | ||
---|---|---|
784 | You're right ... I was assuming that ANDROID_PLATFORM_LEVEL would be consistent across the build of libc++ and the build of clients, but that's not necessarily true. With that being said, we don't generate config files for this as far as I'm aware, so the only place this PUBLIC will affect is other parts of LLVM's build that depend on libc++, and I think it's fair to assume the entirety of LLVM is being built with the same ANDROID_PLATFORM_LEVEL. |
libcxx/CMakeLists.txt | ||
---|---|---|
784 | Okay, works for me. |
This should probably be PRIVATE rather than PUBLIC. The consumer doesn't need it if their minSdkVersion is 21+. The real constraint might be describable with a generator expression, but I'm not sure. (if we don't generate config files for this it doesn't matter anyway)