[libcxx-commits] [PATCH] D73516: [libcxx] Link against android_support when needed

Shoaib Meenai via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 27 17:41:45 PST 2020


smeenai created this revision.
smeenai added reviewers: danalbert, enh, EricWF, ldionne.
Herald added subscribers: libcxx-commits, dexonsmith, christof, mgorny.
Herald added a project: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73516

Files:
  libcxx/CMakeLists.txt
  libcxxabi/src/CMakeLists.txt


Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -95,6 +95,9 @@
   # MINGW_LIBRARIES is defined in config-ix.cmake
   list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES})
 endif()
+if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21)
+  list(APPEND LIBCXXABI_LIBRARIES android_support)
+endif()
 
 if (NOT LIBCXXABI_USE_COMPILER_RT)
   add_library_flags_if(LIBCXXABI_HAS_GCC_LIB gcc)
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -779,6 +779,10 @@
     # (e.g. `printfw`/`scanfw`)
     target_link_libraries(${target} PRIVATE iso_stdio_wide_specifiers)
   endif()
+
+  if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21)
+    target_link_libraries(${target} PUBLIC android_support)
+  endif()
 endfunction()
 
 # Windows-related flags =======================================================


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73516.240743.patch
Type: text/x-patch
Size: 1011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200128/1acacc3f/attachment.bin>


More information about the libcxx-commits mailing list