[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2020-09-22 Thread msl0000023508 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #11 from WHR  ---
Created attachment 49259
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49259&action=edit
gcc-10.2.0-sanitizer-madvise-fix.diff

Replace non-standard madvise(2) with posix_madvise(3).

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2020-09-22 Thread msl0000023508 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #10 from WHR  ---
Created attachment 49258
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49258&action=edit
gcc-10.2.0-sanitizer-solaris-libelf-h-without-file-offset-bits-64.diff

Solaris libelf.h doesn't work with _FILE_OFFSET_BITS=64 for i386 target.

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2020-09-22 Thread msl0000023508 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #9 from WHR  ---
Created attachment 49257
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49257&action=edit
gcc-10.2.0-sanitizer-linux-procfs-fix.diff

Limit this Linux procfs code to Linux only.

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2020-09-22 Thread msl0000023508 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

WHR  changed:

   What|Removed |Added

 CC||msl023508 at gmail dot com

--- Comment #8 from WHR  ---
I found this sanitizer-related issue when building GCC 10.2 for Solaris; and
after manual source browseing I believe this bug still existing in the master
branch.

To fix the O_DIRECTORY issue, my opinion is to remove its use by using '#if
SANITIZER_LINUX', because the only place it gets used is some Linux-specific
code, that uses Linux procfs path '/proc/%d/task/'.

I also found some other issues.

Solaris libelf.h doesn't work with _FILE_OFFSET_BITS=64 for i386 target, 
/usr/include/libelf.h:42:2: error: #error "large files are not supported by
libelf"

Last issue is the code uses madvise(2), which is non-standard, and therefore
didn't get declared by Solaris system headers without some addition macros; the
standard interface posix_madvise(3) should be used instead.

I will upload my patches shortly.

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #7 from Andrew Pinski  ---
(In reply to Fazal Majid from comment #6)
> @Andrew Pinski
> 
> I looked for the files in question at https://github.com/google/sanitizers
> and couldn't find them, so I assumed they were the GCC-specific port of the
> LLVM sanitizer code.

That is because upstream is part of the LLVM compiler-rt repo now.  E.g.
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_linux.cc

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread gcc at sentfrom dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #6 from Fazal Majid  ---
@Andrew Pinski

I looked for the files in question at https://github.com/google/sanitizers and
couldn't find them, so I assumed they were the GCC-specific port of the LLVM
sanitizer code.

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread gcc at sentfrom dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #5 from Fazal Majid  ---
Yet another compile issue:

mordac
~/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libsanitizer/sanitizer_common>/bin/ksh
../libtool  --tag=CXX   --mode=compile
/home/majid/build/gcc-9.1.0/obj/./gcc/xgcc -shared-libgcc
-B/home/majid/build/gcc-9.1.0/obj/./gcc -nostdinc++
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/src
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/src/.libs
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/libsupc++/.libs
-B/usr/local/x86_64-pc-solaris2.11/bin/ -B/usr/local/x86_64-pc-solaris2.11/lib/
-isystem /usr/local/x86_64-pc-solaris2.11/include -isystem
/usr/local/x86_64-pc-solaris2.11/sys-include   -fchecking=1 -D_GNU_SOURCE
-D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-DHAVE_RPC_XDR_H=1 -DHAVE_TIRPC_RPC_XDR_H=0 -I.
-I../../../../libsanitizer/sanitizer_common -I..  -I
../../../../libsanitizer/include -isystem
../../../../libsanitizer/include/system  -Wall -W -Wno-unused-parameter
-Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions
-fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden
-Wno-variadic-macros -I../../libstdc++-v3/include
-I../../libstdc++-v3/include/x86_64-pc-solaris2.11
-I../../../../libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++11 
-DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I
../../../../libsanitizer/../libbacktrace -I ../libbacktrace -I
../../../../libsanitizer/../include -include
../../../../libsanitizer/libbacktrace/backtrace-rename.h -g -O2 -MT
sanitizer_posix_libcdep.lo -MD -MP -MF .deps/sanitizer_posix_libcdep.Tpo -c -o
sanitizer_posix_libcdep.lo
../../../../libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
libtool: compile:  /home/majid/build/gcc-9.1.0/obj/./gcc/xgcc -shared-libgcc
-B/home/majid/build/gcc-9.1.0/obj/./gcc -nostdinc++
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/src
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/src/.libs
-L/home/majid/build/gcc-9.1.0/obj/x86_64-pc-solaris2.11/libstdc++-v3/libsupc++/.libs
-B/usr/local/x86_64-pc-solaris2.11/bin/ -B/usr/local/x86_64-pc-solaris2.11/lib/
-isystem /usr/local/x86_64-pc-solaris2.11/include -isystem
/usr/local/x86_64-pc-solaris2.11/sys-include -fchecking=1 -D_GNU_SOURCE
-D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-DHAVE_RPC_XDR_H=1 -DHAVE_TIRPC_RPC_XDR_H=0 -I.
-I../../../../libsanitizer/sanitizer_common -I.. -I
../../../../libsanitizer/include -isystem
../../../../libsanitizer/include/system -Wall -W -Wno-unused-parameter
-Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions
-fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden
-Wno-variadic-macros -I../../libstdc++-v3/include
-I../../libstdc++-v3/include/x86_64-pc-solaris2.11
-I../../../../libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++11
-DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I
../../../../libsanitizer/../libbacktrace -I ../libbacktrace -I
../../../../libsanitizer/../include -include
../../../../libsanitizer/libbacktrace/backtrace-rename.h -g -O2 -MT
sanitizer_posix_libcdep.lo -MD -MP -MF .deps/sanitizer_posix_libcdep.Tpo -c
../../../../libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc  -fPIC
-DPIC -o .libs/sanitizer_posix_libcdep.o
../../../../libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc: In
function 'void __sanitizer::ReleaseMemoryPagesToOS(__sanitizer::uptr,
__sanitizer::uptr)':
../../../../libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc:66:5:
error: 'madvise' was not declared in this scope
   66 | madvise((char *)beg_aligned, end_aligned - beg_aligned,
  | ^~~

That's because with these settings /usr/include/mman.h defines posix_madvise()
but not advise().

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #4 from Andrew Pinski  ---
Patches to sanitizer should be sent upstream first.

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread gcc at sentfrom dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #3 from Fazal Majid  ---
Created attachment 46283
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46283&action=edit
Patch for the glob_t issue

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread gcc at sentfrom dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #2 from Fazal Majid  ---
Created attachment 46282
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46282&action=edit
Patch for the O_DIRECTORY issue

[Bug sanitizer/90337] sanitizer_linux.cc Fails to compile on Illumos-derived Solaris

2019-05-03 Thread gcc at sentfrom dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90337

--- Comment #1 from Fazal Majid  ---
Another error, due to glob_t having gained some extra fields in newer versions
of Illumos (apparently based on BSD code contributed by Guide van Rossum).

Oracle Solaris:

typedef struct  glob_t  {
size_t  gl_pathc;   /* Count of paths matched by pattern */
char**gl_pathv; /* List of matched pathnames */
size_t  gl_offs;/* # of slots reserved in gl_pathv */
/* following are internal to the implementation */
char**gl_pathp; /* gl_pathv + gl_offs */
int gl_pathn;   /* # of elements allocated */
}   glob_t;

Illumos (see also:
https://github.com/illumos/illumos-gate/commit/a5229c74bcec7e2b136379c59a46f4b0717fd516)

typedef struct  glob_t  {
/*
 * Members specified by POSIX
 */
size_t  gl_pathc;   /* Total count of paths matched by pattern */
char**gl_pathv; /* List of matched pathnames */
size_t  gl_offs;/* # of slots reserved in gl_pathv */

/*
 * Internal-use members:
 *
 * NB: The next two members are carried in both the
 * libc backward compatibility wrapper functions and
 * the extended functions.
 */
char**gl_pathp; /* gl_pathv + gl_offs */
int gl_pathn;   /* # of elements allocated */

/*
 * Non-POSIX extensions
 *
 * NB: The following members are not carried in
 * the libc backward compatibility wrapper functions.
 */
int gl_matchc;  /* Count of paths matching pattern. */
int gl_flags;   /* Copy of flags parameter to glob. */
struct  stat **gl_statv; /* Stat entries corresponding to gl_pathv */

/*
 * Alternate filesystem access methods for glob; replacement
 * versions of closedir(3), readdir(3), opendir(3), stat(2)
 * and lstat(2).
 */
void (*gl_closedir)(void *);
struct dirent *(*gl_readdir)(void *);
void *(*gl_opendir)(const char *);
int (*gl_lstat)(const char *, struct stat *);
int (*gl_stat)(const char *, struct stat *);
}   glob_t;

Patch p2.txt addresses this