Skip to content

Commit cd31e78

Browse files
committed
[Sanitizers] Fix sanitizer_posix_libcdep.cc compilation on Solaris 11.5
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. Differential Revision: https://reviews.llvm.org/D62892 llvm-svn: 363778
1 parent b6e2093 commit cd31e78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end) {
7070

7171
bool NoHugePagesInRegion(uptr addr, uptr size) {
7272
#ifdef MADV_NOHUGEPAGE // May not be defined on old systems.
73-
return madvise((void *)addr, size, MADV_NOHUGEPAGE) == 0;
73+
return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
7474
#else
7575
return true;
7676
#endif // MADV_NOHUGEPAGE
7777
}
7878

7979
bool DontDumpShadowMemory(uptr addr, uptr length) {
8080
#if defined(MADV_DONTDUMP)
81-
return madvise((void *)addr, length, MADV_DONTDUMP) == 0;
81+
return madvise((char *)addr, length, MADV_DONTDUMP) == 0;
8282
#elif defined(MADV_NOCORE)
83-
return madvise((void *)addr, length, MADV_NOCORE) == 0;
83+
return madvise((char *)addr, length, MADV_NOCORE) == 0;
8484
#else
8585
return true;
8686
#endif // MADV_DONTDUMP

0 commit comments

Comments
 (0)