This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Fix sanitizer_posix_libcdep.cc compilation on Solaris 11.5
ClosedPublic

Authored by ro on Jun 5 2019, 1:19 AM.

Details

Summary

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?

Diff Detail

Repository
rL LLVM

Event Timeline

ro created this revision.Jun 5 2019, 1:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2019, 1:19 AM
Herald added subscribers: Restricted Project, fedor.sergeev, kubamracek. · View Herald Transcript
ro added a comment.Jun 12 2019, 4:35 AM

Ping? It's been a week and the patch is close to obvious.

ro added a comment.Jun 19 2019, 1:01 AM

Ping^2. It's been two weeks now for a trivial patch fixing the build...

devnexen accepted this revision.Jun 19 2019, 1:05 AM
This revision is now accepted and ready to land.Jun 19 2019, 1:05 AM
This revision was automatically updated to reflect the committed changes.