[libcxx-commits] [libcxx] [libc++][Android] Explicitly declare low-level lib existence (PR #70534)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 27 20:53:59 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Ryan Prichard (rprichard)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/70534.diff


2 Files Affected:

- (modified) libcxx/cmake/config-ix.cmake (+4) 
- (modified) libcxxabi/cmake/config-ix.cmake (+5) 


``````````diff
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)

``````````

</details>


https://github.com/llvm/llvm-project/pull/70534


More information about the libcxx-commits mailing list