[PATCH] D34943: llvm: fix building with musl libc

Martell Malone via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 07:34:26 PDT 2017


martell created this revision.
Herald added a subscriber: srhines.

musl uses `#define` to map some 64 type functions for backwards compatibility.
this breaks building LLVM which assumes GLIBC in a lot of places.

There is no __MUSL__ macro so this is the best way to detect it currently.
One would presume the #undef's should be safe without a guard.
This is just a precaution. Suggested improvements welcome :)


Repository:
  rL LLVM

https://reviews.llvm.org/D34943

Files:
  include/llvm/Analysis/TargetLibraryInfo.h


Index: include/llvm/Analysis/TargetLibraryInfo.h
===================================================================
--- include/llvm/Analysis/TargetLibraryInfo.h
+++ include/llvm/Analysis/TargetLibraryInfo.h
@@ -19,6 +19,28 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 
+#if defined(__linux__) and !defined(__GLIBC__) and !defined(__ANDROID__)
+#undef fopen64
+#undef fseeko64
+#undef fstat64
+#undef fstatvfs64
+#undef ftello64
+#undef lstat64
+#undef stat64
+#undef tmpfile64
+#undef F_GETLK64
+#undef F_SETLK64
+#undef F_SETLKW64
+#undef flock64
+#undef open64
+#undef openat64
+#undef creat64
+#undef lockf64
+#undef posix_fadvise64
+#undef posix_fallocate64
+#undef off64_t
+#endif
+
 namespace llvm {
 template <typename T> class ArrayRef;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34943.105061.patch
Type: text/x-patch
Size: 766 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170703/4ccd716f/attachment.bin>


More information about the llvm-commits mailing list