[llvm-commits] Building LLVM with the Android toolchain

Sean Childs sean.childs at googlemail.com
Fri Apr 13 03:02:38 PDT 2012


Hi,

I've compiled llvm for arm using the android toolchain, had to make a few
changes to get it to work (as the android library is missing a few things),
and seeing as this is the first time I'm doing this, thought I'd post the
diff here and see what people say.

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120413/444a666e/attachment.html>
-------------- next part --------------
diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp
index 506b5cf..8de541d 100644
--- a/lib/CodeGen/GCStrategy.cpp
+++ b/lib/CodeGen/GCStrategy.cpp
@@ -20,6 +20,7 @@
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Module.h"
 #include "llvm/Analysis/Dominators.h"
+#include "llvm/Analysis/DominatorInternals.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
index 2d1775c..7561d36 100644
--- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
+++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
@@ -815,12 +815,14 @@ public:
     sys::DynamicLibrary::AddSymbol("stat", (void*)(intptr_t)stat);
     sys::DynamicLibrary::AddSymbol("fstat", (void*)(intptr_t)fstat);
     sys::DynamicLibrary::AddSymbol("lstat", (void*)(intptr_t)lstat);
+#if ! defined(__ANDROID__)
     sys::DynamicLibrary::AddSymbol("stat64", (void*)(intptr_t)stat64);
     sys::DynamicLibrary::AddSymbol("\x1stat64", (void*)(intptr_t)stat64);
     sys::DynamicLibrary::AddSymbol("\x1open64", (void*)(intptr_t)open64);
     sys::DynamicLibrary::AddSymbol("\x1lseek64", (void*)(intptr_t)lseek64);
     sys::DynamicLibrary::AddSymbol("fstat64", (void*)(intptr_t)fstat64);
     sys::DynamicLibrary::AddSymbol("lstat64", (void*)(intptr_t)lstat64);
+#endif
     sys::DynamicLibrary::AddSymbol("atexit", (void*)(intptr_t)atexit);
     sys::DynamicLibrary::AddSymbol("mknod", (void*)(intptr_t)mknod);
   }
diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
index fb02c07..cd7157d 100644
--- a/lib/Support/DynamicLibrary.cpp
+++ b/lib/Support/DynamicLibrary.cpp
@@ -160,7 +160,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
 // 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__)
+#if defined(__linux__) && ! defined(__ANDROID__)
   {
     EXPLICIT_SYMBOL(stderr);
     EXPLICIT_SYMBOL(stdout);
diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp
index 64404a1..e557c5d 100644
--- a/lib/Support/LockFileManager.cpp
+++ b/lib/Support/LockFileManager.cpp
@@ -49,7 +49,7 @@ LockFileManager::readLockFile(StringRef LockFileName) {
 }
 
 bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) {
-#if LLVM_ON_UNIX
+#if LLVM_ON_UNIX && ! __ANDROID__
   char MyHostname[256];
   MyHostname[255] = 0;
   MyHostname[0] = 0;
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index ddc1e0f..d5fb4da 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -67,7 +67,7 @@
 
 // Put in a hack for Cygwin which falsely reports that the mkdtemp function
 // is available when it is not.
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(__ANDROID__)
 # undef HAVE_MKDTEMP
 #endif
 
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 9a5423f..5daeb5e 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -23,6 +23,7 @@
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Pass.h"
 #include "llvm/Analysis/Dominators.h"
+#include "llvm/Analysis/DominatorInternals.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/ProfileInfo.h"
 #include "llvm/Target/TargetData.h"
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 79fd7f8..115db54 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -184,7 +184,16 @@ int main(int argc, char **argv) {
   // Check to see if we are inside a development tree by comparing to possible
   // locations (prefix style or CMake style). This could be wrong in the face of
   // symbolic links, but is good enough.
+#ifdef __MINGW32__
+  // For mingw32, we want something like /c/ instead of c:/
+  size_t colon_position = CurrentExecPrefix.find_first_of(':');
+  if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE
+  || (colon_position != std::string::npos &&
+         (std::string("/") + CurrentExecPrefix.substr(0, colon_position) + CurrentExecPrefix.substr(colon_position + 1))
+      ==  std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE)) {
+#else
   if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE) {
+#endif
     IsInDevelopmentTree = true;
     DevelopmentTreeLayout = MakefileStyle;
 
diff --git a/unittests/ADT/HashingTest.cpp b/unittests/ADT/HashingTest.cpp
index b148f14..8bb6dfb 100644
--- a/unittests/ADT/HashingTest.cpp
+++ b/unittests/ADT/HashingTest.cpp
@@ -19,6 +19,12 @@
 #include <map>
 #include <vector>
 
+#ifdef __ANDROID__
+namespace std {
+	typedef basic_string<wchar_t> wstring;
+}
+#endif
+
 namespace llvm {
 
 // Helper for test code to print hash codes.


More information about the llvm-commits mailing list