Index: cmake/platforms/Android.cmake =================================================================== --- cmake/platforms/Android.cmake +++ cmake/platforms/Android.cmake @@ -44,7 +44,7 @@ # its symbols, which significantly increases the binary size. Static linking, on # the other hand, has little to no effect on the binary size. if (NOT DEFINED LLVM_BUILD_STATIC) - set( LLVM_BUILD_STATIC True ) + set( LLVM_BUILD_STATIC True ) endif() set( ANDROID_ABI "${ANDROID_ABI}" CACHE INTERNAL "Android Abi" FORCE ) @@ -102,6 +102,10 @@ # 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" ) + 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() endif() # linker flags Index: source/Host/common/Socket.cpp =================================================================== --- source/Host/common/Socket.cpp +++ source/Host/common/Socket.cpp @@ -24,7 +24,11 @@ #include #include #include -#endif +#if defined(ANDROID_ARM_BUILD_STATIC) +#include +#include +#endif // ANDROID_ARM_BUILD_STATIC +#endif // __ANDROID_NDK__ #ifndef LLDB_DISABLE_POSIX #include @@ -70,7 +74,19 @@ NativeSocket Accept(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit) { -#ifdef SOCK_CLOEXEC +#if defined(ANDROID_ARM_BUILD_STATIC) + // Temporary workaround for statically linking Android lldb-server with the + // latest API. + int fd = syscall(__NR_accept, sockfd, addr, addrlen); + if (fd >= 0 && !child_processes_inherit) + { + if (::fcntl(fd, F_GETFD) == -1) + return -1; + if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) + return -1; + } + return fd; +#elif defined(SOCK_CLOEXEC) int flags = 0; if (!child_processes_inherit) { flags |= SOCK_CLOEXEC;