[sanitizer] Use runtime checks instead of API level for Android logging
authorKostya Kortchinsky <kostyak@google.com>
Thu, 16 Nov 2017 16:19:44 +0000 (16:19 +0000)
committerKostya Kortchinsky <kostyak@google.com>
Thu, 16 Nov 2017 16:19:44 +0000 (16:19 +0000)
commit8562eb32c9a5a44ee1bda92cba825f014d8a5e5a
tree598081cc2d3194eab68d6b8783b62c3f89f5ca53
parentc43622642adf34665d7e03831026c63f409c1f49
[sanitizer] Use runtime checks instead of API level for Android logging

Summary:
Recent Bionic have a slew of `async_safe_*` logging functions that are
basically the liblog ones but included within the libc. They have the advantage
of not allocating memory. `async_safe_write_log` does no formatting and is
likely the best candidate for logging.

Use a weak definition to try and use it. Also, avoid API level checks (as
the toolchain is compiled at a rather low API level) for `__android_log_write`
in favor of a weak definition as well.

Keep the fallback to `syslog` if nothing else was found.

I tried to overhaul the code block to only have a single #if SANITIZER_ANDROID
but I am not particularly attached to the form. LMKWYT.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D40100

llvm-svn: 318410
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc