Author: Brad Smith Date: 2025-01-23T12:54:35-05:00 New Revision: ff17a4136dedba004d901a571c4fae501affd051
URL: https://github.com/llvm/llvm-project/commit/ff17a4136dedba004d901a571c4fae501affd051 DIFF: https://github.com/llvm/llvm-project/commit/ff17a4136dedba004d901a571c4fae501affd051.diff LOG: [lldb] Remove support and workarounds for Android 4 and older (#124047) Added: Modified: lldb/cmake/modules/LLDBConfig.cmake lldb/include/lldb/Host/Time.h lldb/source/Host/CMakeLists.txt lldb/source/Host/common/Socket.cpp lldb/source/Host/posix/HostInfoPosix.cpp lldb/source/Host/posix/ProcessLauncherPosixFork.cpp Removed: lldb/source/Host/android/LibcGlue.cpp ################################################################################ diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 9bb37f5967d4f3..747f7e6038181c 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -306,9 +306,4 @@ else() set(LLDB_CAN_USE_DEBUGSERVER OFF) endif() -if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND - ((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips"))) - add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND) -endif() - include(LLDBGenerateConfig) diff --git a/lldb/include/lldb/Host/Time.h b/lldb/include/lldb/Host/Time.h index aee4c43247c5a3..2ca5a4026884b7 100644 --- a/lldb/include/lldb/Host/Time.h +++ b/lldb/include/lldb/Host/Time.h @@ -11,15 +11,6 @@ #ifndef LLDB_HOST_TIME_H #define LLDB_HOST_TIME_H -#ifdef __ANDROID__ -#include <android/api-level.h> -#endif - -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 -#include <time64.h> -extern time_t timegm(struct tm *t); -#else #include <ctime> -#endif #endif // LLDB_HOST_TIME_H diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index e0cd8569bf9575..cdfb6184f2219e 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -113,7 +113,6 @@ else() if (CMAKE_SYSTEM_NAME MATCHES "Android") add_host_subdirectory(android android/HostInfoAndroid.cpp - android/LibcGlue.cpp ) endif() elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") diff --git a/lldb/source/Host/android/LibcGlue.cpp b/lldb/source/Host/android/LibcGlue.cpp deleted file mode 100644 index 877d735823feee..00000000000000 --- a/lldb/source/Host/android/LibcGlue.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===-- LibcGlue.cpp ------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// This files adds functions missing from libc on earlier versions of Android - -#include <android/api-level.h> - -#include <sys/syscall.h> - -#if __ANDROID_API__ < 21 - -#include <csignal> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "lldb/Host/Time.h" - -time_t timegm(struct tm *t) { return (time_t)timegm64(t); } - -int posix_openpt(int flags) { return open("/dev/ptmx", flags); } - -#endif diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 0ccff41a552068..296c2273ba419c 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -472,23 +472,7 @@ Status Socket::Accept(const Timeout<std::micro> &timeout, Socket *&socket) { NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, Status &error) { error.Clear(); -#if defined(ANDROID_USE_ACCEPT_WORKAROUND) - // 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) { - int flags = ::fcntl(fd, F_GETFD); - if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1) - return fd; - SetLastError(error); - close(fd); - } - return fd; -#elif defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4) +#if defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4) int flags = SOCK_CLOEXEC; NativeSocket fd = llvm::sys::RetryAfterSignal( static_cast<NativeSocket>(-1), ::accept4, sockfd, addr, addrlen, flags); diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 193f584900b632..23ba3177de317a 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -86,13 +86,6 @@ std::optional<std::string> HostInfoPosix::GetOSBuildString() { return std::string(un.release); } -#ifdef __ANDROID__ -#include <android/api-level.h> -#endif -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 -#define USE_GETPWUID -#endif - namespace { class PosixUserIDResolver : public UserIDResolver { protected: @@ -107,14 +100,6 @@ struct PasswdEntry { }; static std::optional<PasswdEntry> GetPassword(id_t uid) { -#ifdef USE_GETPWUID - // getpwuid_r is missing from android-9 - // The caller should provide some thread safety by making sure no one calls - // this function concurrently, because using getpwuid is ultimately not - // thread-safe as we don't know who else might be calling it. - if (auto *user_info_ptr = ::getpwuid(uid)) - return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell}; -#else struct passwd user_info; struct passwd *user_info_ptr = &user_info; char user_buffer[PATH_MAX]; @@ -124,7 +109,6 @@ static std::optional<PasswdEntry> GetPassword(id_t uid) { user_info_ptr) { return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell}; } -#endif return std::nullopt; } diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 7b8b42a4b7fe07..22bf698c71716e 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -25,13 +25,10 @@ #include <sstream> #ifdef __ANDROID__ -#include <android/api-level.h> #define PT_TRACE_ME PTRACE_TRACEME #endif -#if defined(__ANDROID_API__) && __ANDROID_API__ < 15 -#include <linux/personality.h> -#elif defined(__linux__) +#if defined(__linux__) #include <sys/personality.h> #endif _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits