[PATCH] D62892: [Sanitizers] Fix sanitizer_posix_libcdep.cc compilation on Solaris 11.5

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 01:19:45 PDT 2019


ro created this revision.
ro added a reviewer: kcc.
ro added a project: Sanitizers.
Herald added subscribers: Sanitizers, fedor.sergeev, kubamracek.
Herald added a project: LLVM.

A recent build of Solaris 11.5 Beta (st_047) gained `madvise(MADV_DONTDUMP)`
support for Linux compatibility.  This broke the compiler-rt build:

  /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_comm/sanitizer_posix_libcdep.cc: In function ‘bool __sanitizer::DontDumpShadowMemory(__sanitizer::uptr, __sanitizer::uptr)’:
  /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc:81:18: error: invalid conversion from ‘void*’ to ‘caddr_t’ {aka ‘char*’} [-fpermissive]
     81 |   return madvise((void *)addr, length, MADV_DONTDUMP) == 0;
        |                  ^~~~~~~~~~~~
        |                  |
        |                  void*
  In file included from /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc:32:
  /usr/include/sys/mman.h:231:20: note:   initializing argument 1 of ‘int madvise(caddr_t, std::size_t, int)’
    231 | extern int madvise(caddr_t, size_t, int);
        |                    ^~~~~~~

The obvious fix is to use the same solution that has already been used a couple of
lines earlier:

  // In the default Solaris compilation environment, madvise() is declared
  // to take a caddr_t arg; casting it to void * results in an invalid
  // conversion error, so use char * instead.

This allowed the compiler-rt build to finish and was tested successfully on 
`i386-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

Ok for trunk?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D62892

Files:
  lib/sanitizer_common/sanitizer_posix_libcdep.cc


Index: lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -70,7 +70,7 @@
 
 bool NoHugePagesInRegion(uptr addr, uptr size) {
 #ifdef MADV_NOHUGEPAGE  // May not be defined on old systems.
-  return madvise((void *)addr, size, MADV_NOHUGEPAGE) == 0;
+  return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
 #else
   return true;
 #endif  // MADV_NOHUGEPAGE
@@ -78,9 +78,9 @@
 
 bool DontDumpShadowMemory(uptr addr, uptr length) {
 #if defined(MADV_DONTDUMP)
-  return madvise((void *)addr, length, MADV_DONTDUMP) == 0;
+  return madvise((char *)addr, length, MADV_DONTDUMP) == 0;
 #elif defined(MADV_NOCORE)
-  return madvise((void *)addr, length, MADV_NOCORE) == 0;
+  return madvise((char *)addr, length, MADV_NOCORE) == 0;
 #else
   return true;
 #endif  // MADV_DONTDUMP


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62892.203094.patch
Type: text/x-patch
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190605/b0e3e5e7/attachment.bin>


More information about the llvm-commits mailing list