[Lldb-commits] [PATCH] D103127: lldb: Don't check for CMAKE_SYSTEM_NAME==Android.
Peter Collingbourne via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 25 16:57:15 PDT 2021
pcc created this revision.
pcc added reviewers: JDevlieghere, labath.
Herald added subscribers: danielkiss, krytarowski, mgorny.
pcc requested review of this revision.
Herald added a project: LLDB.
CMAKE_SYSTEM_NAME seems to be unreliable for detecting whether the
target is Android. At least on my machine it always turns out to
have the value Linux when targeting Android. Even explicitly passing
-DCMAKE_SYSTEM_NAME=Android to CMake doesn't seem to help. It seems
that CMake is overriding the value that I pass in with a value that
it computed somehow.
To avoid relying on whichever fragile mechanism is used to detect
Android targets, let's just compile the Android source files
unconditionally and use the preprocessor to exclude their contents
on non-Android platforms.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103127
Files:
lldb/source/Host/CMakeLists.txt
lldb/source/Host/android/HostInfoAndroid.cpp
lldb/source/Host/android/LibcGlue.cpp
Index: lldb/source/Host/android/LibcGlue.cpp
===================================================================
--- lldb/source/Host/android/LibcGlue.cpp
+++ lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,8 @@
// This files adds functions missing from libc on earlier versions of Android
+#if defined(__ANDROID__)
+
#include <android/api-level.h>
#include <sys/syscall.h>
@@ -26,3 +28,5 @@
int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
#endif
+
+#endif // __ANDROID__
Index: lldb/source/Host/android/HostInfoAndroid.cpp
===================================================================
--- lldb/source/Host/android/HostInfoAndroid.cpp
+++ lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#if defined(__ANDROID__)
+
#include "lldb/Host/android/HostInfoAndroid.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@
return FileSystem::Instance().Exists(file_spec);
}
+
+#endif // __ANDROID__
Index: lldb/source/Host/CMakeLists.txt
===================================================================
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -106,12 +106,10 @@
linux/LibcGlue.cpp
linux/Support.cpp
)
- if (CMAKE_SYSTEM_NAME MATCHES "Android")
- add_host_subdirectory(android
- android/HostInfoAndroid.cpp
- android/LibcGlue.cpp
- )
- endif()
+ add_host_subdirectory(android
+ android/HostInfoAndroid.cpp
+ android/LibcGlue.cpp
+ )
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_host_subdirectory(freebsd
freebsd/Host.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103127.347823.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210525/49bec1d1/attachment-0001.bin>
More information about the lldb-commits
mailing list