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.

llvm-svn: 293281
This commit is contained in:
Pavel Labath 2017-01-27 12:23:51 +00:00
parent 12caf8e1e6
commit ef97630fd2
3 changed files with 11 additions and 13 deletions

View File

@ -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)

View File

@ -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

View File

@ -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(NativeSocket sockfd, struct sockaddr *addr,
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);