[Lldb-commits] [lldb] r293281 - Refactor the android accept hack

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 27 04:23:51 PST 2017


Author: labath
Date: Fri Jan 27 06:23:51 2017
New Revision: 293281

URL: http://llvm.org/viewvc/llvm-project?rev=293281&view=rev
Log:
Refactor the android accept hack

This moves the accept hack from the android toolchain file into
LLDBConfig.cmake. This allows successful lldb android compilation
without relying on our custom toolchain file.

Modified:
    lldb/trunk/cmake/modules/LLDBConfig.cmake
    lldb/trunk/cmake/platforms/Android.cmake
    lldb/trunk/source/Host/common/Socket.cpp

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=293281&r1=293280&r2=293281&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Jan 27 06:23:51 2017
@@ -412,4 +412,8 @@ if(LLDB_USE_BUILTIN_DEMANGLER)
     add_definitions(-DLLDB_USE_BUILTIN_DEMANGLER)
 endif()
 
+if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC)
+  add_definitions(-DANDROID_BUILD_STATIC)
+endif()
+
 find_package(Backtrace)

Modified: lldb/trunk/cmake/platforms/Android.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/platforms/Android.cmake?rev=293281&r1=293280&r2=293281&view=diff
==============================================================================
--- lldb/trunk/cmake/platforms/Android.cmake (original)
+++ lldb/trunk/cmake/platforms/Android.cmake Fri Jan 27 06:23:51 2017
@@ -102,10 +102,6 @@ elseif( ANDROID_ABI STREQUAL "armeabi" )
  # 64 bit atomic operations used in c++ libraries require armv7-a instructions
  # armv5te and armv6 were tried but do not work.
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mthumb" )
- if( LLVM_BUILD_STATIC )
-  # Temporary workaround for static linking with the latest API.
-  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -DANDROID_ARM_BUILD_STATIC" )
- endif()
 elseif( ANDROID_ABI STREQUAL "mips" )
  # http://b.android.com/182094
  list( FIND LLDB_SYSTEM_LIBS atomic index )
@@ -113,10 +109,6 @@ elseif( ANDROID_ABI STREQUAL "mips" )
   list( APPEND LLDB_SYSTEM_LIBS atomic )
   set( LLDB_SYSTEM_LIBS ${LLDB_SYSTEM_LIBS} CACHE INTERNAL "" FORCE )
  endif()
- if( LLVM_BUILD_STATIC )
-  # Temporary workaround for static linking with the latest API.
-  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -DANDROID_MIPS_BUILD_STATIC" )
- endif()
 endif()
 
 # Use gold linker and enable safe ICF in case of x86, x86_64 and arm

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=293281&r1=293280&r2=293281&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Fri Jan 27 06:23:51 2017
@@ -38,11 +38,9 @@
 #include <asm-generic/errno-base.h>
 #include <errno.h>
 #include <linux/tcp.h>
-#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
 #include <fcntl.h>
 #include <sys/syscall.h>
 #include <unistd.h>
-#endif // ANDROID_ARM_BUILD_STATIC || ANDROID_MIPS_BUILD_STATIC
 #endif // __ANDROID__
 
 using namespace lldb;
@@ -424,9 +422,13 @@ NativeSocket Socket::AcceptSocket(Native
                                   socklen_t *addrlen,
                                   bool child_processes_inherit, Error &error) {
   error.Clear();
-#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
-  // Temporary workaround for statically linking Android lldb-server with the
-  // latest API.
+#if defined(ANDROID_BUILD_STATIC)
+  // Hack:
+  // This enables static linking lldb-server to an API 21 libc, but still having
+  // it run on older devices. It is necessary because API 21 libc's
+  // implementation of accept() uses the accept4 syscall(), which is not
+  // available in older kernels. Using an older libc would fix this issue, but
+  // introduce other ones, as the old libraries were quite buggy.
   int fd = syscall(__NR_accept, sockfd, addr, addrlen);
   if (fd >= 0 && !child_processes_inherit) {
     int flags = ::fcntl(fd, F_GETFD);




More information about the lldb-commits mailing list