[llvm] 8f55cd0 - [Support] Fix build on illumos

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 00:44:09 PST 2022


Author: Nikita Popov
Date: 2022-02-15T09:42:40+01:00
New Revision: 8f55cd0178c192232929afae5d73c363167b26d8

URL: https://github.com/llvm/llvm-project/commit/8f55cd0178c192232929afae5d73c363167b26d8
DIFF: https://github.com/llvm/llvm-project/commit/8f55cd0178c192232929afae5d73c363167b26d8.diff

LOG: [Support] Fix build on illumos

D116366 added a call to madvise() in Path.inc. Unfortunately,
Illumos does not declare this function if _XOPEN_SOURCE is defined
(which it is by default) and we need to provide the declaration
manually. This is the same workaround used in sanitizers:
https://github.com/llvm/llvm-project/blob/ee423d93ead39e94c2970b3cc7ef6e6faa75d10b/compiler-rt/lib/sanitizer_common/sanitizer_solaris.cpp#L77-L85

Differential Revision: https://reviews.llvm.org/D119695

Added: 
    

Modified: 
    llvm/lib/Support/Unix/Path.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 788460d657fe..d53a09f0579c 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -118,6 +118,12 @@ typedef uint_t uint;
 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
 #endif
 
+#if defined(__sun__) && defined(__svr4__)
+// The madvise() declaration on Illumos cannot be made visible if _XOPEN_SOURCE
+// is defined. This declaration is also compatible with Solaris 11.4.
+extern "C" int madvise(void *, size_t, int);
+#endif
+
 using namespace llvm;
 
 namespace llvm {


        


More information about the llvm-commits mailing list