[libcxx-commits] [libcxx] [libc++][Android] Explicitly declare low-level lib existence (PR #70534)
Ryan Prichard via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 27 20:52:56 PDT 2023
https://github.com/rprichard created https://github.com/llvm/llvm-project/pull/70534
Android's librt and libpthread functionality is part of libc.{a,so} instead. The atomic APIs are part of the compiler-rt builtins archive. Android does have libdl.
Android's libc.so has `__cxa_thread_atexit_impl` starting in API 23, and the oldest supported API is 21, so continue using feature detection for that API.
These settings need to be declared explicitly for the sake of the fuzzer library's custom libc++ build `add_custom_libcxx`. That macro builds libc++ using `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`, which breaks the feature detection.
>From 60f077f118c6796745b5f4d304c2b1e223ba97f9 Mon Sep 17 00:00:00 2001
From: Ryan Prichard <rprichard at google.com>
Date: Fri, 27 Oct 2023 16:28:37 -0700
Subject: [PATCH] [libc++][Android] Explicitly declare low-level lib existence
Android's librt and libpthread functionality is part of libc.{a,so}
instead. The atomic APIs are part of the compiler-rt builtins archive.
Android does have libdl.
Android's libc.so has `__cxa_thread_atexit_impl` starting in API 23,
and the oldest supported API is 21, so continue using feature detection
for that API.
These settings need to be declared explicitly for the sake of the
fuzzer library's custom libc++ build `add_custom_libcxx`. That macro
builds libc++ using `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`,
which breaks the feature detection.
---
libcxx/cmake/config-ix.cmake | 4 ++++
libcxxabi/cmake/config-ix.cmake | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 9fed861a4e193c5..a365517936e7565 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -107,6 +107,10 @@ elseif(FUCHSIA)
set(LIBCXX_HAS_PTHREAD_LIB NO)
set(LIBCXX_HAS_RT_LIB NO)
check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
+elseif(ANDROID)
+ set(LIBCXX_HAS_PTHREAD_LIB NO)
+ set(LIBCXX_HAS_RT_LIB NO)
+ set(LIBCXX_HAS_ATOMIC_LIB NO)
else()
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
index 702fe7d1d72f777..39b9284b780ebcf 100644
--- a/libcxxabi/cmake/config-ix.cmake
+++ b/libcxxabi/cmake/config-ix.cmake
@@ -95,6 +95,11 @@ if(FUCHSIA)
set(LIBCXXABI_HAS_PTHREAD_LIB NO)
check_library_exists(c __cxa_thread_atexit_impl ""
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
+elseif(ANDROID)
+ set(LIBCXXABI_HAS_DL_LIB YES)
+ set(LIBCXXABI_HAS_PTHREAD_LIB NO)
+ check_library_exists(c __cxa_thread_atexit_impl ""
+ LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
else()
check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB)
check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
More information about the libcxx-commits
mailing list