summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-01-27 12:23:51 +0000
committerPavel Labath <labath@google.com>2017-01-27 12:23:51 +0000
commitef97630fd20d24ee508c8287a3d7d8699a59fbaa (patch)
treea88116cb79d2e2fc1d3781b181b2cc92a89b0956
parent12caf8e1e6759d8ced7dbd40ca1bd8efe9e7bbae (diff)
downloadbcm5719-llvm-ef97630fd20d24ee508c8287a3d7d8699a59fbaa.tar.gz
bcm5719-llvm-ef97630fd20d24ee508c8287a3d7d8699a59fbaa.zip
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
-rw-r--r--lldb/cmake/modules/LLDBConfig.cmake4
-rw-r--r--lldb/cmake/platforms/Android.cmake8
-rw-r--r--lldb/source/Host/common/Socket.cpp12
3 files changed, 11 insertions, 13 deletions
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 26f9c93902a..0ee60a705af 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -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)
diff --git a/lldb/cmake/platforms/Android.cmake b/lldb/cmake/platforms/Android.cmake
index d3e9a05f915..789322f4353 100644
--- a/lldb/cmake/platforms/Android.cmake
+++ b/lldb/cmake/platforms/Android.cmake
@@ -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
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 79777c88fa4..8082fff179f 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -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);
OpenPOWER on IntegriCloud