Index: include/llvm/Target/TargetLibraryInfo.h =================================================================== --- include/llvm/Target/TargetLibraryInfo.h +++ include/llvm/Target/TargetLibraryInfo.h @@ -13,6 +13,13 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/Pass.h" +#if defined(__ANDROID_NDK__) +// some versions of Android NDK have these macros defined +#undef stat64 +#undef lstat64 +#undef fstat64 +#endif + namespace llvm { class Triple; Index: include/llvm/Transforms/Instrumentation.h =================================================================== --- include/llvm/Transforms/Instrumentation.h +++ include/llvm/Transforms/Instrumentation.h @@ -16,7 +16,7 @@ #include "llvm/ADT/StringRef.h" -#if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID) +#if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID_NDK__) inline void *getDFSanArgTLSPtrForJIT() { extern __thread __attribute__((tls_model("initial-exec"))) void *__dfsan_arg_tls; @@ -78,7 +78,7 @@ void *(*getArgTLS)() = nullptr, void *(*getRetValTLS)() = nullptr); -#if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID) +#if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID_NDK__) inline ModulePass *createDataFlowSanitizerPassForJIT(StringRef ABIListFile = StringRef()) { return createDataFlowSanitizerPass(ABIListFile, getDFSanArgTLSPtrForJIT, Index: lib/Support/DynamicLibrary.cpp =================================================================== --- lib/Support/DynamicLibrary.cpp +++ lib/Support/DynamicLibrary.cpp @@ -143,7 +143,7 @@ // On linux we have a weird situation. The stderr/out/in symbols are both // macros and global variables because of standards requirements. So, we // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. -#if defined(__linux__) and !defined(__ANDROID__) +#if defined(__linux__) and !defined(__ANDROID__) and !defined(__ANDROID_NDK__) { EXPLICIT_SYMBOL(stderr); EXPLICIT_SYMBOL(stdout); Index: lib/Support/LockFileManager.cpp =================================================================== --- lib/Support/LockFileManager.cpp +++ lib/Support/LockFileManager.cpp @@ -58,7 +58,7 @@ } bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) { -#if LLVM_ON_UNIX && !defined(__ANDROID__) +#if LLVM_ON_UNIX && !defined(__ANDROID__) && !defined(__ANDROID_NDK__) char MyHostname[256]; MyHostname[255] = 0; MyHostname[0] = 0; Index: lib/Support/Unix/Memory.inc =================================================================== --- lib/Support/Unix/Memory.inc +++ lib/Support/Unix/Memory.inc @@ -340,7 +340,7 @@ __clear_cache(const_cast(Start), const_cast(End)); # elif defined(__mips__) const char *Start = static_cast(Addr); -# if defined(ANDROID) +# if defined(ANDROID) || defined(__ANDROID_NDK__) // The declaration of "cacheflush" in Android bionic: // extern int cacheflush(long start, long end, long flags); const char *End = Start + Len; Index: lib/Transforms/Hello/CMakeLists.txt =================================================================== --- lib/Transforms/Hello/CMakeLists.txt +++ lib/Transforms/Hello/CMakeLists.txt @@ -6,7 +6,7 @@ endif() endif() -if(WIN32 OR CYGWIN) +if(WIN32 OR CYGWIN OR __ANDROID_NDK__) set(LLVM_LINK_COMPONENTS Core Support) endif() Index: tools/bugpoint-passes/CMakeLists.txt =================================================================== --- tools/bugpoint-passes/CMakeLists.txt +++ tools/bugpoint-passes/CMakeLists.txt @@ -10,7 +10,7 @@ endif() endif() -if(WIN32 OR CYGWIN) +if(WIN32 OR CYGWIN OR __ANDROID_NDK__) set(LLVM_LINK_COMPONENTS Core) endif() Index: utils/unittest/googletest/include/gtest/internal/gtest-port.h =================================================================== --- utils/unittest/googletest/include/gtest/internal/gtest-port.h +++ utils/unittest/googletest/include/gtest/internal/gtest-port.h @@ -233,7 +233,7 @@ # define GTEST_OS_FREEBSD 1 #elif defined __linux__ # define GTEST_OS_LINUX 1 -# if defined(ANDROID) || defined(__ANDROID__) +# if defined(ANDROID) || defined(__ANDROID__) || defined(__ANDROID_NDK__) # define GTEST_OS_LINUX_ANDROID 1 # endif // ANDROID #elif defined __MVS__ @@ -271,7 +271,7 @@ // Defines this to true iff Google Test can use POSIX regular expressions. #ifndef GTEST_HAS_POSIX_RE -# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) +# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS && !defined(__ANDROID_NDK__)) #endif #if GTEST_HAS_POSIX_RE @@ -523,7 +523,7 @@ #ifndef GTEST_HAS_CLONE // The user didn't tell us, so we need to figure it out. -# if GTEST_OS_LINUX && !defined(__ia64__) +# if GTEST_OS_LINUX && !defined(__ia64__) && !defined(__ANDROID_NDK__) # define GTEST_HAS_CLONE 1 # else # define GTEST_HAS_CLONE 0