Android NDK compatibility patch for Debug+Asserts build
Jeffrey Brusseau
bobajeff82 at gmail.com
Thu Sep 11 08:24:25 PDT 2014
This is my first patch. I don't expect it's the best way to do things but
this is at least a start. If you have any suggestions on how to improve it
I'm open to being ridiculed in all manner of ways.
This patch is to add support for compiling LLVM/Clang for use on Android
using the NDK toolchain (GCC-4.8). For the most part I compiled this using
the default configuration:
> ../llvm/configure --enable-targets=host --host=arm-linux-androideabi
> --prefix=/home/bobajeff/android-ext
>
So I wound up compiling the Debug+Asserts build. I will test compiling
Release (optimized) build if that's requested. I've had experience building
a optimized build before using Mozilla's Fastcomp fork but that needed a
different set of patches.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140911/59f4d114/attachment.html>
-------------- next part --------------
diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h
index 389fd25..65b0a55 100644
--- a/include/llvm/Target/TargetLibraryInfo.h
+++ b/include/llvm/Target/TargetLibraryInfo.h
@@ -301,8 +301,10 @@ namespace llvm {
fsetpos,
/// int fstat(int fildes, struct stat *buf);
fstat,
+#ifndef __ANDROID__
/// int fstat64(int filedes, struct stat64 *buf)
fstat64,
+#endif
/// int fstatvfs(int fildes, struct statvfs *buf);
fstatvfs,
/// int fstatvfs64(int fildes, struct statvfs64 *buf);
@@ -392,8 +394,10 @@ namespace llvm {
logl,
/// int lstat(const char *path, struct stat *buf);
lstat,
+#ifndef __ANDROID__
/// int lstat64(const char *path, struct stat64 *buf);
lstat64,
+#endif
/// void *malloc(size_t size);
malloc,
/// void *memalign(size_t boundary, size_t size);
@@ -537,8 +541,10 @@ namespace llvm {
sscanf,
/// int stat(const char *path, struct stat *buf);
stat,
+#ifndef __ANDROID__
/// int stat64(const char *path, struct stat64 *buf);
stat64,
+#endif
/// int statvfs(const char *path, struct statvfs *buf);
statvfs,
/// int statvfs64(const char *path, struct statvfs64 *buf)
diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp
index 616ff90..cd963d2 100644
--- a/lib/Target/TargetLibraryInfo.cpp
+++ b/lib/Target/TargetLibraryInfo.cpp
@@ -165,7 +165,9 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"fseeko64",
"fsetpos",
"fstat",
+#ifndef __ANDROID__
"fstat64",
+#endif
"fstatvfs",
"fstatvfs64",
"ftell",
@@ -210,7 +212,9 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"logf",
"logl",
"lstat",
+#ifndef __ANDROID__
"lstat64",
+#endif
"malloc",
"memalign",
"memccpy",
@@ -281,7 +285,9 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"sqrtl",
"sscanf",
"stat",
+#ifndef __ANDROID__
"stat64",
+#endif
"statvfs",
"statvfs64",
"stpcpy",
@@ -663,12 +669,18 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
TLI.setUnavailable(LibFunc::memalign);
TLI.setUnavailable(LibFunc::fopen64);
TLI.setUnavailable(LibFunc::fseeko64);
+#ifndef __ANDROID__
TLI.setUnavailable(LibFunc::fstat64);
+#endif
TLI.setUnavailable(LibFunc::fstatvfs64);
TLI.setUnavailable(LibFunc::ftello64);
+#ifndef __ANDROID__
TLI.setUnavailable(LibFunc::lstat64);
+#endif
TLI.setUnavailable(LibFunc::open64);
+#ifndef __ANDROID__
TLI.setUnavailable(LibFunc::stat64);
+#endif
TLI.setUnavailable(LibFunc::statvfs64);
TLI.setUnavailable(LibFunc::tmpfile64);
}
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index 7e0cfa9..f42ca79 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1601,6 +1601,7 @@ bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
setDoesNotCapture(F, 1);
setOnlyReadsMemory(F, 1);
break;
+#ifndef __ANDROID__
case LibFunc::stat64:
case LibFunc::lstat64:
case LibFunc::statvfs64:
@@ -1613,6 +1614,7 @@ bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
setDoesNotCapture(F, 2);
setOnlyReadsMemory(F, 1);
break;
+#endif
case LibFunc::dunder_isoc99_sscanf:
if (FTy->getNumParams() < 1 ||
!FTy->getParamType(0)->isPointerTy() ||
@@ -1650,7 +1652,9 @@ bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
setDoesNotThrow(F);
setDoesNotAlias(F, 0);
break;
+#ifndef __ANDROID__
case LibFunc::fstat64:
+#endif
case LibFunc::fstatvfs64:
if (FTy->getNumParams() != 2 || !FTy->getParamType(1)->isPointerTy())
return false;
More information about the llvm-commits
mailing list