[compiler-rt] c61dcb8 - [compiler-rt] fix build on Illumos

David Carlier via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 07:20:12 PDT 2020


Author: David Carlier
Date: 2020-07-22T15:19:56+01:00
New Revision: c61dcb8f623e5d289164f44c086867d0b052b1e5

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

LOG: [compiler-rt] fix build on Illumos

- there are additional fields for glob_t struct, thus size check is failing.
- to access old mman.h api based on caddr_t, _XOPEN_SOURCE needs to be not defined
 thus we provide the prototype.
- prxmap_t constified.

Reviewers: ro, eugenis

Reviewed-By: ro

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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp
index 6ec1a1bdd114..565b31f68aae 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp
@@ -202,7 +202,8 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
 
-CHECK_TYPE_SIZE(glob_t);
+// There are additional fields we are not interested in.
+COMPILER_CHECK(sizeof(__sanitizer_glob_t) <= sizeof(glob_t));
 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
 CHECK_SIZE_AND_OFFSET(glob_t, gl_offs);

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index f920172c06d6..0bd64dd0d3e9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -44,6 +44,12 @@
 #define MAP_NORESERVE 0
 #endif
 
+#if SANITIZER_SOLARIS
+// Illumos' declaration of madvie cannot be made visible if _XOPEN_SOURCE
+// is defined as g++ does on Solaris.
+extern "C" int madvise(caddr_t, size_t, int);
+#endif
+
 typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
 
 namespace __sanitizer {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
index 8793423a6017..4063ec8deaa1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
@@ -35,7 +35,8 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
   char *last = data_.proc_self_maps.data + data_.proc_self_maps.len;
   if (data_.current >= last) return false;
 
-  prxmap_t *xmapentry = (prxmap_t*)data_.current;
+  prxmap_t *xmapentry =
+      const_cast<prxmap_t *>(reinterpret_cast<const prxmap_t *>(data_.current));
 
   segment->start = (uptr)xmapentry->pr_vaddr;
   segment->end = (uptr)(xmapentry->pr_vaddr + xmapentry->pr_size);


        


More information about the llvm-commits mailing list