[PATCH] D119695: [Support] Fix build on illumos

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 14 01:31:55 PST 2022


nikic created this revision.
nikic added reviewers: devnexen, ro, pcc, MaskRay.
Herald added subscribers: dexonsmith, hiraditya, fedor.sergeev, krytarowski.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

D116366 <https://reviews.llvm.org/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


https://reviews.llvm.org/D119695

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


Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -118,6 +118,12 @@
 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
 #endif
 
+#if defined(__sun__)
+// 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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119695.408352.patch
Type: text/x-patch
Size: 523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220214/455e7baf/attachment.bin>


More information about the llvm-commits mailing list