Page MenuHomePhabricator

[libcxx] Link against android_support when needed
ClosedPublic

Authored by smeenai on Jan 27 2020, 5:40 PM.

Details

Summary

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.

Diff Detail

Event Timeline

smeenai created this revision.Jan 27 2020, 5:40 PM

We don't build the NDK's libc++ with CMake. What's the motivation for this?

We don't build the NDK's libc++ with CMake. What's the motivation for this?

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.

danalbert added inline comments.Jan 28 2020, 10:16 AM
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)

smeenai marked an inline comment as done.Jan 28 2020, 11:34 AM
smeenai added inline comments.
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.

danalbert accepted this revision.Jan 28 2020, 12:52 PM
danalbert marked an inline comment as done.
danalbert added inline comments.
libcxx/CMakeLists.txt
784

Okay, works for me.

This revision is now accepted and ready to land.Jan 28 2020, 12:52 PM
This revision was automatically updated to reflect the committed changes.