public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] assorted patches for uClibc support
@ 2013-04-04 23:08 Bernhard Reutner-Fischer
  2013-04-04 23:18 ` [PATCH 1/3] libgcc: check for fenv.h in dfp configure check Bernhard Reutner-Fischer
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-04 23:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, libstdc++

Hi,

The following patches were bootstrapped and regtested on
x86_64-unknown-linux-gnu without new regressions.

They fix a few problems i faced when building against uClibc.

Ok for trunk and, in a week or two, the 4.8 branch?

PS:
I would like to ask the libstdc++ folks to advise on the tmpnam part..

thanks and cheers,


Bernhard Reutner-Fischer (3):
  libgcc: check for fenv.h in dfp configure check
  libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  libsanitizer: add LFS guards

 libgcc/configure                                          |   13 +++++++++++++
 libgcc/configure.ac                                       |    9 ++++++++-
 libsanitizer/interception/interception_type_test.cc       |    2 +-
 libsanitizer/sanitizer_common/sanitizer_allocator.cc      |    4 +++-
 .../sanitizer_common/sanitizer_platform_limits_posix.cc   |    4 +++-
 libstdc++-v3/include/c_global/cstdio                      |    2 ++
 6 files changed, 30 insertions(+), 4 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 1/3] libgcc: check for fenv.h in dfp configure check
  2013-04-04 23:08 [PATCH 0/3] assorted patches for uClibc support Bernhard Reutner-Fischer
@ 2013-04-04 23:18 ` Bernhard Reutner-Fischer
  2013-04-05  6:26   ` Ian Lance Taylor
  2013-04-04 23:32 ` [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY Bernhard Reutner-Fischer
  2013-04-05  0:25 ` [PATCH 3/3] libsanitizer: add LFS guards Bernhard Reutner-Fischer
  2 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-04 23:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, ian

uClibc can be built without fenv support, extend the configure check for
decimal floating point to probe the existance of fenv.h, too.

libgcc/ChangeLog:

2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* configure.ac (libgcc_cv_dfp): Extend check to probe fenv.h
	availability.
	* configure: Regenerate

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libgcc/configure    |   13 +++++++++++++
 libgcc/configure.ac |    9 ++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libgcc/configure b/libgcc/configure
index 1425df6..90936e8 100644
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -4048,7 +4048,20 @@ if test "${libgcc_cv_dfp+set}" = set; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+
+#include <fenv.h>
+
+int
+main ()
+{
+
 _Decimal32 x;
+int fe_except =
+  FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT;
+
+  ;
+  return 0;
+}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
   libgcc_cv_dfp=yes
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 8b7aba5..e3d713d 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -172,7 +172,14 @@ AC_SUBST(long_double_type_size)
 
 # Check for decimal float support.
 AC_CACHE_CHECK([whether decimal floating point is supported], [libgcc_cv_dfp],
-	       [AC_COMPILE_IFELSE([_Decimal32 x;], [libgcc_cv_dfp=yes],
+	       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <fenv.h>
+]], [[
+_Decimal32 x;
+int fe_except =
+  FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT;
+]])],
+				  [libgcc_cv_dfp=yes],
 				  [libgcc_cv_dfp=no])])
 decimal_float=$libgcc_cv_dfp
 AC_SUBST(decimal_float)
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-04 23:08 [PATCH 0/3] assorted patches for uClibc support Bernhard Reutner-Fischer
  2013-04-04 23:18 ` [PATCH 1/3] libgcc: check for fenv.h in dfp configure check Bernhard Reutner-Fischer
@ 2013-04-04 23:32 ` Bernhard Reutner-Fischer
  2013-04-05  3:57   ` Gabriel Dos Reis
  2013-04-05  0:25 ` [PATCH 3/3] libsanitizer: add LFS guards Bernhard Reutner-Fischer
  2 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-04 23:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, libstdc++, paolo.carlini, gdr

POSIX.1-2008 (SUSv4) marks tmpnam() as obsolescent. As such it is not
available in uClibc unless SUSv4 legacy stuff is enabled.

libstdc++-v3/ChangeLog

2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* include/c_global/cstdio: On uClibc guard ::tmpnam with SUSv4
	legacy availability.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libstdc++-v3/include/c_global/cstdio |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index fcbec0c..037a668 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -131,7 +131,9 @@ namespace std
   using ::sprintf;
   using ::sscanf;
   using ::tmpfile;
+#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
   using ::tmpnam;
+#endif
   using ::ungetc;
   using ::vfprintf;
   using ::vprintf;
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 3/3] libsanitizer: add LFS guards
  2013-04-04 23:08 [PATCH 0/3] assorted patches for uClibc support Bernhard Reutner-Fischer
  2013-04-04 23:18 ` [PATCH 1/3] libgcc: check for fenv.h in dfp configure check Bernhard Reutner-Fischer
  2013-04-04 23:32 ` [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY Bernhard Reutner-Fischer
@ 2013-04-05  0:25 ` Bernhard Reutner-Fischer
       [not found]   ` <CAGQ9bdy6o_pbZx-xn2TmkNoj0iGCCV2wj_rfhN5e-XKjo0Jz=g@mail.gmail.com>
  2013-04-05  8:32   ` Jakub Jelinek
  2 siblings, 2 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-05  0:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, jakub, dodji, kcc, dvyukov

uClibc can be built without Largefile support, add the corresponding
guards. uClibc does not have __libc_malloc()/__libc_free(), add guard.

libsanitizer/ChangeLog

2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* sanitizer_common/sanitizer_allocator.cc (libc_malloc,
	libc_free): Guard with !uClibc.
	* interception/interception_type_test.cc <OFF64_T>: add LFS guard.
	* sanitizer_common/sanitizer_platform_limits_posix.cc
	<struct_stat64_sz, struct_rlimit64_sz, struct_statfs64_sz>: Likewise.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libsanitizer/interception/interception_type_test.cc              |    2 +-
 libsanitizer/sanitizer_common/sanitizer_allocator.cc             |    4 +++-
 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc |    4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libsanitizer/interception/interception_type_test.cc b/libsanitizer/interception/interception_type_test.cc
index f664eee..91fab63 100644
--- a/libsanitizer/interception/interception_type_test.cc
+++ b/libsanitizer/interception/interception_type_test.cc
@@ -22,7 +22,7 @@ COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
 COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
 COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
 
-#ifndef __APPLE__
+#if !defined __APPLE__ && (defined __USE_LARGEFILE64 && defined __off64_t_defined)
 COMPILER_CHECK(sizeof(OFF64_T) == sizeof(off64_t));
 #endif
 
diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator.cc b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
index a54de9d..e17cf22 100644
--- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
@@ -9,11 +9,13 @@
 // run-time libraries.
 // This allocator that is used inside run-times.
 //===----------------------------------------------------------------------===//
+
+#include <features.h>
 #include "sanitizer_common.h"
 
 // FIXME: We should probably use more low-level allocator that would
 // mmap some pages and split them into chunks to fulfill requests.
-#if defined(__linux__) && !defined(__ANDROID__)
+#if defined(__linux__) && !defined(__ANDROID__) && !defined __UCLIBC__
 extern "C" void *__libc_malloc(__sanitizer::uptr size);
 extern "C" void __libc_free(void *ptr);
 # define LIBC_MALLOC __libc_malloc
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index c4be1aa..c5e8f19 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -32,7 +32,9 @@
 namespace __sanitizer {
   unsigned struct_utsname_sz = sizeof(struct utsname);
   unsigned struct_stat_sz = sizeof(struct stat);
+#ifdef __USE_LARGEFILE64
   unsigned struct_stat64_sz = sizeof(struct stat64);
+#endif
   unsigned struct_rusage_sz = sizeof(struct rusage);
   unsigned struct_tm_sz = sizeof(struct tm);
 
@@ -43,7 +45,7 @@ namespace __sanitizer {
   unsigned struct_epoll_event_sz = sizeof(struct epoll_event);
 #endif // __linux__
 
-#if defined(__linux__) && !defined(__ANDROID__)
+#if defined(__linux__) && !defined(__ANDROID__) && defined __USE_LARGEFILE64
   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
 #endif // __linux__ && !__ANDROID__
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-04 23:32 ` [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY Bernhard Reutner-Fischer
@ 2013-04-05  3:57   ` Gabriel Dos Reis
  2013-04-05 10:23     ` Rainer Orth
  0 siblings, 1 reply; 39+ messages in thread
From: Gabriel Dos Reis @ 2013-04-05  3:57 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, libstdc++, paolo.carlini

On Thu, Apr 4, 2013 at 2:53 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> POSIX.1-2008 (SUSv4) marks tmpnam() as obsolescent. As such it is not
> available in uClibc unless SUSv4 legacy stuff is enabled.
>
> libstdc++-v3/ChangeLog
>
> 2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>
>         * include/c_global/cstdio: On uClibc guard ::tmpnam with SUSv4
>         legacy availability.
>
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> ---
>  libstdc++-v3/include/c_global/cstdio |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
> index fcbec0c..037a668 100644
> --- a/libstdc++-v3/include/c_global/cstdio
> +++ b/libstdc++-v3/include/c_global/cstdio
> @@ -131,7 +131,9 @@ namespace std
>    using ::sprintf;
>    using ::sscanf;
>    using ::tmpfile;
> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>    using ::tmpnam;
> +#endif
>    using ::ungetc;
>    using ::vfprintf;
>    using ::vprintf;
> --
> 1.7.10.4
>

Sounds good to me.

-- Gaby

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/3] libgcc: check for fenv.h in dfp configure check
  2013-04-04 23:18 ` [PATCH 1/3] libgcc: check for fenv.h in dfp configure check Bernhard Reutner-Fischer
@ 2013-04-05  6:26   ` Ian Lance Taylor
  2013-11-08 10:30     ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Ian Lance Taylor @ 2013-04-05  6:26 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, Ian Lance Taylor

On Thu, Apr 4, 2013 at 12:53 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
>
> 2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>
>         * configure.ac (libgcc_cv_dfp): Extend check to probe fenv.h
>         availability.
>         * configure: Regenerate

This is OK.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] libsanitizer: add LFS guards
       [not found]   ` <CAGQ9bdy6o_pbZx-xn2TmkNoj0iGCCV2wj_rfhN5e-XKjo0Jz=g@mail.gmail.com>
@ 2013-04-05  8:29     ` Konstantin Serebryany
  0 siblings, 0 replies; 39+ messages in thread
From: Konstantin Serebryany @ 2013-04-05  8:29 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: GCC Patches, Jakub Jelinek, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov

[resending in plain text]

On Fri, Apr 5, 2013 at 10:24 AM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Hi Bernhard,
>
> The libsanitizer code is the exact copy of some revision of the upstream
> code in LLVM repo.
> libsanitizer/README.gcc:
>   Trivial and urgent fixes (portability, build fixes, etc.) may go directly
> to the
>   GCC tree.  All non-trivial changes, functionality improvements, etc.
> should go
>   through the upstream tree first and then be merged back to the GCC tree.
>
> These patches look trivial, but they will not apply to upstream trunk
> because we've changed how we use the guards.
> So, I'd ask you to apply the changes to upstream too (or, better, do it
> first), otherwise they will get lost during the next merge.
>
> I don't mind if you apply the patches to 4.8 branch, but I don't think I may
> approve it.
>
>
>
>
> On Thu, Apr 4, 2013 at 11:53 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
>>
>> uClibc can be built without Largefile support, add the corresponding
>> guards. uClibc does not have __libc_malloc()/__libc_free(), add guard.
>>
>> libsanitizer/ChangeLog
>>
>> 2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>>
>>         * sanitizer_common/sanitizer_allocator.cc (libc_malloc,
>>         libc_free): Guard with !uClibc.
>>         * interception/interception_type_test.cc <OFF64_T>: add LFS guard.
>>         * sanitizer_common/sanitizer_platform_limits_posix.cc
>>         <struct_stat64_sz, struct_rlimit64_sz, struct_statfs64_sz>:
>> Likewise.
>>
>> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
>> ---
>>  libsanitizer/interception/interception_type_test.cc              |    2
>> +-
>>  libsanitizer/sanitizer_common/sanitizer_allocator.cc             |    4
>> +++-
>>  libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc |    4
>> +++-
>>  3 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/libsanitizer/interception/interception_type_test.cc
>> b/libsanitizer/interception/interception_type_test.cc
>> index f664eee..91fab63 100644
>> --- a/libsanitizer/interception/interception_type_test.cc
>> +++ b/libsanitizer/interception/interception_type_test.cc
>> @@ -22,7 +22,7 @@ COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
>>  COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
>>  COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
>>
>> -#ifndef __APPLE__
>> +#if !defined __APPLE__ && (defined __USE_LARGEFILE64 && defined
>> __off64_t_defined)
>>  COMPILER_CHECK(sizeof(OFF64_T) == sizeof(off64_t));
>>  #endif
>>
>> diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> index a54de9d..e17cf22 100644
>> --- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> @@ -9,11 +9,13 @@
>>  // run-time libraries.
>>  // This allocator that is used inside run-times.
>>
>> //===----------------------------------------------------------------------===//
>> +
>> +#include <features.h>
>>  #include "sanitizer_common.h"
>>
>>  // FIXME: We should probably use more low-level allocator that would
>>  // mmap some pages and split them into chunks to fulfill requests.
>> -#if defined(__linux__) && !defined(__ANDROID__)
>> +#if defined(__linux__) && !defined(__ANDROID__) && !defined __UCLIBC__
>>  extern "C" void *__libc_malloc(__sanitizer::uptr size);
>>  extern "C" void __libc_free(void *ptr);
>>  # define LIBC_MALLOC __libc_malloc
>> diff --git
>> a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
>> b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
>> index c4be1aa..c5e8f19 100644
>> --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
>> +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
>> @@ -32,7 +32,9 @@
>>  namespace __sanitizer {
>>    unsigned struct_utsname_sz = sizeof(struct utsname);
>>    unsigned struct_stat_sz = sizeof(struct stat);
>> +#ifdef __USE_LARGEFILE64
>>    unsigned struct_stat64_sz = sizeof(struct stat64);
>> +#endif
>>    unsigned struct_rusage_sz = sizeof(struct rusage);
>>    unsigned struct_tm_sz = sizeof(struct tm);
>>
>> @@ -43,7 +45,7 @@ namespace __sanitizer {
>>    unsigned struct_epoll_event_sz = sizeof(struct epoll_event);
>>  #endif // __linux__
>>
>> -#if defined(__linux__) && !defined(__ANDROID__)
>> +#if defined(__linux__) && !defined(__ANDROID__) && defined
>> __USE_LARGEFILE64
>>    unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
>>    unsigned struct_statfs64_sz = sizeof(struct statfs64);
>>  #endif // __linux__ && !__ANDROID__
>> --
>> 1.7.10.4
>>
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] libsanitizer: add LFS guards
  2013-04-05  0:25 ` [PATCH 3/3] libsanitizer: add LFS guards Bernhard Reutner-Fischer
       [not found]   ` <CAGQ9bdy6o_pbZx-xn2TmkNoj0iGCCV2wj_rfhN5e-XKjo0Jz=g@mail.gmail.com>
@ 2013-04-05  8:32   ` Jakub Jelinek
  2013-04-05  9:02     ` Konstantin Serebryany
  1 sibling, 1 reply; 39+ messages in thread
From: Jakub Jelinek @ 2013-04-05  8:32 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, dodji, kcc, dvyukov

On Thu, Apr 04, 2013 at 09:53:30PM +0200, Bernhard Reutner-Fischer wrote:
> uClibc can be built without Largefile support, add the corresponding
> guards. uClibc does not have __libc_malloc()/__libc_free(), add guard.

Ugh, this is very ugly.  In addition to the stuff mentioned by Konstantin
that this really should go into upstream first:

> --- a/libsanitizer/interception/interception_type_test.cc
> +++ b/libsanitizer/interception/interception_type_test.cc
> @@ -22,7 +22,7 @@ COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
>  COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
>  COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
>  
> -#ifndef __APPLE__
> +#if !defined __APPLE__ && (defined __USE_LARGEFILE64 && defined __off64_t_defined)

Using the internal implementation detail of __USE_LARGEFILE64 is very ugly,
but why __off64_t_defined?  That macro is there just to avoid typedefing it
multiple times, if you include more than one of the sys/types.h, stdio.h and
unistd.h headers.  If you include any of those headers, it will be defined
when __USE_LARGEFILE64 is defined.  Or is uClibc not guaranteeing that?

> --- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> @@ -9,11 +9,13 @@
>  // run-time libraries.
>  // This allocator that is used inside run-times.
>  //===----------------------------------------------------------------------===//
> +
> +#include <features.h>

I'm afraid features.h won't exist on many targets, it isn't a standard
header.  I'd say you want to include some standard header instead (stdio.h?)
or guard this.

	Jakub

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] libsanitizer: add LFS guards
  2013-04-05  8:32   ` Jakub Jelinek
@ 2013-04-05  9:02     ` Konstantin Serebryany
  2013-04-05 12:07       ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Konstantin Serebryany @ 2013-04-05  9:02 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Bernhard Reutner-Fischer, GCC Patches, Dodji Seketeli,
	Kostya Serebryany, Dmitry Vyukov

On Fri, Apr 5, 2013 at 10:37 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Apr 04, 2013 at 09:53:30PM +0200, Bernhard Reutner-Fischer wrote:
>> uClibc can be built without Largefile support, add the corresponding
>> guards. uClibc does not have __libc_malloc()/__libc_free(), add guard.
>
> Ugh, this is very ugly.  In addition to the stuff mentioned by Konstantin
> that this really should go into upstream first:
>
>> --- a/libsanitizer/interception/interception_type_test.cc
>> +++ b/libsanitizer/interception/interception_type_test.cc
>> @@ -22,7 +22,7 @@ COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
>>  COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
>>  COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
>>
>> -#ifndef __APPLE__
>> +#if !defined __APPLE__ && (defined __USE_LARGEFILE64 && defined __off64_t_defined)
>
> Using the internal implementation detail of __USE_LARGEFILE64 is very ugly,
> but why __off64_t_defined?  That macro is there just to avoid typedefing it
> multiple times, if you include more than one of the sys/types.h, stdio.h and
> unistd.h headers.  If you include any of those headers, it will be defined
> when __USE_LARGEFILE64 is defined.  Or is uClibc not guaranteeing that?
>
>> --- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
>> @@ -9,11 +9,13 @@
>>  // run-time libraries.
>>  // This allocator that is used inside run-times.
>>  //===----------------------------------------------------------------------===//
>> +
>> +#include <features.h>

I overlooked this.
The sanitizer files (other than *_linux.cc and such) may not include
*any* system header files.
We've been there, it cost us lots of pain and lots of work to get rid of.

--kcc


>
> I'm afraid features.h won't exist on many targets, it isn't a standard
> header.  I'd say you want to include some standard header instead (stdio.h?)
> or guard this.
>
>         Jakub

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05  3:57   ` Gabriel Dos Reis
@ 2013-04-05 10:23     ` Rainer Orth
  2013-04-05 10:38       ` Gabriel Dos Reis
  0 siblings, 1 reply; 39+ messages in thread
From: Rainer Orth @ 2013-04-05 10:23 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: Bernhard Reutner-Fischer, gcc-patches, libstdc++, paolo.carlini

Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

>> diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
>> index fcbec0c..037a668 100644
>> --- a/libstdc++-v3/include/c_global/cstdio
>> +++ b/libstdc++-v3/include/c_global/cstdio
>> @@ -131,7 +131,9 @@ namespace std
>>    using ::sprintf;
>>    using ::sscanf;
>>    using ::tmpfile;
>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>    using ::tmpnam;
>> +#endif
>>    using ::ungetc;
>>    using ::vfprintf;
>>    using ::vprintf;
>> --
>> 1.7.10.4
>>
>
> Sounds good to me.

Do we really want to use target-specific macros directly instead of
defining something more abstract either via a configure test or a define
in config/os/uclibc?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05 10:23     ` Rainer Orth
@ 2013-04-05 10:38       ` Gabriel Dos Reis
  2013-04-05 10:53         ` Rainer Orth
  0 siblings, 1 reply; 39+ messages in thread
From: Gabriel Dos Reis @ 2013-04-05 10:38 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Bernhard Reutner-Fischer, gcc-patches, libstdc++, paolo.carlini

On Fri, Apr 5, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>
>>> diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
>>> index fcbec0c..037a668 100644
>>> --- a/libstdc++-v3/include/c_global/cstdio
>>> +++ b/libstdc++-v3/include/c_global/cstdio
>>> @@ -131,7 +131,9 @@ namespace std
>>>    using ::sprintf;
>>>    using ::sscanf;
>>>    using ::tmpfile;
>>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>>    using ::tmpnam;
>>> +#endif
>>>    using ::ungetc;
>>>    using ::vfprintf;
>>>    using ::vprintf;
>>> --
>>> 1.7.10.4
>>>
>>
>> Sounds good to me.
>
> Do we really want to use target-specific macros directly instead of
> defining something more abstract either via a configure test or a define
> in config/os/uclibc?
>
>         Rainer

What would your suggestion for defineingsomething more abstract that reliably
says whether the feature is deprecated or absent?


>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05 10:38       ` Gabriel Dos Reis
@ 2013-04-05 10:53         ` Rainer Orth
  2013-04-05 11:22           ` Gabriel Dos Reis
  0 siblings, 1 reply; 39+ messages in thread
From: Rainer Orth @ 2013-04-05 10:53 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: Bernhard Reutner-Fischer, gcc-patches, libstdc++, paolo.carlini

Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

> On Fri, Apr 5, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>
>>>> diff --git a/libstdc++-v3/include/c_global/cstdio
>>>> b/libstdc++-v3/include/c_global/cstdio
>>>> index fcbec0c..037a668 100644
>>>> --- a/libstdc++-v3/include/c_global/cstdio
>>>> +++ b/libstdc++-v3/include/c_global/cstdio
>>>> @@ -131,7 +131,9 @@ namespace std
>>>>    using ::sprintf;
>>>>    using ::sscanf;
>>>>    using ::tmpfile;
>>>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>>>    using ::tmpnam;
>>>> +#endif
>>>>    using ::ungetc;
>>>>    using ::vfprintf;
>>>>    using ::vprintf;
>>>> --
>>>> 1.7.10.4
b>>>>
>>>
>>> Sounds good to me.
>>
>> Do we really want to use target-specific macros directly instead of
>> defining something more abstract either via a configure test or a define
>> in config/os/uclibc?
>>
>>         Rainer
>
> What would your suggestion for defineingsomething more abstract that reliably
> says whether the feature is deprecated or absent?

It seems _GLIBCXX_USE_TMPNAM would be in line with the other macros I
see.  Than either configure could test if tmpnam() is available without
special additional macros or config/os/uclibc/os_config.h could define
it to 0, with a default of 1 (best decided by the libstdc++
maintainers).

The configure route seems cleaner to me, especially given that
Bernhard's rationale for uClibc no longer providing it by default
suggests that other systems might follow in the foreseeable future.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05 10:53         ` Rainer Orth
@ 2013-04-05 11:22           ` Gabriel Dos Reis
  2013-04-05 12:34             ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Gabriel Dos Reis @ 2013-04-05 11:22 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Bernhard Reutner-Fischer, gcc-patches, libstdc++, paolo.carlini

On Fri, Apr 5, 2013 at 4:13 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>
>> On Fri, Apr 5, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>>
>>>>> diff --git a/libstdc++-v3/include/c_global/cstdio
>>>>> b/libstdc++-v3/include/c_global/cstdio
>>>>> index fcbec0c..037a668 100644
>>>>> --- a/libstdc++-v3/include/c_global/cstdio
>>>>> +++ b/libstdc++-v3/include/c_global/cstdio
>>>>> @@ -131,7 +131,9 @@ namespace std
>>>>>    using ::sprintf;
>>>>>    using ::sscanf;
>>>>>    using ::tmpfile;
>>>>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>>>>    using ::tmpnam;
>>>>> +#endif
>>>>>    using ::ungetc;
>>>>>    using ::vfprintf;
>>>>>    using ::vprintf;
>>>>> --
>>>>> 1.7.10.4
> b>>>>
>>>>
>>>> Sounds good to me.
>>>
>>> Do we really want to use target-specific macros directly instead of
>>> defining something more abstract either via a configure test or a define
>>> in config/os/uclibc?
>>>
>>>         Rainer
>>
>> What would your suggestion for defineingsomething more abstract that reliably
>> says whether the feature is deprecated or absent?
>
> It seems _GLIBCXX_USE_TMPNAM would be in line with the other macros I
> see.  Than either configure could test if tmpnam() is available without
> special additional macros or config/os/uclibc/os_config.h could define
> it to 0, with a default of 1 (best decided by the libstdc++
> maintainers).
>
> The configure route seems cleaner to me, especially given that
> Bernhard's rationale for uClibc no longer providing it by default
> suggests that other systems might follow in the foreseeable future.
>
>         Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University

sounds reasonable; Bernhard, would you mind amending your patch in
that direction?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] libsanitizer: add LFS guards
  2013-04-05  9:02     ` Konstantin Serebryany
@ 2013-04-05 12:07       ` Bernhard Reutner-Fischer
  2013-04-05 13:06         ` Jakub Jelinek
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-05 12:07 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov

On 5 April 2013 08:42, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
>
> On Fri, Apr 5, 2013 at 10:37 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Thu, Apr 04, 2013 at 09:53:30PM +0200, Bernhard Reutner-Fischer wrote:
> >> uClibc can be built without Largefile support, add the corresponding
> >> guards. uClibc does not have __libc_malloc()/__libc_free(), add guard.
> >
> > Ugh, this is very ugly.  In addition to the stuff mentioned by Konstantin
> > that this really should go into upstream first:
> >
> >> --- a/libsanitizer/interception/interception_type_test.cc
> >> +++ b/libsanitizer/interception/interception_type_test.cc
> >> @@ -22,7 +22,7 @@ COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
> >>  COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
> >>  COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
> >>
> >> -#ifndef __APPLE__
> >> +#if !defined __APPLE__ && (defined __USE_LARGEFILE64 && defined __off64_t_defined)
> >
> > Using the internal implementation detail of __USE_LARGEFILE64 is very ugly,
> > but why __off64_t_defined?  That macro is there just to avoid typedefing it
> > multiple times, if you include more than one of the sys/types.h, stdio.h and
> > unistd.h headers.  If you include any of those headers, it will be defined
> > when __USE_LARGEFILE64 is defined.  Or is uClibc not guaranteeing that?


It does guarantee that, let me see if i can drop that  && defined
__off64_t_defined.
>
> >
> >> --- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> >> +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> >> @@ -9,11 +9,13 @@
> >>  // run-time libraries.
> >>  // This allocator that is used inside run-times.
> >>  //===----------------------------------------------------------------------===//
> >> +
> >> +#include <features.h>
>
> I overlooked this.
> The sanitizer files (other than *_linux.cc and such) may not include
> *any* system header files.
> We've been there, it cost us lots of pain and lots of work to get rid of.


So how do you suggest i should deal with it then?
I do not have a CPP token inside of the compiler to denote the libc
type, AFAICS.

thanks,
>
>
> --kcc
>
>
> >
> > I'm afraid features.h won't exist on many targets, it isn't a standard
> > header.  I'd say you want to include some standard header instead (stdio.h?)
> > or guard this.
> >
> >         Jakub

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05 11:22           ` Gabriel Dos Reis
@ 2013-04-05 12:34             ` Bernhard Reutner-Fischer
  2013-04-11 12:37               ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-05 12:34 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: Rainer Orth, GCC Patches, libstdc++, paolo.carlini

On 5 April 2013 11:23, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> On Fri, Apr 5, 2013 at 4:13 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>
>>> On Fri, Apr 5, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>>>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>>>
>>>>>> diff --git a/libstdc++-v3/include/c_global/cstdio
>>>>>> b/libstdc++-v3/include/c_global/cstdio
>>>>>> index fcbec0c..037a668 100644
>>>>>> --- a/libstdc++-v3/include/c_global/cstdio
>>>>>> +++ b/libstdc++-v3/include/c_global/cstdio
>>>>>> @@ -131,7 +131,9 @@ namespace std
>>>>>>    using ::sprintf;
>>>>>>    using ::sscanf;
>>>>>>    using ::tmpfile;
>>>>>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>>>>>    using ::tmpnam;
>>>>>> +#endif
>>>>>>    using ::ungetc;
>>>>>>    using ::vfprintf;
>>>>>>    using ::vprintf;
>>>>>> --
>>>>>> 1.7.10.4
>> b>>>>
>>>>>
>>>>> Sounds good to me.
>>>>
>>>> Do we really want to use target-specific macros directly instead of
>>>> defining something more abstract either via a configure test or a define
>>>> in config/os/uclibc?
>>>>
>>>>         Rainer
>>>
>>> What would your suggestion for defineingsomething more abstract that reliably
>>> says whether the feature is deprecated or absent?
>>
>> It seems _GLIBCXX_USE_TMPNAM would be in line with the other macros I
>> see.  Than either configure could test if tmpnam() is available without
>> special additional macros or config/os/uclibc/os_config.h could define
>> it to 0, with a default of 1 (best decided by the libstdc++
>> maintainers).
>>
>> The configure route seems cleaner to me, especially given that
>> Bernhard's rationale for uClibc no longer providing it by default
>> suggests that other systems might follow in the foreseeable future.

> sounds reasonable; Bernhard, would you mind amending your patch in
> that direction?

I'll have a look.
Thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] libsanitizer: add LFS guards
  2013-04-05 12:07       ` Bernhard Reutner-Fischer
@ 2013-04-05 13:06         ` Jakub Jelinek
  2014-04-17 14:01           ` [PATCH 0/3] libsanitizer libc conditionals Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Jakub Jelinek @ 2013-04-05 13:06 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Konstantin Serebryany, GCC Patches, Dodji Seketeli,
	Kostya Serebryany, Dmitry Vyukov

On Fri, Apr 05, 2013 at 11:46:44AM +0200, Bernhard Reutner-Fischer wrote:
> > >> --- a/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> > >> +++ b/libsanitizer/sanitizer_common/sanitizer_allocator.cc
> > >> @@ -9,11 +9,13 @@
> > >>  // run-time libraries.
> > >>  // This allocator that is used inside run-times.
> > >>  //===----------------------------------------------------------------------===//
> > >> +
> > >> +#include <features.h>
> >
> > I overlooked this.
> > The sanitizer files (other than *_linux.cc and such) may not include
> > *any* system header files.
> > We've been there, it cost us lots of pain and lots of work to get rid of.
> 
> 
> So how do you suggest i should deal with it then?
> I do not have a CPP token inside of the compiler to denote the libc
> type, AFAICS.

autoconf, and pass some -DHAS___LIBC_MALLOC or similar down to the compiler
(or just -DUCLIBC or whatever, -DUCLIBC would have the advantage that
(provided llvm doesn't support uClibc) that you'd only need to change gcc's
configury)?

	Jakub

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-05 12:34             ` Bernhard Reutner-Fischer
@ 2013-04-11 12:37               ` Bernhard Reutner-Fischer
  2013-04-11 12:46                 ` Paolo Carlini
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-04-11 12:37 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: Rainer Orth, GCC Patches, libstdc++, paolo.carlini

On 5 April 2013 11:48, Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> On 5 April 2013 11:23, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
>> On Fri, Apr 5, 2013 at 4:13 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>>
>>>> On Fri, Apr 5, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>>>>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>>>>
>>>>>>> diff --git a/libstdc++-v3/include/c_global/cstdio
>>>>>>> b/libstdc++-v3/include/c_global/cstdio
>>>>>>> index fcbec0c..037a668 100644
>>>>>>> --- a/libstdc++-v3/include/c_global/cstdio
>>>>>>> +++ b/libstdc++-v3/include/c_global/cstdio
>>>>>>> @@ -131,7 +131,9 @@ namespace std
>>>>>>>    using ::sprintf;
>>>>>>>    using ::sscanf;
>>>>>>>    using ::tmpfile;
>>>>>>> +#if !defined __UCLIBC__ || defined __UCLIBC_SUSV4_LEGACY__
>>>>>>>    using ::tmpnam;
>>>>>>> +#endif
>>>>>>>    using ::ungetc;
>>>>>>>    using ::vfprintf;
>>>>>>>    using ::vprintf;
>>>>>>> --
>>>>>>> 1.7.10.4
>>> b>>>>
>>>>>>
>>>>>> Sounds good to me.
>>>>>
>>>>> Do we really want to use target-specific macros directly instead of
>>>>> defining something more abstract either via a configure test or a define
>>>>> in config/os/uclibc?
>>>>>
>>>>>         Rainer
>>>>
>>>> What would your suggestion for defineingsomething more abstract that reliably
>>>> says whether the feature is deprecated or absent?
>>>
>>> It seems _GLIBCXX_USE_TMPNAM would be in line with the other macros I
>>> see.  Than either configure could test if tmpnam() is available without
>>> special additional macros or config/os/uclibc/os_config.h could define
>>> it to 0, with a default of 1 (best decided by the libstdc++
>>> maintainers).
>>>
>>> The configure route seems cleaner to me, especially given that
>>> Bernhard's rationale for uClibc no longer providing it by default
>>> suggests that other systems might follow in the foreseeable future.
>
>> sounds reasonable; Bernhard, would you mind amending your patch in
>> that direction?
>
> I'll have a look.

Done with the configure check, looks prettier indeed, will followup once tested.

I would have expected that somebody would tell me that omitting
::tmpnam violates 27.9.2 <cstdio> from the spec but noone yelled at me
yet?
> Thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-11 12:37               ` Bernhard Reutner-Fischer
@ 2013-04-11 12:46                 ` Paolo Carlini
  2013-11-08 10:38                   ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Paolo Carlini @ 2013-04-11 12:46 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

Hi,

On 04/11/2013 02:04 PM, Bernhard Reutner-Fischer wrote:
> I would have expected that somebody would tell me that omitting 
> ::tmpnam violates 27.9.2 <cstdio> from the spec but noone yelled at me 
> yet? 
Frankly, I didn't because the targets I really care about aren't 
affected. The actual maintainers of this target should speak.

Paolo.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/3] libgcc: check for fenv.h in dfp configure check
  2013-04-05  6:26   ` Ian Lance Taylor
@ 2013-11-08 10:30     ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-11-08 10:30 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, Ian Lance Taylor

On 4 April 2013 23:01, Ian Lance Taylor <iant@google.com> wrote:
> On Thu, Apr 4, 2013 at 12:53 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
>>
>> 2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>>
>>         * configure.ac (libgcc_cv_dfp): Extend check to probe fenv.h
>>         availability.
>>         * configure: Regenerate
>
> This is OK.

Applied just now as r204562.
thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-04-11 12:46                 ` Paolo Carlini
@ 2013-11-08 10:38                   ` Bernhard Reutner-Fischer
  2013-11-11 11:43                     ` Jonathan Wakely
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-11-08 10:38 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 928 bytes --]

On 11 April 2013 14:18, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
>
> On 04/11/2013 02:04 PM, Bernhard Reutner-Fischer wrote:
>>
>> I would have expected that somebody would tell me that omitting ::tmpnam
>> violates 27.9.2 <cstdio> from the spec but noone yelled at me yet?
>
> Frankly, I didn't because the targets I really care about aren't affected.
> The actual maintainers of this target should speak.

Attaching an updated patch that i was using since March (without
regressions) which takes Rainer's comments about _GLIBCXX_USE_TMPNAM
into account.
Ok for trunk?

libstdc++-v3/ChangeLog

2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

        * acinclude.m4 (GLIBCXX_CHECK_TMPNAM): New check for tmpnam
        function.
        * configure.ac: Use GLIBCXX_CHECK_TMPNAM.
        * (configure, config.h.in): Regenerate.
        * include/c_global/cstdio: Guard ::tmpnam with _GLIBCXX_USE_TMPNAM

[-- Attachment #2: commit-6f2faa2 --]
[-- Type: application/octet-stream, Size: 5533 bytes --]

commit 6f2faa21be1712ceae1fa558587089d37510cc58
Author: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date:   Mon Mar 25 10:46:41 2013 +0100

    libstdc++-v3: Check for obsolescent ::tmpnam
    
    POSIX.1-2008 (SUSv4) marks tmpnam() as obsolescent. As such it is not
    available in uClibc unless SUSv4 legacy stuff is enabled.
    
    Add configure check for tmpnam
    
    libstdc++-v3/ChangeLog
    
    2013-03-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
    
    	* acinclude.m4 (GLIBCXX_CHECK_TMPNAM): New check for tmpnam
    	function.
    	* configure.ac: Use GLIBCXX_CHECK_TMPNAM.
    	* (configure, config.h.in): Regenerate.
    	* include/c_global/cstdio: Guard ::tmpnam with _GLIBCXX_USE_TMPNAM
    
    Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f9d12d0..e0b60be 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3771,6 +3771,33 @@ AC_DEFUN([GLIBCXX_ENABLE_WERROR], [
   GLIBCXX_CONDITIONAL(ENABLE_WERROR, test $enable_werror = yes)
 ])
 
+dnl
+dnl Check whether obsolescent tmpnam is available in <stdio.h>,
+dnl and define _GLIBCXX_USE_TMPNAM.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_TMPNAM], [dnl
+dnl
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -fno-exceptions"
+dnl
+  AC_MSG_CHECKING([for tmpnam])
+  AC_CACHE_VAL(glibcxx_cv_TMPNAM, [dnl
+    GCC_TRY_COMPILE_OR_LINK(
+      [#include <stdio.h>],
+      [char *tmp = tmpnam("NULL");],
+      [glibcxx_cv_TMPNAM=yes],
+      [glibcxx_cv_TMPNAM=no])
+  ])
+  if test $glibcxx_cv_TMPNAM = yes; then
+    AC_DEFINE(_GLIBCXX_USE_TMPNAM, 1, [Define if obsolescent tmpnam is available in <stdio.h>.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_TMPNAM)
+dnl
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+])
 
 dnl
 dnl Check to see if sys/sdt.h exists and that it is suitable for use.
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 4c029d2..adc7d44 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -867,6 +867,9 @@
 /* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */
 #undef _GLIBCXX_USE_SYSCTL_HW_NCPU
 
+/* Define if obsolescent tmpnam is available in <stdio.h>. */
+#undef _GLIBCXX_USE_TMPNAM
+
 /* Define if code specialized for wchar_t should be used. */
 #undef _GLIBCXX_USE_WCHAR_T
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 4be21b1..f7edc50 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -20120,6 +20120,81 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+# Check for tmpnam which is obsolescent in POSIX.1-2008
+
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -fno-exceptions"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tmpnam" >&5
+$as_echo_n "checking for tmpnam... " >&6; }
+  if test "${glibcxx_cv_TMPNAM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      if test x$gcc_no_link = xyes; then
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+char *tmp = tmpnam("NULL");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  glibcxx_cv_TMPNAM=yes
+else
+  glibcxx_cv_TMPNAM=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+char *tmp = tmpnam("NULL");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  glibcxx_cv_TMPNAM=yes
+else
+  glibcxx_cv_TMPNAM=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+
+fi
+
+  if test $glibcxx_cv_TMPNAM = yes; then
+
+$as_echo "#define _GLIBCXX_USE_TMPNAM 1" >>confdefs.h
+
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_TMPNAM" >&5
+$as_echo "$glibcxx_cv_TMPNAM" >&6; }
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
 
   ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
 if test "x$ac_cv_header_locale_h" = x""yes; then :
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 22fc840..1de0f6c 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -213,6 +213,9 @@ GLIBCXX_CHECK_GETTIMEOFDAY
 # For clock_gettime, nanosleep and sched_yield support.
 GLIBCXX_ENABLE_LIBSTDCXX_TIME
 
+# Check for tmpnam which is obsolescent in POSIX.1-2008
+GLIBCXX_CHECK_TMPNAM
+
 AC_LC_MESSAGES
 
 # For hardware_concurrency
diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index b566073..13d6b35 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -137,7 +137,9 @@ namespace std
   using ::sprintf;
   using ::sscanf;
   using ::tmpfile;
+#if _GLIBCXX_USE_TMPNAM
   using ::tmpnam;
+#endif
   using ::ungetc;
   using ::vfprintf;
   using ::vprintf;

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-11-08 10:38                   ` Bernhard Reutner-Fischer
@ 2013-11-11 11:43                     ` Jonathan Wakely
  2013-11-13 10:20                       ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Jonathan Wakely @ 2013-11-11 11:43 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

On 8 November 2013 10:29, Bernhard Reutner-Fischer wrote:
>> On 04/11/2013 02:04 PM, Bernhard Reutner-Fischer wrote:
>>>
>>> I would have expected that somebody would tell me that omitting ::tmpnam
>>> violates 27.9.2 <cstdio> from the spec but noone yelled at me yet?

std::tmpnam, like std::gets, should be killed with fire. If a target C
library doesn't provide it then I have no problem is libstdc++ doesn't
provide it either.

> Attaching an updated patch that i was using since March (without
> regressions) which takes Rainer's comments about _GLIBCXX_USE_TMPNAM
> into account.
> Ok for trunk?

Thanks for following this up.

I'm curious why you use tmpnam("NULL") rather than tmpnam(NULL) or
tmpnam("something")?  Using the string literal "NULL" is a bit
confusing (although not a problem.)

How does __UCLIBC_SUSV4_LEGACY__ get defined?  We'd have a problem if
users defined that at configure time but not later when using the
library.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-11-11 11:43                     ` Jonathan Wakely
@ 2013-11-13 10:20                       ` Bernhard Reutner-Fischer
  2013-11-13 20:42                         ` Jonathan Wakely
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-11-13 10:20 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

On 11 November 2013 12:30, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 8 November 2013 10:29, Bernhard Reutner-Fischer wrote:
>>> On 04/11/2013 02:04 PM, Bernhard Reutner-Fischer wrote:
>>>>
>>>> I would have expected that somebody would tell me that omitting ::tmpnam
>>>> violates 27.9.2 <cstdio> from the spec but noone yelled at me yet?
>
> std::tmpnam, like std::gets, should be killed with fire. If a target C
> library doesn't provide it then I have no problem is libstdc++ doesn't
> provide it either.
>
>> Attaching an updated patch that i was using since March (without
>> regressions) which takes Rainer's comments about _GLIBCXX_USE_TMPNAM
>> into account.
>> Ok for trunk?
>
> Thanks for following this up.
>
> I'm curious why you use tmpnam("NULL") rather than tmpnam(NULL) or
> tmpnam("something")?  Using the string literal "NULL" is a bit
> confusing (although not a problem.)

Yea, perhaps that's confusing, let's use "XYZ" instead.
>
> How does __UCLIBC_SUSV4_LEGACY__ get defined?  We'd have a problem if
> users defined that at configure time but not later when using the
> library.
That would be defined by uClibc's configury, but the latest
"commit-6f2faa2" i attached does not mention this anymore, but does
the check in a libc-agnostic manner?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-11-13 10:20                       ` Bernhard Reutner-Fischer
@ 2013-11-13 20:42                         ` Jonathan Wakely
  2013-12-20 12:16                           ` Bernhard Reutner-Fischer
  2014-04-14 10:09                           ` Bernhard Reutner-Fischer
  0 siblings, 2 replies; 39+ messages in thread
From: Jonathan Wakely @ 2013-11-13 20:42 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

On 13 November 2013 09:22, Bernhard Reutner-Fischer wrote:
> On 11 November 2013 12:30, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> How does __UCLIBC_SUSV4_LEGACY__ get defined?  We'd have a problem if
>> users defined that at configure time but not later when using the
>> library.
> That would be defined by uClibc's configury, but the latest
> "commit-6f2faa2" i attached does not mention this anymore, but does
> the check in a libc-agnostic manner?

Yes, but I was concerned about whether the value of that macro can
change between configuring libstdc++ and users compiling code using
libstdc++.  If it could change (e.g. by users compiling with
-D_POSIX_C_SOURCE=200112L or some other feature test macro) then the
value of _GLIBCXX_USE_TMPNAM (which doesn't change) would be
unreliable and we could end up with a "using ::tmpnam" in the library
that causes errors when users compile.

If it's set when configuring uClibc then it is a constant for a given
libstdc++ installation, so the value of _GLIBCXX_USE_TMPNAM is
reliable.  In that case your change is OK to commit (with or without
the "XYZ" change) - thanks.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-11-13 20:42                         ` Jonathan Wakely
@ 2013-12-20 12:16                           ` Bernhard Reutner-Fischer
  2014-04-08 21:10                             ` Bernhard Reutner-Fischer
  2014-04-14 10:09                           ` Bernhard Reutner-Fischer
  1 sibling, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-12-20 12:16 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

On 13 November 2013 18:56, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 13 November 2013 09:22, Bernhard Reutner-Fischer wrote:
>> On 11 November 2013 12:30, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>> How does __UCLIBC_SUSV4_LEGACY__ get defined?  We'd have a problem if
>>> users defined that at configure time but not later when using the
>>> library.
>> That would be defined by uClibc's configury, but the latest
>> "commit-6f2faa2" i attached does not mention this anymore, but does
>> the check in a libc-agnostic manner?
>
> Yes, but I was concerned about whether the value of that macro can
> change between configuring libstdc++ and users compiling code using
> libstdc++.  If it could change (e.g. by users compiling with
> -D_POSIX_C_SOURCE=200112L or some other feature test macro) then the
> value of _GLIBCXX_USE_TMPNAM (which doesn't change) would be
> unreliable and we could end up with a "using ::tmpnam" in the library
> that causes errors when users compile.
>
> If it's set when configuring uClibc then it is a constant for a given
> libstdc++ installation, so the value of _GLIBCXX_USE_TMPNAM is
> reliable.  In that case your change is OK to commit (with or without
> the "XYZ" change) - thanks.

It is a constant, yes. I will push this after another round of regtests
against current trunk as time permits.

thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-12-20 12:16                           ` Bernhard Reutner-Fischer
@ 2014-04-08 21:10                             ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-08 21:10 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches,
	libstdc++,
	Steve Ellcey

On 20 December 2013 13:16, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 13 November 2013 18:56, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 13 November 2013 09:22, Bernhard Reutner-Fischer wrote:
>>> On 11 November 2013 12:30, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>>> How does __UCLIBC_SUSV4_LEGACY__ get defined?  We'd have a problem if
>>>> users defined that at configure time but not later when using the
>>>> library.
>>> That would be defined by uClibc's configury, but the latest
>>> "commit-6f2faa2" i attached does not mention this anymore, but does
>>> the check in a libc-agnostic manner?
>>
>> Yes, but I was concerned about whether the value of that macro can
>> change between configuring libstdc++ and users compiling code using
>> libstdc++.  If it could change (e.g. by users compiling with
>> -D_POSIX_C_SOURCE=200112L or some other feature test macro) then the
>> value of _GLIBCXX_USE_TMPNAM (which doesn't change) would be
>> unreliable and we could end up with a "using ::tmpnam" in the library
>> that causes errors when users compile.
>>
>> If it's set when configuring uClibc then it is a constant for a given
>> libstdc++ installation, so the value of _GLIBCXX_USE_TMPNAM is
>> reliable.  In that case your change is OK to commit (with or without
>> the "XYZ" change) - thanks.
>
> It is a constant, yes. I will push this after another round of regtests
> against current trunk as time permits.

Just rebased and saw that sje committed this as svn r207009 for me
since i apparently forgot..
Thanks!

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2013-11-13 20:42                         ` Jonathan Wakely
  2013-12-20 12:16                           ` Bernhard Reutner-Fischer
@ 2014-04-14 10:09                           ` Bernhard Reutner-Fischer
  2014-04-14 10:23                             ` Jonathan Wakely
  1 sibling, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-14 10:09 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

Jonathan,

I see that you filed LWG 2249 (gets() removal), may i ask you to take
care of the tmpnam removal, too?
The reasoning would be exactly the same as for gets().

TIA && cheers,

http://wg21.cmeerw.net/lwg/issue2249

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY
  2014-04-14 10:09                           ` Bernhard Reutner-Fischer
@ 2014-04-14 10:23                             ` Jonathan Wakely
  0 siblings, 0 replies; 39+ messages in thread
From: Jonathan Wakely @ 2014-04-14 10:23 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Paolo Carlini, Gabriel Dos Reis, Rainer Orth, GCC Patches, libstdc++

On 14 April 2014 11:09, Bernhard Reutner-Fischer wrote:
> Jonathan,
>
> I see that you filed LWG 2249 (gets() removal), may i ask you to take
> care of the tmpnam removal, too?
> The reasoning would be exactly the same as for gets().

The reason to remove gets() was that it's no longer in the C standard,
but as far as I can tell tmpnam() is still in both C and POSIX, so the
reason cannot be the same.

POSIX marks it as obsolescent, which means it is still part of the
standard, but may be removed in a future version.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 0/3] libsanitizer libc conditionals
  2013-04-05 13:06         ` Jakub Jelinek
@ 2014-04-17 14:01           ` Bernhard Reutner-Fischer
  2014-04-17 14:01             ` [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc Bernhard Reutner-Fischer
                               ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 14:01 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Bernhard Reutner-Fischer, Jakub Jelinek, GCC Patches,
	Dodji Seketeli, Kostya Serebryany, Dmitry Vyukov, llvm-commits

Respun. First two patches are for gcc, the last one is for upstream
LLVM.

The gcc part was bootstrapped and regtested on x86_64-unknown-linux-gnu
without regressions and bootstrapped on x86_64-unknown-linux-uclibc to
verify that the configury works as expected and that the library links
without errors. These two patches are essentially "backports" of the
LLVM bits in patch #3.

The LLVM part was compiled on x86_64 (X86_64 ?) against glibc and
verified that the configury picks up the previously hard-coded values
both with "configure && make" as well as with "cmake && make".

LLVM'er, please install the LLVM bits.

Ok for trunk?


Bernhard Reutner-Fischer (3):
  libsanitizer: Fix !statfs64 builds
  libsanitizer: add conditionals for libc
  [LLVM] [sanitizer] add conditionals for libc

 libsanitizer/asan/Makefile.am                      |   6 +
 libsanitizer/asan/Makefile.in                      |  17 +-
 libsanitizer/config.h.in                           |  60 +++++
 libsanitizer/configure                             | 281 ++++++++++++++++++++-
 libsanitizer/configure.ac                          |  38 +++
 libsanitizer/interception/interception_linux.cc    |   2 +
 libsanitizer/interception/interception_linux.h     |   8 +
 libsanitizer/lsan/Makefile.am                      |   6 +
 libsanitizer/lsan/Makefile.in                      |  11 +-
 libsanitizer/sanitizer_common/Makefile.am          |   5 +
 libsanitizer/sanitizer_common/Makefile.in          |  18 +-
 .../sanitizer_common_interceptors.inc              | 100 +++++++-
 .../sanitizer_platform_interceptors.h              |   4 +-
 .../sanitizer_platform_limits_linux.cc             |   2 +
 .../sanitizer_platform_limits_posix.cc             |  44 +++-
 .../sanitizer_platform_limits_posix.h              |  27 +-
 .../sanitizer_common/sanitizer_posix_libcdep.cc    |   7 +
 libsanitizer/tsan/Makefile.am                      |   6 +
 libsanitizer/tsan/Makefile.in                      |  11 +-
 19 files changed, 619 insertions(+), 34 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 14:01           ` [PATCH 0/3] libsanitizer libc conditionals Bernhard Reutner-Fischer
@ 2014-04-17 14:01             ` Bernhard Reutner-Fischer
  2014-04-17 14:28               ` Konstantin Serebryany
  2014-04-17 14:01             ` [PATCH 1/3] libsanitizer: Fix !statfs64 builds Bernhard Reutner-Fischer
  2014-04-17 14:08             ` [PATCH 2/3] libsanitizer: add conditionals for libc Bernhard Reutner-Fischer
  2 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 14:01 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Bernhard Reutner-Fischer, Jakub Jelinek, GCC Patches,
	Dodji Seketeli, Kostya Serebryany, Dmitry Vyukov, llvm-commits

Conditionalize usage of dlvsym(), nanosleep(), usleep();
Conditionalize layout of struct sigaction and type of it's member
sa_flags.
Conditionalize glob_t members gl_closedir, gl_readdir, gl_opendir,
gl_flags, gl_lstat, gl_stat.
Check for availability of glob.h for use with above members.
Check for availability of netrom/netrom.h, sys/ustat.h (for obsolete
ustat() function), utime.h (for obsolete utime() function), wordexp.h.
Determine size of sigset_t instead of hardcoding it.
Determine size of struct statfs64, if available.

Leave defaults to match what glibc expects but probe them for uClibc.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 CMakeLists.txt                                     |  58 +++++++
 cmake/Modules/CompilerRTUtils.cmake                |  15 ++
 cmake/Modules/FunctionExistsNotStub.cmake          |  56 +++++++
 lib/interception/interception_linux.cc             |   2 +
 lib/interception/interception_linux.h              |   9 ++
 .../sanitizer_common_interceptors.inc              | 101 +++++++++++-
 .../sanitizer_platform_limits_posix.cc             |  44 ++++-
 .../sanitizer_platform_limits_posix.h              |  27 +++-
 lib/sanitizer_common/sanitizer_posix_libcdep.cc    |   9 ++
 make/platform/clang_linux.mk                       | 180 +++++++++++++++++++++
 make/platform/clang_linux_test_libc.c              |  68 ++++++++
 11 files changed, 561 insertions(+), 8 deletions(-)
 create mode 100644 cmake/Modules/FunctionExistsNotStub.cmake
 create mode 100644 make/platform/clang_linux_test_libc.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1a7a1f..af8073e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -330,6 +330,64 @@ if(APPLE)
     -isysroot ${IOSSIM_SDK_DIR})
 endif()
 
+set(ct_c ${COMPILER_RT_SOURCE_DIR}/make/platform/clang_linux_test_libc.c)
+check_include_file(sys/ustat.h HAVE_SYS_USTAT_H)
+check_include_file(utime.h HAVE_UTIME_H)
+check_include_file(wordexp.h HAVE_WORDEXP_H)
+check_include_file(glob.h HAVE_GLOB_H)
+include(FunctionExistsNotStub)
+check_function_exists_not_stub(${ct_c} nanosleep HAVE_NANOSLEEP)
+check_function_exists_not_stub(${ct_c} usleep HAVE_USLEEP)
+include(CheckTypeSize)
+# check for sizeof sigset_t
+set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
+set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} signal.h)
+check_type_size("sigset_t" SIZEOF_SIGSET_T BUILTIN_TYPES_ONLY)
+if(EXISTS HAVE_SIZEOF_SIGSET_T)
+  set(SIZEOF_SIGSET_T ${HAVE_SIZEOF_SIGSET_T})
+endif()
+set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
+# check for sizeof struct statfs64
+set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
+check_include_file(sys/statfs.h HAVE_SYS_STATFS_H)
+check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
+if(HAVE_SYS_STATFS_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/statfs.h)
+endif()
+if(HAVE_SYS_VFS_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/vfs.h)
+endif()
+# Have to pass _LARGEFILE64_SOURCE otherwise there is no struct statfs64.
+# We forcefully enable LFS to retain glibc legacy behaviour herein.
+set(oCMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
+set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE)
+check_type_size("struct statfs64" SIZEOF_STRUCT_STATFS64)
+if(EXISTS HAVE_SIZEOF_STRUCT_STATFS64)
+  set(SIZEOF_STRUCT_STATFS64 ${HAVE_SIZEOF_STRUCT_STATFS64})
+else()
+  set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
+endif()
+set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
+# do not set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
+# it back here either way.
+include(CheckStructHasMember)
+check_struct_has_member(glob_t gl_flags glob.h HAVE_GLOB_T_GL_FLAGS)
+check_struct_has_member(glob_t gl_closedir glob.h HAVE_GLOB_T_GL_CLOSEDIR)
+check_struct_has_member(glob_t gl_readdir glob.h HAVE_GLOB_T_GL_READDIR)
+check_struct_has_member(glob_t gl_opendir glob.h HAVE_GLOB_T_GL_OPENDIR)
+check_struct_has_member(glob_t gl_lstat glob.h HAVE_GLOB_T_GL_LSTAT)
+check_struct_has_member(glob_t gl_stat glob.h HAVE_GLOB_T_GL_STAT)
+
+# folks seem to have an aversion to configure_file? So be it..
+foreach(x HAVE_SYS_USTAT_H HAVE_UTIME_H HAVE_WORDEXP_H HAVE_GLOB_H
+HAVE_NANOSLEEP HAVE_USLEEP SIZEOF_SIGSET_T SIZEOF_STRUCT_STATFS64
+HAVE_GLOB_T_GL_FLAGS HAVE_GLOB_T_GL_CLOSEDIR
+HAVE_GLOB_T_GL_READDIR HAVE_GLOB_T_GL_OPENDIR
+HAVE_GLOB_T_GL_LSTAT HAVE_GLOB_T_GL_STAT)
+def_undef_string(${x} SANITIZER_COMMON_CFLAGS)
+endforeach()
+
+
 # Architectures supported by Sanitizer runtimes. Specific sanitizers may
 # support only subset of these (e.g. TSan works on x86_64 only).
 filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index e22e775..3a0beec 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -59,3 +59,18 @@ macro(append_no_rtti_flag list)
   append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
   append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
 endmacro()
+
+# Appends -Dvalue=${value}/-Uvalue to all strings in ARGN
+macro(def_undef_string condition)
+  if("${${condition}}" STREQUAL "")
+    foreach(str ${ARGN})
+      set(${str} "${${str}} -U${condition}")
+    endforeach()
+  else()
+    foreach(str ${ARGN})
+      set(${str} "${${str}} '-D${condition}=${${condition}}'")
+    endforeach()
+  endif()
+endmacro()
+
+
diff --git a/cmake/Modules/FunctionExistsNotStub.cmake b/cmake/Modules/FunctionExistsNotStub.cmake
new file mode 100644
index 0000000..9f944dd
--- /dev/null
+++ b/cmake/Modules/FunctionExistsNotStub.cmake
@@ -0,0 +1,56 @@
+INCLUDE(CheckFunctionExists)
+
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
+#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+#  CMAKE_REQUIRED_INCLUDES = list of include directories
+
+macro(CHECK_FUNCTION_EXISTS_NOT_STUB CSRC FUNCTION VARIABLE)
+  if(NOT DEFINED CHECKED_STUB_${VARIABLE})
+    set(CHECKED_STUB_${VARIABLE} "done" CACHE INTERNAL "checked stub of ${FUNCTION}")
+    CHECK_FUNCTION_EXISTS("${FUNCTION}" "${VARIABLE}")
+    if(DEFINED ${VARIABLE})
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for stubbed out ${FUNCTION}")
+      endif()
+      if(CMAKE_REQUIRED_INCLUDES)
+        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES
+          "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+      else()
+        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES)
+      endif()
+      set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS ${CMAKE_REQUIRED_FLAGS})
+      try_compile(${VARIABLE}
+        ${CMAKE_BINARY_DIR}
+        "${CSRC}"
+        COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+        CMAKE_FLAGS
+        "-DCOMPILE_DEFINITIONS:STRING=-DL_features_h -DL_AC_CHECK_FUNC=${FUNCTION} -DL_AC_CHECK_FUNC_stub='defined __stub_${FUNCTION} || defined __stub___${FUNCTION}'"
+        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS}"
+        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES}"
+        OUTPUT_VARIABLE OUTPUT
+      )
+    endif()
+    if(${VARIABLE})
+      set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "Determining if function ${FUNCTION} is a stub "
+        "passed with the following output:\n"
+        "${OUTPUT}\n\n")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for stubbed out ${FUNCTION} - no stub")
+      endif()
+    else()
+      set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "Determining if function ${FUNCTION} is a stub "
+        "failed with the following output:\n"
+        "${OUTPUT}\n\n")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for stubbed out ${FUNCTION} - stub found")
+      endif()
+    endif()
+  endif()
+endmacro()
diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
index 6e908ac..c9b4a6e 100644
--- a/lib/interception/interception_linux.cc
+++ b/lib/interception/interception_linux.cc
@@ -24,11 +24,13 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
   return real == wrapper;
 }
 
+#ifdef HAVE_DLVSYM
 #if !defined(__ANDROID__)  // android does not have dlvsym
 void *GetFuncAddrVer(const char *func_name, const char *ver) {
   return dlvsym(RTLD_NEXT, func_name, ver);
 }
 #endif  // !defined(__ANDROID__)
+#endif // HAVE_DLVSYM
 
 }  // namespace __interception
 
diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
index d3f774b..4802fe5 100644
--- a/lib/interception/interception_linux.h
+++ b/lib/interception/interception_linux.h
@@ -25,7 +25,9 @@ namespace __interception {
 // returns true if a function with the given name was found.
 bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
     uptr real, uptr wrapper);
+# ifdef HAVE_DLVSYM
 void *GetFuncAddrVer(const char *func_name, const char *ver);
+# endif /* HAVE_DLVSYM */
 }  // namespace __interception
 
 #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)                          \
@@ -43,5 +45,12 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
      INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
 #endif  // !defined(__ANDROID__)
 
+#ifndef HAVE_DLVSYM
+/* Undo marketing crap above. Probe functionality, use result to decide.  */
+# undef INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD
+# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+	     INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
+#endif
+
 #endif  // INTERCEPTION_LINUX_H
 #endif  // __linux__ || __FreeBSD__
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 0d076a0..0a767d4 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1273,33 +1273,43 @@ static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
 
 static THREADLOCAL __sanitizer_glob_t *pglob_copy;
 
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
 static void wrapped_gl_closedir(void *dir) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
   IndirectExternCall(pglob_copy->gl_closedir)(dir);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_READDIR
 static void *wrapped_gl_readdir(void *dir) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
   return IndirectExternCall(pglob_copy->gl_readdir)(dir);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_OPENDIR
 static void *wrapped_gl_opendir(const char *s) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
   COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
   return IndirectExternCall(pglob_copy->gl_opendir)(s);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_LSTAT
 static int wrapped_gl_lstat(const char *s, void *st) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
   COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
   return IndirectExternCall(pglob_copy->gl_lstat)(s, st);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_STAT
 static int wrapped_gl_stat(const char *s, void *st) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
   COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
   return IndirectExternCall(pglob_copy->gl_stat)(s, st);
 }
+#endif
 
 INTERCEPTOR(int, glob, const char *pattern, int flags,
             int (*errfunc)(const char *epath, int eerrno),
@@ -1307,24 +1317,64 @@ INTERCEPTOR(int, glob, const char *pattern, int flags,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
   __sanitizer_glob_t glob_copy = {
-      0,                  0,                   0,
-      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
-      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
+       0,
+       0,
+       0
+#ifdef HAVE_GLOB_T_GL_FLAGS
+       ,0
+#endif
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
+       ,wrapped_gl_closedir
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
+       ,wrapped_gl_readdir
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
+       ,wrapped_gl_opendir
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
+       ,wrapped_gl_lstat
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
+       ,wrapped_gl_stat
+#endif
+  };
+
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
     pglob_copy = &glob_copy;
   }
   int res = REAL(glob)(pattern, flags, errfunc, pglob);
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
   }
   pglob_copy = 0;
   if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
@@ -1337,24 +1387,63 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
   __sanitizer_glob_t glob_copy = {
-      0,                  0,                   0,
-      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
-      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
+       0,
+       0,
+       0
+#ifdef HAVE_GLOB_T_GL_FLAGS
+       ,0
+#endif
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
+       ,wrapped_gl_closedir
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
+       ,wrapped_gl_readdir
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
+       ,wrapped_gl_opendir
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
+       ,wrapped_gl_lstat
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
+       ,wrapped_gl_stat
+#endif
+  };
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
     pglob_copy = &glob_copy;
   }
   int res = REAL(glob64)(pattern, flags, errfunc, pglob);
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
   }
   pglob_copy = 0;
   if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index 9ae4870..645777f 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -103,14 +103,18 @@
 #endif
 
 #if SANITIZER_LINUX || SANITIZER_FREEBSD
+# ifdef HAVE_UTIME_H
 # include <utime.h>
+# endif
 # include <sys/ptrace.h>
 #endif
 
 #if !SANITIZER_ANDROID
 #include <ifaddrs.h>
 #include <sys/ucontext.h>
+# ifdef HAVE_WORDEXP_H
 #include <wordexp.h>
+# endif
 #endif
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
@@ -119,7 +123,9 @@
 #include <net/if_ppp.h>
 #include <netax25/ax25.h>
 #include <netipx/ipx.h>
+# ifdef HAVE_NETROM_NETROM_H
 #include <netrom/netrom.h>
+# endif
 #include <rpc/xdr.h>
 #include <scsi/scsi.h>
 #include <sys/mtio.h>
@@ -128,7 +134,9 @@
 #include <sys/statvfs.h>
 #include <sys/timex.h>
 #include <sys/user.h>
+# ifdef HAVE_SYS_USTAT_H
 #include <sys/ustat.h>
+# endif
 #include <linux/cyclades.h>
 #include <linux/if_eql.h>
 #include <linux/if_plip.h>
@@ -215,12 +223,16 @@ namespace __sanitizer {
 #if SANITIZER_LINUX || SANITIZER_FREEBSD
   unsigned struct_rlimit_sz = sizeof(struct rlimit);
   unsigned struct_timespec_sz = sizeof(struct timespec);
+# ifdef HAVE_UTIME_H
   unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
+# endif
   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
 #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
+# ifdef HAVE_SYS_USTAT_H
   unsigned struct_ustat_sz = sizeof(struct ustat);
+# endif
   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
 #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
@@ -266,7 +278,9 @@ namespace __sanitizer {
 
 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
   int glob_nomatch = GLOB_NOMATCH;
+# ifdef GLOB_ALTDIRFUNC
   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+# endif
 #endif
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
@@ -370,7 +384,9 @@ namespace __sanitizer {
   unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
   unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
   unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
+# ifdef HAVE_NETROM_NETROM_H
   unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
+# endif
   unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
   unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
   unsigned struct_serial_multiport_struct_sz
@@ -805,10 +821,18 @@ namespace __sanitizer {
   unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
   unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
   unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
+# ifdef SIOCNRDECOBS
   unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
+# endif
+# ifdef SIOCNRGETPARMS
   unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
+# endif
+# ifdef SIOCNRRTCTL
   unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
+# endif
+# ifdef SIOCNRSETPARMS
   unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
+# endif
   unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
   unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
   unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
@@ -890,12 +914,24 @@ CHECK_TYPE_SIZE(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);
+# ifdef HAVE_GLOB_T_GL_FLAGS
 CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
+# endif
+# ifdef HAVE_GLOB_T_GL_CLOSEDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
+# endif
+# ifdef HAVE_GLOB_T_GL_READDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
+# endif
+# ifdef HAVE_GLOB_T_GL_OPENDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
+# endif
+# ifdef HAVE_GLOB_T_GL_LSTAT
 CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
+# endif
+# ifdef HAVE_GLOB_T_GL_STAT
 CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
+# endif
 #endif
 
 CHECK_TYPE_SIZE(addrinfo);
@@ -967,11 +1003,17 @@ CHECK_TYPE_SIZE(sigset_t);
 COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
 // Can't write checks for sa_handler and sa_sigaction due to them being
 // preprocessor macros.
+#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
+#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
 #if SANITIZER_LINUX
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
 #endif
+#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
 
 #if SANITIZER_LINUX
 CHECK_TYPE_SIZE(__sysctl_args);
@@ -991,7 +1033,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
 CHECK_TYPE_SIZE(__kernel_fd_set);
 #endif
 
-#if !SANITIZER_ANDROID
+#ifdef HAVE_WORDEXP_H
 CHECK_TYPE_SIZE(wordexp_t);
 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index a780ee2..04c6a96 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -478,7 +478,8 @@ namespace __sanitizer {
 #elif SANITIZER_LINUX
   struct __sanitizer_sigset_t {
     // The size is determined by looking at sizeof of real sigset_t on linux.
-    uptr val[128 / sizeof(uptr)];
+    /* .. except this should be * sizeof(uptr), not '/', no? */
+    uptr val[SIZEOF_SIGSET_T / sizeof(uptr)];
   };
 #elif SANITIZER_FREEBSD
   struct __sanitizer_sigset_t {
@@ -487,6 +488,17 @@ namespace __sanitizer {
   };
 #endif
 
+#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
+  struct __sanitizer_sigaction {
+    union {
+      void (*sigaction)(int sig, void *siginfo, void *uctx);
+      void (*handler)(int sig);
+    };
+    STRUCT_SIGACTION_SA_FLAGS_TYPE sa_flags;
+    void (*sa_restorer)();
+    __sanitizer_sigset_t sa_mask;
+  };
+#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
   // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
   struct __sanitizer_sigaction {
     union {
@@ -504,6 +516,7 @@ namespace __sanitizer {
     void (*sa_restorer)();
 #endif
   };
+#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
 
 #if SANITIZER_FREEBSD
   typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
@@ -588,13 +601,25 @@ namespace __sanitizer {
     uptr gl_pathc;
     char **gl_pathv;
     uptr gl_offs;
+#  ifdef HAVE_GLOB_T_GL_FLAGS
     int gl_flags;
+#  endif
 
+#  ifdef HAVE_GLOB_T_GL_CLOSEDIR
     void (*gl_closedir)(void *dirp);
+#  endif
+#  ifdef HAVE_GLOB_T_GL_READDIR
     void *(*gl_readdir)(void *dirp);
+#  endif
+#  ifdef HAVE_GLOB_T_GL_OPENDIR
     void *(*gl_opendir)(const char *);
+#  endif
+#  ifdef HAVE_GLOB_T_GL_LSTAT
     int (*gl_lstat)(const char *, void *);
+#  endif
+#  ifdef HAVE_GLOB_T_GL_STAT
     int (*gl_stat)(const char *, void *);
+#  endif
   };
 # elif SANITIZER_FREEBSD
   struct __sanitizer_glob_t {
diff --git a/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
index bb6e587..973f698 100644
--- a/lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -73,7 +73,16 @@ void SleepForSeconds(int seconds) {
 }
 
 void SleepForMillis(int millis) {
+#ifdef HAVE_NANOSLEEP
+  struct timespec ts;
+  ts.tv_sec = millis / 1000;
+  ts.tv_nsec = (millis % 1000) * 1000000;
+  nanosleep(&ts, NULL); /* could as well loop here */
+#elif defined HAVE_USLEEP
   usleep(millis * 1000);
+# else
+  dunno how to SleepForMillis
+#endif
 }
 
 void Abort() {
diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk
index c6921ea..5ce1567 100644
--- a/make/platform/clang_linux.mk
+++ b/make/platform/clang_linux.mk
@@ -74,6 +74,185 @@ Arch.dfsan-x86_64 := x86_64
 Arch.lsan-x86_64 := x86_64
 endif
 
+# TryCompile2 compiler source flags
+# Returns exit code of running a compiler invocation.
+# Same as TryCompile but in outer scope, don't want to touch the other one
+TryCompile2 = \
+  $(shell \
+    cflags=""; \
+    for flag in $(3); do \
+      cflags="$$cflags $$flag"; \
+    done; \
+    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
+    echo $$?)
+
+# our conftest.c
+ct_c = $(ProjSrcRoot)/make/platform/clang_linux_test_libc.c
+
+HAVE_DLVSYM := 1
+HAVE_NETROM_NETROM_H := 1
+HAVE_GLOB_H := 1
+HAVE_NANOSLEEP := 1
+HAVE_GLOB_T_GL_CLOSEDIR := 1
+HAVE_GLOB_T_GL_FLAGS := 1
+HAVE_GLOB_T_GL_LSTAT := 1
+HAVE_GLOB_T_GL_OPENDIR := 1
+HAVE_GLOB_T_GL_READDIR := 1
+HAVE_GLOB_T_GL_STAT := 1
+HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 0
+HAVE_SYS_USTAT_H := 1
+HAVE_USLEEP := 1
+HAVE_UTIME_H := 1
+HAVE_WORDEXP_H := 1
+SIZEOF_STRUCT_STATFS64 := 120
+SIZEOF_SIGSET_T := 128
+STRUCT_SIGACTION_SA_FLAGS_TYPE := int
+
+#ifneq ($(findstring -uclibc,$(CompilerTargetTriple)),)
+# does not work, cross-compilation seems to be non-working?
+ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_UCLIBC -DL_AC_CHECK_HEADER="<stdio.h>",),0)
+  HAVE_DLVSYM :=
+  HAVE_NETROM_NETROM_H :=
+  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned long
+ifneq ($(filter alpha%,$(CompilerTargetTriple)),)
+  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
+endif
+ifneq ($(filter mips%,$(CompilerTargetTriple)),)
+  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
+endif
+  HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 1
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/ustat.h>",),0)
+  HAVE_SYS_USTAT_H :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<utime.h>",),0)
+  HAVE_UTIME_H :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<wordexp.h>",),0)
+  HAVE_WORDEXP_H :=
+endif
+glob_h := -DL_AC_CHECK_HEADER="<glob.h>"
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN $(glob_h),),0)
+  HAVE_GLOB_H :=
+endif
+# check for struct glob members (check for GNU extensions)
+glob_h += -DL_AC_STRUCT="glob_t"
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_flags,),0)
+  HAVE_GLOB_T_GL_FLAGS :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_closedir,),0)
+  HAVE_GLOB_T_GL_CLOSEDIR :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_readdir,),0)
+  HAVE_GLOB_T_GL_READDIR :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_opendir,),0)
+  HAVE_GLOB_T_GL_OPENDIR :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_lstat,),0)
+  HAVE_GLOB_T_GL_LSTAT :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_stat,),0)
+  HAVE_GLOB_T_GL_STAT :=
+endif
+# check misc functions
+# for __stub_* on glibc and uClibc including features.h is enough
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=nanosleep -DL_AC_CHECK_FUNC_stub="defined __stub_nanosleep || defined __stub___nanosleep",),0)
+  HAVE_NANOSLEEP :=
+endif
+ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=usleep -DL_AC_CHECK_FUNC_stub="defined __stub_usleep || defined __stub___usleep",),0)
+  HAVE_USLEEP :=
+endif
+
+# AC_CHECK_SIZEOF, in make
+define ac_check_sizeof
+$(shell \
+if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; \
+then \
+  ac_lo=0 ac_mid=0; \
+  while :; \
+  do \
+  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
+    ac_hi=$$ac_mid; \
+    break; \
+  else \
+    ac_lo=$$(( $$ac_mid + 1 )); \
+    if test $$ac_lo -le $$ac_mid; then ac_lo= ac_hi=; break; fi; \
+    ac_mid=$$(( 2 * $$ac_mid + 1 )); \
+  fi; \
+  done; \
+else \
+  if test $$($(CC) $(1) -DL_AC_SIZEOF_LT=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
+    ac_hi=-1 ac_mid=-1; \
+    while :; \
+    do \
+    if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
+      ac_lo=$$ac_mid; \
+      break; \
+    else \
+      ac_hi=$$(( ($$ac_mid) - 1 )); \
+      if test $$ac_mid -le $$ac_hi; then ac_lo= ac_hi=; break; fi; \
+      ac_mid=$$(( 2 * $$ac_mid )); \
+    fi; \
+    done; \
+  else \
+    ac_lo= ac_hi=; \
+  fi; \
+fi; \
+while test "x$$ac_lo" != "x$$ac_hi"; \
+do \
+  ac_mid=$$(( ($$ac_hi - $$ac_lo) / 2 + $$ac_lo )); \
+  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
+    ac_hi=$$ac_mid; \
+  else \
+    ac_lo=$$(( ($$ac_mid) + 1 )); \
+  fi; \
+done; \
+echo $$(( $$ac_lo + 0 )); \
+)
+endef
+
+# determine sizeof sigset_t
+SIZEOF_SIGSET_T := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<signal.h>" -DL_AC_SIZEOF="sigset_t")
+
+# determine sizeof struct statfs64
+SIZEOF_STRUCT_STATFS64 := 0
+ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/statfs.h>",),0)
+SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/statfs.h>" -DL_AC_SIZEOF="struct statfs64")
+else
+ ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/vfs.h>",),0)
+ SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/vfs.h>" -DL_AC_SIZEOF="struct statfs64")
+ endif
+endif
+# end of -uclibc handling
+endif
+
+define add_config_h_cppflag
+ifeq ($($(1)),)
+CONFIG_H_CPPFLAGS += -U$(1)
+else
+CONFIG_H_CPPFLAGS += '-D$(1)=$($(1))'
+endif
+endef
+
+CONFIG_H_CPPFLAGS :=
+$(eval $(call add_config_h_cppflag,HAVE_DLVSYM))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_H))
+$(eval $(call add_config_h_cppflag,HAVE_NANOSLEEP))
+$(eval $(call add_config_h_cppflag,HAVE_NETROM_NETROM_H))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_CLOSEDIR))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_FLAGS))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_LSTAT))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_OPENDIR))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_READDIR))
+$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_STAT))
+$(eval $(call add_config_h_cppflag,HAVE_STRUCT_SIGACTION_SA_MASK_LAST))
+$(eval $(call add_config_h_cppflag,HAVE_SYS_USTAT_H))
+$(eval $(call add_config_h_cppflag,HAVE_USLEEP))
+$(eval $(call add_config_h_cppflag,HAVE_UTIME_H))
+$(eval $(call add_config_h_cppflag,HAVE_WORDEXP_H))
+$(eval $(call add_config_h_cppflag,SIZEOF_STRUCT_STATFS64))
+$(eval $(call add_config_h_cppflag,SIZEOF_SIGSET_T))
+$(eval $(call add_config_h_cppflag,STRUCT_SIGACTION_SA_FLAGS_TYPE))
 endif
 
 ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
@@ -87,6 +266,7 @@ endif
 
 CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
 SANITIZER_CFLAGS := -fPIE -fno-builtin -gline-tables-only
+CFLAGS += $(CONFIG_H_CPPFLAGS)
 
 CFLAGS.full-i386 := $(CFLAGS) -m32
 CFLAGS.full-x86_64 := $(CFLAGS) -m64
diff --git a/make/platform/clang_linux_test_libc.c b/make/platform/clang_linux_test_libc.c
new file mode 100644
index 0000000..2f9bba8
--- /dev/null
+++ b/make/platform/clang_linux_test_libc.c
@@ -0,0 +1,68 @@
+/* This file is used to check for libc characteristics and features */
+#ifdef L_features_h
+# include <features.h>
+#endif
+
+#ifdef L_AC_CHECK_HEADER
+/* compile-time check for availability of a header */
+# include L_AC_CHECK_HEADER
+#endif
+
+#ifdef L_AC_CHECK_UCLIBC
+# ifndef __UCLIBC__
+choke me /* not uClibc */
+# endif
+#endif
+
+#ifdef L_MAIN
+/* provide a dummy main for the linker */
+int main()
+{
+  return 0;
+}
+#endif
+
+#ifdef L_AC_CHECK_STRUCT_MEMBER
+/* compile-time check for presence of struct member */
+int main()
+{
+  static L_AC_STRUCT ac_aggr;
+  if (ac_aggr.L_AC_CHECK_STRUCT_MEMBER)
+    return 0;
+  return 0;
+}
+#endif
+
+#ifdef L_AC_CHECK_FUNC
+/* check if function (or macro) is available */
+# ifdef __cplusplus
+extern "C"
+# endif
+# if L_AC_CHECK_FUNC_stub
+choke me /* function 'L_AC_CHECK_FUNC' stubbed out! */
+# endif
+char L_AC_CHECK_FUNC ();
+int main ()
+{
+	return L_AC_CHECK_FUNC ();
+}
+#endif
+
+#ifdef L_AC_SIZEOF
+/* Determine sizeof expression */
+int main ()
+{
+# define s (long int) (sizeof (L_AC_SIZEOF))
+# if defined L_AC_SIZEOF_GE
+  static int test_array [1 - 2 * !((s) >= L_AC_SIZEOF_GE)];
+# elif defined L_AC_SIZEOF_LE
+  static int test_array [1 - 2 * !((s) <= L_AC_SIZEOF_LE)];
+# elif defined L_AC_SIZEOF_LT
+  static int test_array [1 - 2 * !((s) <  L_AC_SIZEOF_LT)];
+# else
+#  error no such comparison operator
+# endif
+  test_array [0] = 0;
+  return 0;
+}
+#endif
-- 
1.9.1

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 1/3] libsanitizer: Fix !statfs64 builds
  2014-04-17 14:01           ` [PATCH 0/3] libsanitizer libc conditionals Bernhard Reutner-Fischer
  2014-04-17 14:01             ` [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc Bernhard Reutner-Fischer
@ 2014-04-17 14:01             ` Bernhard Reutner-Fischer
  2014-04-17 14:08             ` [PATCH 2/3] libsanitizer: add conditionals for libc Bernhard Reutner-Fischer
  2 siblings, 0 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 14:01 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Bernhard Reutner-Fischer, Jakub Jelinek, GCC Patches,
	Dodji Seketeli, Kostya Serebryany, Dmitry Vyukov

libsanitizer/ChangeLog
2014-04-02  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* configure.ac: Check for sizeof(struct statfs64).
	* configure, config.h.in: Regenerate.
	* sanitizer_common/sanitizer_platform_interceptors.h
	(SANITIZER_INTERCEPT_STATFS64): Make conditional on
	SIZEOF_STRUCT_STATFS64 being not 0.
	* sanitizer_common/sanitizer_platform_limits_linux.cc
	(namespace __sanitizer): Make unsigned
	struct_statfs64_sz conditional on SANITIZER_INTERCEPT_STATFS64.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libsanitizer/config.h.in                           |  9 +++
 libsanitizer/configure                             | 69 ++++++++++++++++++++++
 libsanitizer/configure.ac                          | 15 +++++
 .../sanitizer_platform_interceptors.h              |  4 +-
 .../sanitizer_platform_limits_linux.cc             |  2 +
 5 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/libsanitizer/config.h.in b/libsanitizer/config.h.in
index e4b2786..4bd6a7f 100644
--- a/libsanitizer/config.h.in
+++ b/libsanitizer/config.h.in
@@ -61,12 +61,18 @@
 /* Define to 1 if you have the <sys/mman.h> header file. */
 #undef HAVE_SYS_MMAN_H
 
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+#undef HAVE_SYS_STATFS_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#undef HAVE_SYS_VFS_H
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -107,6 +113,9 @@
 /* The size of `short', as computed by sizeof. */
 #undef SIZEOF_SHORT
 
+/* The size of `struct statfs64', as computed by sizeof. */
+#undef SIZEOF_STRUCT_STATFS64
+
 /* The size of `void *', as computed by sizeof. */
 #undef SIZEOF_VOID_P
 
diff --git a/libsanitizer/configure b/libsanitizer/configure
index 5e4840f..c636212 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -15463,6 +15463,75 @@ _ACEOF
 
 
 
+for ac_header in sys/statfs.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/statfs.h" "ac_cv_header_sys_statfs_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_statfs_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_STATFS_H 1
+_ACEOF
+
+fi
+
+done
+
+if test "$ac_cv_header_sys_statfs_h" = "no"; then
+  for ac_header in sys/vfs.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/vfs.h" "ac_cv_header_sys_vfs_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_vfs_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_VFS_H 1
+_ACEOF
+
+fi
+
+done
+
+fi
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct statfs64" >&5
+$as_echo_n "checking size of struct statfs64... " >&6; }
+if test "${ac_cv_sizeof_struct_statfs64+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct statfs64))" "ac_cv_sizeof_struct_statfs64"        "
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h>
+#endif
+
+"; then :
+
+else
+  if test "$ac_cv_type_struct_statfs64" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (struct statfs64)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_struct_statfs64=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_statfs64" >&5
+$as_echo "$ac_cv_sizeof_struct_statfs64" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_STRUCT_STATFS64 $ac_cv_sizeof_struct_statfs64
+_ACEOF
+
+
+
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
 else
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index e672131..746c216 100644
--- a/libsanitizer/configure.ac
+++ b/libsanitizer/configure.ac
@@ -78,6 +78,21 @@ AC_SUBST(enable_static)
 
 AC_CHECK_SIZEOF([void *])
 
+dnl Careful, this breaks on glibc for e.g. dirent.d_ino being 64bit
+dnl AC_SYS_LARGEFILE
+AC_CHECK_HEADERS(sys/statfs.h)
+if test "$ac_cv_header_sys_statfs_h" = "no"; then
+  AC_CHECK_HEADERS(sys/vfs.h)
+fi
+AC_CHECK_SIZEOF([struct statfs64],[],[
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h>
+#endif
+])
+
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
 else
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
index f37d84b..b9ebd5c 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
@@ -137,7 +137,9 @@
 # define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID
 # define SANITIZER_INTERCEPT_STATFS SI_NOT_WINDOWS
 # define SANITIZER_INTERCEPT_STATFS64 \
-    (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
+    SIZEOF_STRUCT_STATFS64 && ( \
+      (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID \
+    )
 # define SANITIZER_INTERCEPT_STATVFS SI_LINUX_NOT_ANDROID
 # define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
 # define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
index bc37df0..637ac1d 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -59,7 +59,9 @@
 #endif
 
 namespace __sanitizer {
+#if SANITIZER_INTERCEPT_STATFS64
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
+#endif
 }  // namespace __sanitizer
 
 #if !defined(__powerpc64__) && !defined(__x86_64__)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 2/3] libsanitizer: add conditionals for libc
  2014-04-17 14:01           ` [PATCH 0/3] libsanitizer libc conditionals Bernhard Reutner-Fischer
  2014-04-17 14:01             ` [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc Bernhard Reutner-Fischer
  2014-04-17 14:01             ` [PATCH 1/3] libsanitizer: Fix !statfs64 builds Bernhard Reutner-Fischer
@ 2014-04-17 14:08             ` Bernhard Reutner-Fischer
  2 siblings, 0 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 14:08 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Bernhard Reutner-Fischer, Jakub Jelinek, GCC Patches,
	Dodji Seketeli, Kostya Serebryany, Dmitry Vyukov

Conditionalize usage of dlvsym(), nanosleep(), usleep();
Conditionalize layout of struct sigaction and type of it's member
sa_flags.
Conditionalize glob_t members gl_closedir, gl_readdir, gl_opendir,
gl_flags, gl_lstat, gl_stat.
Check for availability of glob.h for use with above members.
Check for availability of netrom/netrom.h, sys/ustat.h (for obsolete
ustat() function), utime.h (for obsolete utime() function), wordexp.h.
Determine size of sigset_t instead of hardcoding it.

libsanitizer/ChangeLog

2014-04-16  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* configure.ac (AC_CHECK_HEADERS): Add time.h, wordexp.h,
	glob.h, netrom/netrom.h, sys/ustat.h.
	(AC_CHECK_MEMBERS): Check GNU extension glob_t members.
	(AC_CHECK_SIZEOF): Determine size of sigset_t.
	(HAVE_STRUCT_SIGACTION_SA_MASK_LAST,
	STRUCT_SIGACTION_SA_FLAGS_TYPE): New.
	(AC_CHECK_FUNCS): Add usleep, nanosleep, dlvsym.
	* configure, config.h.in: Regenerate.
	* asan/Makefile.am, lsan/Makefile.am, tsan/Makefile.am,
	sanitizer_common/Makefile.am (AM_CXXFLAGS): Include config.h,
	add include search directory.
	* asan/Makefile.in, lsan/Makefile.in, tsan/Makefile.in,
	sanitizer_common/Makefile.in: Regenerate.
	* interception/interception_linux.h,
	interception/interception_linux.cc,
	sanitizer_common/sanitizer_common_interceptors.inc,
	sanitizer_common/sanitizer_platform_limits_posix.cc,
	sanitizer_common/sanitizer_platform_limits_posix.h,
	sanitizer_common/sanitizer_posix_libcdep.cc: Use config.h's new
	defines.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libsanitizer/asan/Makefile.am                      |   6 +
 libsanitizer/asan/Makefile.in                      |  17 +-
 libsanitizer/config.h.in                           |  51 +++++
 libsanitizer/configure                             | 212 ++++++++++++++++++++-
 libsanitizer/configure.ac                          |  23 +++
 libsanitizer/interception/interception_linux.cc    |   2 +
 libsanitizer/interception/interception_linux.h     |   8 +
 libsanitizer/lsan/Makefile.am                      |   6 +
 libsanitizer/lsan/Makefile.in                      |  11 +-
 libsanitizer/sanitizer_common/Makefile.am          |   5 +
 libsanitizer/sanitizer_common/Makefile.in          |  18 +-
 .../sanitizer_common_interceptors.inc              | 100 +++++++++-
 .../sanitizer_platform_limits_posix.cc             |  44 ++++-
 .../sanitizer_platform_limits_posix.h              |  27 ++-
 .../sanitizer_common/sanitizer_posix_libcdep.cc    |   7 +
 libsanitizer/tsan/Makefile.am                      |   6 +
 libsanitizer/tsan/Makefile.in                      |  11 +-
 17 files changed, 521 insertions(+), 33 deletions(-)

diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
index 3f07a83..851774c 100644
--- a/libsanitizer/asan/Makefile.am
+++ b/libsanitizer/asan/Makefile.am
@@ -9,6 +9,12 @@ DEFS += -DMAC_INTERPOSE_FUNCTIONS -DMISSING_BLOCKS_SUPPORT
 endif
 AM_CXXFLAGS = -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
 AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+AM_CXXFLAGS += -include $(top_builddir)/config.h
+if LIBBACKTRACE_SUPPORTED
+# backtrace-rename.h is included from config.h, provide -I dir for it
+AM_CXXFLAGS += -I $(top_srcdir)
+endif
+
 ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
 
 toolexeclib_LTLIBRARIES = libasan.la
diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in
index 273eb4b..a9b889d 100644
--- a/libsanitizer/asan/Makefile.in
+++ b/libsanitizer/asan/Makefile.in
@@ -37,8 +37,10 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 @USING_MAC_INTERPOSE_TRUE@am__append_1 = -DMAC_INTERPOSE_FUNCTIONS -DMISSING_BLOCKS_SUPPORT
-@USING_MAC_INTERPOSE_FALSE@am__append_2 = $(top_builddir)/interception/libinterception.la
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_3 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
+# backtrace-rename.h is included from config.h, provide -I dir for it
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = -I $(top_srcdir)
+@USING_MAC_INTERPOSE_FALSE@am__append_3 = $(top_builddir)/interception/libinterception.la
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_4 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
 subdir = asan
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -86,8 +88,8 @@ LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
 am__DEPENDENCIES_1 =
 libasan_la_DEPENDENCIES =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
-	$(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_2) \
-	$(am__append_3) $(am__DEPENDENCIES_1)
+	$(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_3) \
+	$(am__append_4) $(am__DEPENDENCIES_1)
 am__objects_1 = asan_allocator2.lo asan_dll_thunk.lo \
 	asan_fake_stack.lo asan_globals.lo asan_interceptors.lo \
 	asan_linux.lo asan_mac.lo asan_malloc_linux.lo \
@@ -267,7 +269,8 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 AM_CXXFLAGS = -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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+	-Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -include \
+	$(top_builddir)/config.h $(am__append_2)
 ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
 toolexeclib_LTLIBRARIES = libasan.la
 nodist_toolexeclib_HEADERS = libasan_preinit.o
@@ -295,8 +298,8 @@ asan_files = \
 libasan_la_SOURCES = $(asan_files)
 libasan_la_LIBADD =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
-	$(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_2) \
-	$(am__append_3) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
+	$(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_3) \
+	$(am__append_4) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
 libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libasan)
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
diff --git a/libsanitizer/config.h.in b/libsanitizer/config.h.in
index 4bd6a7f..12ebac6 100644
--- a/libsanitizer/config.h.in
+++ b/libsanitizer/config.h.in
@@ -25,6 +25,9 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
+/* Define to 1 if you have the `dlvsym' function. */
+#undef HAVE_DLVSYM
+
 /* Define if dl_iterate_phdr is available. */
 #undef HAVE_DL_ITERATE_PHDR
 
@@ -34,6 +37,27 @@
 /* Define if getexecname is available. */
 #undef HAVE_GETEXECNAME
 
+/* Define to 1 if you have the <glob.h> header file. */
+#undef HAVE_GLOB_H
+
+/* Define to 1 if `glob_t' is a member of `gl_closedir'. */
+#undef HAVE_GLOB_T_GL_CLOSEDIR
+
+/* Define to 1 if `glob_t' is a member of `gl_flags'. */
+#undef HAVE_GLOB_T_GL_FLAGS
+
+/* Define to 1 if `glob_t' is a member of `gl_lstat'. */
+#undef HAVE_GLOB_T_GL_LSTAT
+
+/* Define to 1 if `glob_t' is a member of `gl_opendir'. */
+#undef HAVE_GLOB_T_GL_OPENDIR
+
+/* Define to 1 if `glob_t' is a member of `gl_readdir'. */
+#undef HAVE_GLOB_T_GL_READDIR
+
+/* Define to 1 if `glob_t' is a member of `gl_stat'. */
+#undef HAVE_GLOB_T_GL_STAT
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -43,6 +67,12 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Define to 1 if you have the `nanosleep' function. */
+#undef HAVE_NANOSLEEP
+
+/* Define to 1 if you have the <netrom/netrom.h> header file. */
+#undef HAVE_NETROM_NETROM_H
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -55,6 +85,9 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
+/* Define to 1 if struct sigaction has member sa_mask as last field */
+#undef HAVE_STRUCT_SIGACTION_SA_MASK_LAST
+
 /* Define to 1 if you have the __sync functions */
 #undef HAVE_SYNC_FUNCTIONS
 
@@ -70,12 +103,24 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if you have the <sys/ustat.h> header file. */
+#undef HAVE_SYS_USTAT_H
+
 /* Define to 1 if you have the <sys/vfs.h> header file. */
 #undef HAVE_SYS_VFS_H
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the `usleep' function. */
+#undef HAVE_USLEEP
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if you have the <wordexp.h> header file. */
+#undef HAVE_WORDEXP_H
+
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
@@ -113,6 +158,9 @@
 /* The size of `short', as computed by sizeof. */
 #undef SIZEOF_SHORT
 
+/* The size of `sigset_t', as computed by sizeof. */
+#undef SIZEOF_SIGSET_T
+
 /* The size of `struct statfs64', as computed by sizeof. */
 #undef SIZEOF_STRUCT_STATFS64
 
@@ -122,6 +170,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Define to type of struct sigaction member sa_mask */
+#undef STRUCT_SIGACTION_SA_FLAGS_TYPE
+
 /* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
diff --git a/libsanitizer/configure b/libsanitizer/configure
index c636212..bfbaf52 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -2171,6 +2171,63 @@ rm -f conftest.val
 
 } # ac_fn_c_compute_int
 
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
+$as_echo_n "checking for $2.$3... " >&6; }
+if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (sizeof ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  eval "$4=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$4
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_member
+
 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
 # -------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -12019,7 +12076,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12022 "configure"
+#line 12079 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12125,7 +12182,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12128 "configure"
+#line 12185 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15531,6 +15588,157 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+for ac_header in utime.h wordexp.h glob.h netrom/netrom.h sys/ustat.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_flags" "ac_cv_member_glob_t_gl_flags" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_flags" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_FLAGS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_closedir" "ac_cv_member_glob_t_gl_closedir" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_closedir" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_CLOSEDIR 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_readdir" "ac_cv_member_glob_t_gl_readdir" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_readdir" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_READDIR 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_opendir" "ac_cv_member_glob_t_gl_opendir" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_opendir" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_OPENDIR 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_lstat" "ac_cv_member_glob_t_gl_lstat" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_lstat" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_LSTAT 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "glob_t" "gl_stat" "ac_cv_member_glob_t_gl_stat" "#include <glob.h>
+"
+if test "x$ac_cv_member_glob_t_gl_stat" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_T_GL_STAT 1
+_ACEOF
+
+
+fi
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of sigset_t" >&5
+$as_echo_n "checking size of sigset_t... " >&6; }
+if test "${ac_cv_sizeof_sigset_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (sigset_t))" "ac_cv_sizeof_sigset_t"        "#include <signal.h>
+"; then :
+
+else
+  if test "$ac_cv_type_sigset_t" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (sigset_t)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_sigset_t=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_sigset_t" >&5
+$as_echo "$ac_cv_sizeof_sigset_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SIGSET_T $ac_cv_sizeof_sigset_t
+_ACEOF
+
+
+case "${target}" in
+  *-*-*uclibc*)
+$as_echo "#define HAVE_STRUCT_SIGACTION_SA_MASK_LAST 1" >>confdefs.h
+;;
+  *)
+$as_echo "#define HAVE_STRUCT_SIGACTION_SA_MASK_LAST 0" >>confdefs.h
+;;
+esac
+case "${target}" in
+  alpha*-*-*uclibc*|mips*-*-*uclibc*)
+
+$as_echo "#define STRUCT_SIGACTION_SA_FLAGS_TYPE unsigned" >>confdefs.h
+;;
+  *-*-*uclibc*)
+$as_echo "#define STRUCT_SIGACTION_SA_FLAGS_TYPE unsigned long" >>confdefs.h
+;;
+esac
+for ac_func in usleep nanosleep
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in dlvsym
+do :
+  ac_fn_c_check_func "$LINENO" "dlvsym" "ac_cv_func_dlvsym"
+if test "x$ac_cv_func_dlvsym" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLVSYM 1
+_ACEOF
+
+fi
+done
+
 
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
index 746c216..12d4f3a 100644
--- a/libsanitizer/configure.ac
+++ b/libsanitizer/configure.ac
@@ -92,6 +92,29 @@ AC_CHECK_SIZEOF([struct statfs64],[],[
 # include <sys/vfs.h>
 #endif
 ])
+AC_CHECK_HEADERS([utime.h wordexp.h glob.h netrom/netrom.h sys/ustat.h])
+dnl check POSIX glob versus GNU glob extensions
+AC_CHECK_MEMBERS([glob_t.gl_flags, glob_t.gl_closedir, glob_t.gl_readdir, glob_t.gl_opendir, glob_t.gl_lstat, glob_t.gl_stat],[],[],[[#include <glob.h>]])
+AC_CHECK_SIZEOF([sigset_t],[],[#include <signal.h>])
+dnl uClibc uses a cache-friendly, linux kernel-like struct sigaction layout
+case "${target}" in
+  *-*-*uclibc*) AC_DEFINE([HAVE_STRUCT_SIGACTION_SA_MASK_LAST],[1],
+	[Define to 1 if struct sigaction has member sa_mask as last field]);;
+  *) AC_DEFINE([HAVE_STRUCT_SIGACTION_SA_MASK_LAST],[0],
+	[Define to 1 if struct sigaction has member sa_mask as last field]);;
+esac
+dnl struct sigaction typeof sa_flags in uClibc
+case "${target}" in
+  alpha*-*-*uclibc*|mips*-*-*uclibc*)
+	AC_DEFINE([STRUCT_SIGACTION_SA_FLAGS_TYPE],[unsigned],
+	[Define to type of struct sigaction member sa_mask]);;
+  *-*-*uclibc*) AC_DEFINE([STRUCT_SIGACTION_SA_FLAGS_TYPE],[unsigned long],
+	[Define to type of struct sigaction member sa_mask]);;
+esac
+dnl usleep was removed, try nanosleep (RT) [or clock_nanosleep (ADVANCED RT)]
+AC_CHECK_FUNCS([usleep nanosleep])
+dnl uClibc dl does not support dlvsym
+AC_CHECK_FUNCS([dlvsym])
 
 if test "${multilib}" = "yes"; then
   multilib_arg="--enable-multilib"
diff --git a/libsanitizer/interception/interception_linux.cc b/libsanitizer/interception/interception_linux.cc
index 0a8df47..efda8f5 100644
--- a/libsanitizer/interception/interception_linux.cc
+++ b/libsanitizer/interception/interception_linux.cc
@@ -23,9 +23,11 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
 }
 
 #if !defined(__ANDROID__)  // android does not have dlvsym
+# ifdef HAVE_DLVSYM
 void *GetFuncAddrVer(const char *func_name, const char *ver) {
   return dlvsym(RTLD_NEXT, func_name, ver);
 }
+# endif /* HAVE_DLVSYM */
 #endif  // !defined(__ANDROID__)
 
 }  // namespace __interception
diff --git a/libsanitizer/interception/interception_linux.h b/libsanitizer/interception/interception_linux.h
index 5ab24db..7ea124e 100644
--- a/libsanitizer/interception/interception_linux.h
+++ b/libsanitizer/interception/interception_linux.h
@@ -41,5 +41,13 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
      INTERCEPT_FUNCTION_LINUX(func)
 #endif  // !defined(__ANDROID__)
 
+
+#ifndef HAVE_DLVSYM
+/* Undo marketing crap above. Probe functionality, use result to decide.  */
+# undef INTERCEPT_FUNCTION_VER_LINUX
+# define INTERCEPT_FUNCTION_VER_LINUX(func, symver) \
+     INTERCEPT_FUNCTION_LINUX(func)
+#endif
+
 #endif  // INTERCEPTION_LINUX_H
 #endif  // __linux__
diff --git a/libsanitizer/lsan/Makefile.am b/libsanitizer/lsan/Makefile.am
index 7a508c1..d01d7c3 100644
--- a/libsanitizer/lsan/Makefile.am
+++ b/libsanitizer/lsan/Makefile.am
@@ -6,6 +6,12 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
 AM_CXXFLAGS = -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
 AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+AM_CXXFLAGS += -include $(top_builddir)/config.h
+if LIBBACKTRACE_SUPPORTED
+# backtrace-rename.h is included from config.h, provide -I dir for it
+AM_CXXFLAGS += -I $(top_srcdir)
+endif
+
 ACLOCAL_AMFLAGS = -I m4
 
 noinst_LTLIBRARIES = libsanitizer_lsan.la
diff --git a/libsanitizer/lsan/Makefile.in b/libsanitizer/lsan/Makefile.in
index 47caebc..8b44eda 100644
--- a/libsanitizer/lsan/Makefile.in
+++ b/libsanitizer/lsan/Makefile.in
@@ -35,7 +35,9 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
+# backtrace-rename.h is included from config.h, provide -I dir for it
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -I $(top_srcdir)
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
 subdir = lsan
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -83,7 +85,7 @@ am__DEPENDENCIES_1 =
 liblsan_la_DEPENDENCIES =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
 	$(top_builddir)/interception/libinterception.la \
-	$(am__append_1) $(am__DEPENDENCIES_1)
+	$(am__append_2) $(am__DEPENDENCIES_1)
 am__objects_1 = lsan_common.lo lsan_common_linux.lo
 am__objects_2 = $(am__objects_1) lsan.lo lsan_allocator.lo \
 	lsan_interceptors.lo lsan_preinit.lo lsan_thread.lo
@@ -260,7 +262,8 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 AM_CXXFLAGS = -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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+	-Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -include \
+	$(top_builddir)/config.h $(am__append_1)
 ACLOCAL_AMFLAGS = -I m4
 noinst_LTLIBRARIES = libsanitizer_lsan.la
 @LSAN_SUPPORTED_TRUE@toolexeclib_LTLIBRARIES = liblsan.la
@@ -281,7 +284,7 @@ liblsan_la_SOURCES = $(lsan_files)
 liblsan_la_LIBADD =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
 	$(top_builddir)/interception/libinterception.la \
-	$(am__append_1) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
+	$(am__append_2) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
 liblsan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_liblsan)
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am
index 8e9038d..e5b6f07 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -6,6 +6,11 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
 AM_CXXFLAGS = -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
 AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+AM_CXXFLAGS += -include $(top_builddir)/config.h
+if LIBBACKTRACE_SUPPORTED
+# backtrace-rename.h is included from config.h, provide -I dir for it
+AM_CXXFLAGS += -I $(top_srcdir)
+endif
 if LIBBACKTRACE_SUPPORTED
 AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \
 	       -I $(top_srcdir)/../libbacktrace \
diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in
index e9fd115..fb6877c 100644
--- a/libsanitizer/sanitizer_common/Makefile.in
+++ b/libsanitizer/sanitizer_common/Makefile.in
@@ -35,12 +35,14 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \
-@LIBBACKTRACE_SUPPORTED_TRUE@	       -I $(top_srcdir)/../libbacktrace \
-@LIBBACKTRACE_SUPPORTED_TRUE@	       -I $(top_builddir)/libbacktrace \
-@LIBBACKTRACE_SUPPORTED_TRUE@	       -I $(top_srcdir)/../include \
-@LIBBACKTRACE_SUPPORTED_TRUE@	       -include $(top_srcdir)/libbacktrace/backtrace-rename.h
-
+# backtrace-rename.h is included from config.h, provide -I dir for it
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -I $(top_srcdir) \
+@LIBBACKTRACE_SUPPORTED_TRUE@	-DSANITIZER_LIBBACKTRACE \
+@LIBBACKTRACE_SUPPORTED_TRUE@	-DSANITIZER_CP_DEMANGLE -I \
+@LIBBACKTRACE_SUPPORTED_TRUE@	$(top_srcdir)/../libbacktrace -I \
+@LIBBACKTRACE_SUPPORTED_TRUE@	$(top_builddir)/libbacktrace -I \
+@LIBBACKTRACE_SUPPORTED_TRUE@	$(top_srcdir)/../include -include \
+@LIBBACKTRACE_SUPPORTED_TRUE@	$(top_srcdir)/libbacktrace/backtrace-rename.h
 subdir = sanitizer_common
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -244,8 +246,8 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 AM_CXXFLAGS = -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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
-	$(am__append_1)
+	-Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -include \
+	$(top_builddir)/config.h $(am__append_1)
 ACLOCAL_AMFLAGS = -I m4
 noinst_LTLIBRARIES = libsanitizer_common.la
 sanitizer_common_files = \
diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
index e301dc1..3c9c409 100644
--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
@@ -863,33 +863,43 @@ static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
 static THREADLOCAL __sanitizer_glob_t *pglob_copy;
 static THREADLOCAL void *glob_ctx;
 
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
 static void wrapped_gl_closedir(void *dir) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(glob_ctx, 1);
   pglob_copy->gl_closedir(dir);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_READDIR
 static void *wrapped_gl_readdir(void *dir) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(glob_ctx, 1);
   return pglob_copy->gl_readdir(dir);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_OPENDIR
 static void *wrapped_gl_opendir(const char *s) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(glob_ctx, 1);
   COMMON_INTERCEPTOR_WRITE_RANGE(glob_ctx, s, REAL(strlen)(s) + 1);
   return pglob_copy->gl_opendir(s);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_LSTAT
 static int wrapped_gl_lstat(const char *s, void *st) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(glob_ctx, 2);
   COMMON_INTERCEPTOR_WRITE_RANGE(glob_ctx, s, REAL(strlen)(s) + 1);
   return pglob_copy->gl_lstat(s, st);
 }
+#endif
 
+#ifdef HAVE_GLOB_T_GL_STAT
 static int wrapped_gl_stat(const char *s, void *st) {
   COMMON_INTERCEPTOR_UNPOISON_PARAM(glob_ctx, 2);
   COMMON_INTERCEPTOR_WRITE_RANGE(glob_ctx, s, REAL(strlen)(s) + 1);
   return pglob_copy->gl_stat(s, st);
 }
+#endif
 
 INTERCEPTOR(int, glob, const char *pattern, int flags,
             int (*errfunc)(const char *epath, int eerrno),
@@ -897,25 +907,64 @@ INTERCEPTOR(int, glob, const char *pattern, int flags,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
   __sanitizer_glob_t glob_copy = {
-      0,                  0,                   0,
-      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
-      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
+	0,
+	0,
+	0
+#ifdef HAVE_GLOB_T_GL_FLAGS
+	,0
+#endif
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
+	,wrapped_gl_closedir
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
+	,wrapped_gl_readdir
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
+	,wrapped_gl_opendir
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
+	,wrapped_gl_lstat
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
+	,wrapped_gl_stat
+#endif
+  };
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
     pglob_copy = &glob_copy;
     glob_ctx = ctx;
   }
   int res = REAL(glob)(pattern, flags, errfunc, pglob);
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
   }
   pglob_copy = 0;
   glob_ctx = 0;
@@ -929,25 +978,64 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
   __sanitizer_glob_t glob_copy = {
-      0,                  0,                   0,
-      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
-      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
+	0,
+	0,
+	0
+#ifdef HAVE_GLOB_T_GL_FLAGS
+	,0
+#endif
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
+	,wrapped_gl_closedir
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
+	,wrapped_gl_readdir
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
+	,wrapped_gl_opendir
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
+	,wrapped_gl_lstat
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
+	,wrapped_gl_stat
+#endif
+  };
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
     pglob_copy = &glob_copy;
     glob_ctx = ctx;
   }
   int res = REAL(glob64)(pattern, flags, errfunc, pglob);
   if (flags & glob_altdirfunc) {
+#ifdef HAVE_GLOB_T_GL_CLOSEDIR
     Swap(pglob->gl_closedir, glob_copy.gl_closedir);
+#endif
+#ifdef HAVE_GLOB_T_GL_READDIR
     Swap(pglob->gl_readdir, glob_copy.gl_readdir);
+#endif
+#ifdef HAVE_GLOB_T_GL_OPENDIR
     Swap(pglob->gl_opendir, glob_copy.gl_opendir);
+#endif
+#ifdef HAVE_GLOB_T_GL_LSTAT
     Swap(pglob->gl_lstat, glob_copy.gl_lstat);
+#endif
+#ifdef HAVE_GLOB_T_GL_STAT
     Swap(pglob->gl_stat, glob_copy.gl_stat);
+#endif
   }
   pglob_copy = 0;
   glob_ctx = 0;
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index 196eb3b..d6e1021 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -45,7 +45,9 @@
 #if SANITIZER_LINUX
 #include <mntent.h>
 #include <netinet/ether.h>
+# ifdef HAVE_UTIME_H
 #include <utime.h>
+# endif
 #include <sys/mount.h>
 #include <sys/ptrace.h>
 #include <sys/sysinfo.h>
@@ -64,7 +66,9 @@
 
 #if !SANITIZER_ANDROID
 #include <sys/ucontext.h>
+# ifdef HAVE_WORDEXP_H
 #include <wordexp.h>
+# endif
 #endif
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
@@ -73,7 +77,9 @@
 #include <net/if_ppp.h>
 #include <netax25/ax25.h>
 #include <netipx/ipx.h>
+# ifdef HAVE_NETROM_NETROM_H
 #include <netrom/netrom.h>
+# endif
 #include <scsi/scsi.h>
 #include <sys/mtio.h>
 #include <sys/kd.h>
@@ -81,7 +87,9 @@
 #include <sys/statvfs.h>
 #include <sys/timex.h>
 #include <sys/user.h>
+# ifdef HAVE_SYS_USTAT_H
 #include <sys/ustat.h>
+# endif
 #include <linux/cyclades.h>
 #include <linux/if_eql.h>
 #include <linux/if_plip.h>
@@ -158,12 +166,16 @@ namespace __sanitizer {
   unsigned __user_cap_header_struct_sz =
       sizeof(struct __user_cap_header_struct);
   unsigned __user_cap_data_struct_sz = sizeof(struct __user_cap_data_struct);
+# ifdef HAVE_UTIME_H
   unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
+# endif
   unsigned struct_new_utsname_sz = sizeof(struct new_utsname);
   unsigned struct_old_utsname_sz = sizeof(struct old_utsname);
   unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname);
   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+# ifdef HAVE_SYS_USTAT_H
   unsigned struct_ustat_sz = sizeof(struct ustat);
+# endif
 #endif // SANITIZER_LINUX
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
@@ -207,7 +219,9 @@ namespace __sanitizer {
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
   int glob_nomatch = GLOB_NOMATCH;
+# ifdef GLOB_ALTDIRFUNC
   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+# endif
 #endif
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
@@ -309,7 +323,9 @@ namespace __sanitizer {
   unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
   unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
   unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
+# ifdef HAVE_NETROM_NETROM_H
   unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
+# endif
   unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
   unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
   unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
@@ -748,10 +764,18 @@ namespace __sanitizer {
   unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
   unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
   unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
+# ifdef SIOCNRDECOBS
   unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
+# endif
+# ifdef SIOCNRGETPARMS
   unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
+# endif
+# ifdef SIOCNRRTCTL
   unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
+# endif
+# ifdef SIOCNRSETPARMS
   unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
+# endif
   unsigned IOCTL_SNDCTL_DSP_GETISPACE = SNDCTL_DSP_GETISPACE;
   unsigned IOCTL_SNDCTL_DSP_GETOSPACE = SNDCTL_DSP_GETOSPACE;
   unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
@@ -790,12 +814,24 @@ CHECK_TYPE_SIZE(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);
+# ifdef HAVE_GLOB_T_GL_FLAGS
 CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
+# endif
+# ifdef HAVE_GLOB_T_GL_CLOSEDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
+# endif
+# ifdef HAVE_GLOB_T_GL_READDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
+# endif
+# ifdef HAVE_GLOB_T_GL_OPENDIR
 CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
+# endif
+# ifdef HAVE_GLOB_T_GL_LSTAT
 CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
+# endif
+# ifdef HAVE_GLOB_T_GL_STAT
 CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
+# endif
 #endif
 
 CHECK_TYPE_SIZE(addrinfo);
@@ -865,11 +901,17 @@ CHECK_TYPE_SIZE(sigset_t);
 COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
 // Can't write checks for sa_handler and sa_sigaction due to them being
 // preprocessor macros.
+#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
+CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
+#else
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
 #if SANITIZER_LINUX
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
 #endif
+#endif
 
 #if SANITIZER_LINUX
 CHECK_TYPE_SIZE(__sysctl_args);
@@ -889,7 +931,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
 CHECK_TYPE_SIZE(__kernel_fd_set);
 #endif
 
-#if !SANITIZER_ANDROID
+#ifdef HAVE_WORDEXP_H
 CHECK_TYPE_SIZE(wordexp_t);
 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index be6e6cf..ff7c969 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -355,10 +355,22 @@ namespace __sanitizer {
 #elif SANITIZER_LINUX
   struct __sanitizer_sigset_t {
     // The size is determined by looking at sizeof of real sigset_t on linux.
-    uptr val[128 / sizeof(uptr)];
+    /* .. except this should be * sizeof(uptr), not '/', no? */
+    uptr val[SIZEOF_SIGSET_T / sizeof(uptr)];
   };
 #endif
 
+#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
+  struct __sanitizer_sigaction {
+    union {
+      void (*sa_handler)(int sig);
+      void (*sa_sigaction)(int sig, void *siginfo, void *uctx);
+    };
+    STRUCT_SIGACTION_SA_FLAGS_TYPE sa_flags;
+    void (*sa_restorer)();
+    __sanitizer_sigset_t sa_mask;
+  };
+#else
   struct __sanitizer_sigaction {
     union {
       void (*sa_handler)(int sig);
@@ -370,6 +382,7 @@ namespace __sanitizer {
     void (*sa_restorer)();
 #endif
   };
+#endif
 
   struct __sanitizer_kernel_sigset_t {
     u8 sig[8];
@@ -448,13 +461,25 @@ namespace __sanitizer {
     uptr gl_pathc;
     char **gl_pathv;
     uptr gl_offs;
+# ifdef HAVE_GLOB_T_GL_FLAGS
     int gl_flags;
+# endif
 
+# ifdef HAVE_GLOB_T_GL_CLOSEDIR
     void (*gl_closedir)(void *dirp);
+# endif
+# ifdef HAVE_GLOB_T_GL_READDIR
     void *(*gl_readdir)(void *dirp);
+# endif
+# ifdef HAVE_GLOB_T_GL_OPENDIR
     void *(*gl_opendir)(const char *);
+# endif
+# ifdef HAVE_GLOB_T_GL_LSTAT
     int (*gl_lstat)(const char *, void *);
+# endif
+# ifdef HAVE_GLOB_T_GL_STAT
     int (*gl_stat)(const char *, void *);
+# endif
   };
 
   extern int glob_nomatch;
diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
index ae782ac..c0fee36 100644
--- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -68,7 +68,14 @@ void SleepForSeconds(int seconds) {
 }
 
 void SleepForMillis(int millis) {
+#ifdef HAVE_NANOSLEEP
+  struct timespec ts;
+  ts.tv_sec = millis / 1000;
+  ts.tv_nsec = (millis % 1000) * 1000000;
+  nanosleep(&ts, NULL); /* could as well loop here */
+#elif defined HAVE_USLEEP
   usleep(millis * 1000);
+#endif
 }
 
 void Abort() {
diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am
index 39ed252..5694e02 100644
--- a/libsanitizer/tsan/Makefile.am
+++ b/libsanitizer/tsan/Makefile.am
@@ -6,6 +6,12 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
 AM_CXXFLAGS = -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
 AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+AM_CXXFLAGS += -include $(top_builddir)/config.h
+if LIBBACKTRACE_SUPPORTED
+# backtrace-rename.h is included from config.h, provide -I dir for it
+AM_CXXFLAGS += -I $(top_srcdir)
+endif
+
 ACLOCAL_AMFLAGS = -I m4
 
 toolexeclib_LTLIBRARIES = libtsan.la
diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in
index 01c27b9..cd61827 100644
--- a/libsanitizer/tsan/Makefile.in
+++ b/libsanitizer/tsan/Makefile.in
@@ -35,7 +35,9 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
+# backtrace-rename.h is included from config.h, provide -I dir for it
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -I $(top_srcdir)
+@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
 subdir = tsan
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -83,7 +85,7 @@ am__DEPENDENCIES_1 =
 libtsan_la_DEPENDENCIES =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
 	$(top_builddir)/interception/libinterception.la \
-	$(am__append_1) $(am__DEPENDENCIES_1)
+	$(am__append_2) $(am__DEPENDENCIES_1)
 am__objects_1 = tsan_clock.lo tsan_interface_atomic.lo tsan_mutex.lo \
 	tsan_report.lo tsan_rtl_thread.lo tsan_symbolize.lo \
 	tsan_flags.lo tsan_interface.lo tsan_platform_linux.lo \
@@ -276,7 +278,8 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 AM_CXXFLAGS = -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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+	-Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -include \
+	$(top_builddir)/config.h $(am__append_1)
 ACLOCAL_AMFLAGS = -I m4
 toolexeclib_LTLIBRARIES = libtsan.la
 tsan_files = \
@@ -311,7 +314,7 @@ libtsan_la_SOURCES = $(tsan_files)
 libtsan_la_LIBADD =  \
 	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
 	$(top_builddir)/interception/libinterception.la \
-	$(am__append_1) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
+	$(am__append_2) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
 libtsan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libtsan)
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
-- 
1.9.1

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 14:01             ` [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc Bernhard Reutner-Fischer
@ 2014-04-17 14:28               ` Konstantin Serebryany
  2014-04-17 14:29                 ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Konstantin Serebryany @ 2014-04-17 14:28 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

Hi,

If you are trying to modify the libsanitizer files, please read here:
https://code.google.com/p/address-sanitizer/wiki/HowToContribute

--kcc

On Thu, Apr 17, 2014 at 5:49 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> Conditionalize usage of dlvsym(), nanosleep(), usleep();
> Conditionalize layout of struct sigaction and type of it's member
> sa_flags.
> Conditionalize glob_t members gl_closedir, gl_readdir, gl_opendir,
> gl_flags, gl_lstat, gl_stat.
> Check for availability of glob.h for use with above members.
> Check for availability of netrom/netrom.h, sys/ustat.h (for obsolete
> ustat() function), utime.h (for obsolete utime() function), wordexp.h.
> Determine size of sigset_t instead of hardcoding it.
> Determine size of struct statfs64, if available.
>
> Leave defaults to match what glibc expects but probe them for uClibc.
>
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> ---
>  CMakeLists.txt                                     |  58 +++++++
>  cmake/Modules/CompilerRTUtils.cmake                |  15 ++
>  cmake/Modules/FunctionExistsNotStub.cmake          |  56 +++++++
>  lib/interception/interception_linux.cc             |   2 +
>  lib/interception/interception_linux.h              |   9 ++
>  .../sanitizer_common_interceptors.inc              | 101 +++++++++++-
>  .../sanitizer_platform_limits_posix.cc             |  44 ++++-
>  .../sanitizer_platform_limits_posix.h              |  27 +++-
>  lib/sanitizer_common/sanitizer_posix_libcdep.cc    |   9 ++
>  make/platform/clang_linux.mk                       | 180 +++++++++++++++++++++
>  make/platform/clang_linux_test_libc.c              |  68 ++++++++
>  11 files changed, 561 insertions(+), 8 deletions(-)
>  create mode 100644 cmake/Modules/FunctionExistsNotStub.cmake
>  create mode 100644 make/platform/clang_linux_test_libc.c
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index e1a7a1f..af8073e 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -330,6 +330,64 @@ if(APPLE)
>      -isysroot ${IOSSIM_SDK_DIR})
>  endif()
>
> +set(ct_c ${COMPILER_RT_SOURCE_DIR}/make/platform/clang_linux_test_libc.c)
> +check_include_file(sys/ustat.h HAVE_SYS_USTAT_H)
> +check_include_file(utime.h HAVE_UTIME_H)
> +check_include_file(wordexp.h HAVE_WORDEXP_H)
> +check_include_file(glob.h HAVE_GLOB_H)
> +include(FunctionExistsNotStub)
> +check_function_exists_not_stub(${ct_c} nanosleep HAVE_NANOSLEEP)
> +check_function_exists_not_stub(${ct_c} usleep HAVE_USLEEP)
> +include(CheckTypeSize)
> +# check for sizeof sigset_t
> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
> +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} signal.h)
> +check_type_size("sigset_t" SIZEOF_SIGSET_T BUILTIN_TYPES_ONLY)
> +if(EXISTS HAVE_SIZEOF_SIGSET_T)
> +  set(SIZEOF_SIGSET_T ${HAVE_SIZEOF_SIGSET_T})
> +endif()
> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
> +# check for sizeof struct statfs64
> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
> +check_include_file(sys/statfs.h HAVE_SYS_STATFS_H)
> +check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
> +if(HAVE_SYS_STATFS_H)
> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/statfs.h)
> +endif()
> +if(HAVE_SYS_VFS_H)
> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/vfs.h)
> +endif()
> +# Have to pass _LARGEFILE64_SOURCE otherwise there is no struct statfs64.
> +# We forcefully enable LFS to retain glibc legacy behaviour herein.
> +set(oCMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
> +set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE)
> +check_type_size("struct statfs64" SIZEOF_STRUCT_STATFS64)
> +if(EXISTS HAVE_SIZEOF_STRUCT_STATFS64)
> +  set(SIZEOF_STRUCT_STATFS64 ${HAVE_SIZEOF_STRUCT_STATFS64})
> +else()
> +  set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
> +endif()
> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
> +# do not set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
> +# it back here either way.
> +include(CheckStructHasMember)
> +check_struct_has_member(glob_t gl_flags glob.h HAVE_GLOB_T_GL_FLAGS)
> +check_struct_has_member(glob_t gl_closedir glob.h HAVE_GLOB_T_GL_CLOSEDIR)
> +check_struct_has_member(glob_t gl_readdir glob.h HAVE_GLOB_T_GL_READDIR)
> +check_struct_has_member(glob_t gl_opendir glob.h HAVE_GLOB_T_GL_OPENDIR)
> +check_struct_has_member(glob_t gl_lstat glob.h HAVE_GLOB_T_GL_LSTAT)
> +check_struct_has_member(glob_t gl_stat glob.h HAVE_GLOB_T_GL_STAT)
> +
> +# folks seem to have an aversion to configure_file? So be it..
> +foreach(x HAVE_SYS_USTAT_H HAVE_UTIME_H HAVE_WORDEXP_H HAVE_GLOB_H
> +HAVE_NANOSLEEP HAVE_USLEEP SIZEOF_SIGSET_T SIZEOF_STRUCT_STATFS64
> +HAVE_GLOB_T_GL_FLAGS HAVE_GLOB_T_GL_CLOSEDIR
> +HAVE_GLOB_T_GL_READDIR HAVE_GLOB_T_GL_OPENDIR
> +HAVE_GLOB_T_GL_LSTAT HAVE_GLOB_T_GL_STAT)
> +def_undef_string(${x} SANITIZER_COMMON_CFLAGS)
> +endforeach()
> +
> +
>  # Architectures supported by Sanitizer runtimes. Specific sanitizers may
>  # support only subset of these (e.g. TSan works on x86_64 only).
>  filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
> diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
> index e22e775..3a0beec 100644
> --- a/cmake/Modules/CompilerRTUtils.cmake
> +++ b/cmake/Modules/CompilerRTUtils.cmake
> @@ -59,3 +59,18 @@ macro(append_no_rtti_flag list)
>    append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
>    append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
>  endmacro()
> +
> +# Appends -Dvalue=${value}/-Uvalue to all strings in ARGN
> +macro(def_undef_string condition)
> +  if("${${condition}}" STREQUAL "")
> +    foreach(str ${ARGN})
> +      set(${str} "${${str}} -U${condition}")
> +    endforeach()
> +  else()
> +    foreach(str ${ARGN})
> +      set(${str} "${${str}} '-D${condition}=${${condition}}'")
> +    endforeach()
> +  endif()
> +endmacro()
> +
> +
> diff --git a/cmake/Modules/FunctionExistsNotStub.cmake b/cmake/Modules/FunctionExistsNotStub.cmake
> new file mode 100644
> index 0000000..9f944dd
> --- /dev/null
> +++ b/cmake/Modules/FunctionExistsNotStub.cmake
> @@ -0,0 +1,56 @@
> +INCLUDE(CheckFunctionExists)
> +
> +# The following variables may be set before calling this macro to
> +# modify the way the check is run:
> +#
> +#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
> +#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
> +#  CMAKE_REQUIRED_INCLUDES = list of include directories
> +
> +macro(CHECK_FUNCTION_EXISTS_NOT_STUB CSRC FUNCTION VARIABLE)
> +  if(NOT DEFINED CHECKED_STUB_${VARIABLE})
> +    set(CHECKED_STUB_${VARIABLE} "done" CACHE INTERNAL "checked stub of ${FUNCTION}")
> +    CHECK_FUNCTION_EXISTS("${FUNCTION}" "${VARIABLE}")
> +    if(DEFINED ${VARIABLE})
> +      if(NOT CMAKE_REQUIRED_QUIET)
> +        message(STATUS "Looking for stubbed out ${FUNCTION}")
> +      endif()
> +      if(CMAKE_REQUIRED_INCLUDES)
> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES
> +          "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
> +      else()
> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES)
> +      endif()
> +      set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS ${CMAKE_REQUIRED_FLAGS})
> +      try_compile(${VARIABLE}
> +        ${CMAKE_BINARY_DIR}
> +        "${CSRC}"
> +        COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
> +        CMAKE_FLAGS
> +        "-DCOMPILE_DEFINITIONS:STRING=-DL_features_h -DL_AC_CHECK_FUNC=${FUNCTION} -DL_AC_CHECK_FUNC_stub='defined __stub_${FUNCTION} || defined __stub___${FUNCTION}'"
> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS}"
> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES}"
> +        OUTPUT_VARIABLE OUTPUT
> +      )
> +    endif()
> +    if(${VARIABLE})
> +      set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
> +        "Determining if function ${FUNCTION} is a stub "
> +        "passed with the following output:\n"
> +        "${OUTPUT}\n\n")
> +      if(NOT CMAKE_REQUIRED_QUIET)
> +        message(STATUS "Looking for stubbed out ${FUNCTION} - no stub")
> +      endif()
> +    else()
> +      set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
> +        "Determining if function ${FUNCTION} is a stub "
> +        "failed with the following output:\n"
> +        "${OUTPUT}\n\n")
> +      if(NOT CMAKE_REQUIRED_QUIET)
> +        message(STATUS "Looking for stubbed out ${FUNCTION} - stub found")
> +      endif()
> +    endif()
> +  endif()
> +endmacro()
> diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
> index 6e908ac..c9b4a6e 100644
> --- a/lib/interception/interception_linux.cc
> +++ b/lib/interception/interception_linux.cc
> @@ -24,11 +24,13 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>    return real == wrapper;
>  }
>
> +#ifdef HAVE_DLVSYM
>  #if !defined(__ANDROID__)  // android does not have dlvsym
>  void *GetFuncAddrVer(const char *func_name, const char *ver) {
>    return dlvsym(RTLD_NEXT, func_name, ver);
>  }
>  #endif  // !defined(__ANDROID__)
> +#endif // HAVE_DLVSYM
>
>  }  // namespace __interception
>
> diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
> index d3f774b..4802fe5 100644
> --- a/lib/interception/interception_linux.h
> +++ b/lib/interception/interception_linux.h
> @@ -25,7 +25,9 @@ namespace __interception {
>  // returns true if a function with the given name was found.
>  bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>      uptr real, uptr wrapper);
> +# ifdef HAVE_DLVSYM
>  void *GetFuncAddrVer(const char *func_name, const char *ver);
> +# endif /* HAVE_DLVSYM */
>  }  // namespace __interception
>
>  #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)                          \
> @@ -43,5 +45,12 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
>       INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>  #endif  // !defined(__ANDROID__)
>
> +#ifndef HAVE_DLVSYM
> +/* Undo marketing crap above. Probe functionality, use result to decide.  */
> +# undef INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD
> +# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
> +            INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
> +#endif
> +
>  #endif  // INTERCEPTION_LINUX_H
>  #endif  // __linux__ || __FreeBSD__
> diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
> index 0d076a0..0a767d4 100644
> --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
> +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
> @@ -1273,33 +1273,43 @@ static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
>
>  static THREADLOCAL __sanitizer_glob_t *pglob_copy;
>
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>  static void wrapped_gl_closedir(void *dir) {
>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>    IndirectExternCall(pglob_copy->gl_closedir)(dir);
>  }
> +#endif
>
> +#ifdef HAVE_GLOB_T_GL_READDIR
>  static void *wrapped_gl_readdir(void *dir) {
>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>    return IndirectExternCall(pglob_copy->gl_readdir)(dir);
>  }
> +#endif
>
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>  static void *wrapped_gl_opendir(const char *s) {
>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>    return IndirectExternCall(pglob_copy->gl_opendir)(s);
>  }
> +#endif
>
> +#ifdef HAVE_GLOB_T_GL_LSTAT
>  static int wrapped_gl_lstat(const char *s, void *st) {
>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>    return IndirectExternCall(pglob_copy->gl_lstat)(s, st);
>  }
> +#endif
>
> +#ifdef HAVE_GLOB_T_GL_STAT
>  static int wrapped_gl_stat(const char *s, void *st) {
>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>    return IndirectExternCall(pglob_copy->gl_stat)(s, st);
>  }
> +#endif
>
>  INTERCEPTOR(int, glob, const char *pattern, int flags,
>              int (*errfunc)(const char *epath, int eerrno),
> @@ -1307,24 +1317,64 @@ INTERCEPTOR(int, glob, const char *pattern, int flags,
>    void *ctx;
>    COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
>    __sanitizer_glob_t glob_copy = {
> -      0,                  0,                   0,
> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
> +       0,
> +       0,
> +       0
> +#ifdef HAVE_GLOB_T_GL_FLAGS
> +       ,0
> +#endif
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
> +       ,wrapped_gl_closedir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
> +       ,wrapped_gl_readdir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
> +       ,wrapped_gl_opendir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
> +       ,wrapped_gl_lstat
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
> +       ,wrapped_gl_stat
> +#endif
> +  };
> +
>    if (flags & glob_altdirfunc) {
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
>      Swap(pglob->gl_stat, glob_copy.gl_stat);
> +#endif
>      pglob_copy = &glob_copy;
>    }
>    int res = REAL(glob)(pattern, flags, errfunc, pglob);
>    if (flags & glob_altdirfunc) {
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
>      Swap(pglob->gl_stat, glob_copy.gl_stat);
> +#endif
>    }
>    pglob_copy = 0;
>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
> @@ -1337,24 +1387,63 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
>    void *ctx;
>    COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
>    __sanitizer_glob_t glob_copy = {
> -      0,                  0,                   0,
> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
> +       0,
> +       0,
> +       0
> +#ifdef HAVE_GLOB_T_GL_FLAGS
> +       ,0
> +#endif
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
> +       ,wrapped_gl_closedir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
> +       ,wrapped_gl_readdir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
> +       ,wrapped_gl_opendir
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
> +       ,wrapped_gl_lstat
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
> +       ,wrapped_gl_stat
> +#endif
> +  };
>    if (flags & glob_altdirfunc) {
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
>      Swap(pglob->gl_stat, glob_copy.gl_stat);
> +#endif
>      pglob_copy = &glob_copy;
>    }
>    int res = REAL(glob64)(pattern, flags, errfunc, pglob);
>    if (flags & glob_altdirfunc) {
> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_READDIR
>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_LSTAT
>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
> +#endif
> +#ifdef HAVE_GLOB_T_GL_STAT
>      Swap(pglob->gl_stat, glob_copy.gl_stat);
> +#endif
>    }
>    pglob_copy = 0;
>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
> index 9ae4870..645777f 100644
> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
> @@ -103,14 +103,18 @@
>  #endif
>
>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
> +# ifdef HAVE_UTIME_H
>  # include <utime.h>
> +# endif
>  # include <sys/ptrace.h>
>  #endif
>
>  #if !SANITIZER_ANDROID
>  #include <ifaddrs.h>
>  #include <sys/ucontext.h>
> +# ifdef HAVE_WORDEXP_H
>  #include <wordexp.h>
> +# endif
>  #endif
>
>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
> @@ -119,7 +123,9 @@
>  #include <net/if_ppp.h>
>  #include <netax25/ax25.h>
>  #include <netipx/ipx.h>
> +# ifdef HAVE_NETROM_NETROM_H
>  #include <netrom/netrom.h>
> +# endif
>  #include <rpc/xdr.h>
>  #include <scsi/scsi.h>
>  #include <sys/mtio.h>
> @@ -128,7 +134,9 @@
>  #include <sys/statvfs.h>
>  #include <sys/timex.h>
>  #include <sys/user.h>
> +# ifdef HAVE_SYS_USTAT_H
>  #include <sys/ustat.h>
> +# endif
>  #include <linux/cyclades.h>
>  #include <linux/if_eql.h>
>  #include <linux/if_plip.h>
> @@ -215,12 +223,16 @@ namespace __sanitizer {
>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
>    unsigned struct_rlimit_sz = sizeof(struct rlimit);
>    unsigned struct_timespec_sz = sizeof(struct timespec);
> +# ifdef HAVE_UTIME_H
>    unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
> +# endif
>    unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
>  #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
>
>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
> +# ifdef HAVE_SYS_USTAT_H
>    unsigned struct_ustat_sz = sizeof(struct ustat);
> +# endif
>    unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
>    unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
>  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
> @@ -266,7 +278,9 @@ namespace __sanitizer {
>
>  #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
>    int glob_nomatch = GLOB_NOMATCH;
> +# ifdef GLOB_ALTDIRFUNC
>    int glob_altdirfunc = GLOB_ALTDIRFUNC;
> +# endif
>  #endif
>
>  #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
> @@ -370,7 +384,9 @@ namespace __sanitizer {
>    unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
>    unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
>    unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
> +# ifdef HAVE_NETROM_NETROM_H
>    unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
> +# endif
>    unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
>    unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
>    unsigned struct_serial_multiport_struct_sz
> @@ -805,10 +821,18 @@ namespace __sanitizer {
>    unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
>    unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
>    unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
> +# ifdef SIOCNRDECOBS
>    unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
> +# endif
> +# ifdef SIOCNRGETPARMS
>    unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
> +# endif
> +# ifdef SIOCNRRTCTL
>    unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
> +# endif
> +# ifdef SIOCNRSETPARMS
>    unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
> +# endif
>    unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
>    unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
>    unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
> @@ -890,12 +914,24 @@ CHECK_TYPE_SIZE(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);
> +# ifdef HAVE_GLOB_T_GL_FLAGS
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
> +# endif
> +# ifdef HAVE_GLOB_T_GL_CLOSEDIR
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
> +# endif
> +# ifdef HAVE_GLOB_T_GL_READDIR
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
> +# endif
> +# ifdef HAVE_GLOB_T_GL_OPENDIR
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
> +# endif
> +# ifdef HAVE_GLOB_T_GL_LSTAT
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
> +# endif
> +# ifdef HAVE_GLOB_T_GL_STAT
>  CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
> +# endif
>  #endif
>
>  CHECK_TYPE_SIZE(addrinfo);
> @@ -967,11 +1003,17 @@ CHECK_TYPE_SIZE(sigset_t);
>  COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
>  // Can't write checks for sa_handler and sa_sigaction due to them being
>  // preprocessor macros.
> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
>  #if SANITIZER_LINUX
>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
>  #endif
> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>
>  #if SANITIZER_LINUX
>  CHECK_TYPE_SIZE(__sysctl_args);
> @@ -991,7 +1033,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
>  CHECK_TYPE_SIZE(__kernel_fd_set);
>  #endif
>
> -#if !SANITIZER_ANDROID
> +#ifdef HAVE_WORDEXP_H
>  CHECK_TYPE_SIZE(wordexp_t);
>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> index a780ee2..04c6a96 100644
> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> @@ -478,7 +478,8 @@ namespace __sanitizer {
>  #elif SANITIZER_LINUX
>    struct __sanitizer_sigset_t {
>      // The size is determined by looking at sizeof of real sigset_t on linux.
> -    uptr val[128 / sizeof(uptr)];
> +    /* .. except this should be * sizeof(uptr), not '/', no? */
> +    uptr val[SIZEOF_SIGSET_T / sizeof(uptr)];
>    };
>  #elif SANITIZER_FREEBSD
>    struct __sanitizer_sigset_t {
> @@ -487,6 +488,17 @@ namespace __sanitizer {
>    };
>  #endif
>
> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
> +  struct __sanitizer_sigaction {
> +    union {
> +      void (*sigaction)(int sig, void *siginfo, void *uctx);
> +      void (*handler)(int sig);
> +    };
> +    STRUCT_SIGACTION_SA_FLAGS_TYPE sa_flags;
> +    void (*sa_restorer)();
> +    __sanitizer_sigset_t sa_mask;
> +  };
> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>    // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
>    struct __sanitizer_sigaction {
>      union {
> @@ -504,6 +516,7 @@ namespace __sanitizer {
>      void (*sa_restorer)();
>  #endif
>    };
> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>
>  #if SANITIZER_FREEBSD
>    typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
> @@ -588,13 +601,25 @@ namespace __sanitizer {
>      uptr gl_pathc;
>      char **gl_pathv;
>      uptr gl_offs;
> +#  ifdef HAVE_GLOB_T_GL_FLAGS
>      int gl_flags;
> +#  endif
>
> +#  ifdef HAVE_GLOB_T_GL_CLOSEDIR
>      void (*gl_closedir)(void *dirp);
> +#  endif
> +#  ifdef HAVE_GLOB_T_GL_READDIR
>      void *(*gl_readdir)(void *dirp);
> +#  endif
> +#  ifdef HAVE_GLOB_T_GL_OPENDIR
>      void *(*gl_opendir)(const char *);
> +#  endif
> +#  ifdef HAVE_GLOB_T_GL_LSTAT
>      int (*gl_lstat)(const char *, void *);
> +#  endif
> +#  ifdef HAVE_GLOB_T_GL_STAT
>      int (*gl_stat)(const char *, void *);
> +#  endif
>    };
>  # elif SANITIZER_FREEBSD
>    struct __sanitizer_glob_t {
> diff --git a/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
> index bb6e587..973f698 100644
> --- a/lib/sanitizer_common/sanitizer_posix_libcdep.cc
> +++ b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
> @@ -73,7 +73,16 @@ void SleepForSeconds(int seconds) {
>  }
>
>  void SleepForMillis(int millis) {
> +#ifdef HAVE_NANOSLEEP
> +  struct timespec ts;
> +  ts.tv_sec = millis / 1000;
> +  ts.tv_nsec = (millis % 1000) * 1000000;
> +  nanosleep(&ts, NULL); /* could as well loop here */
> +#elif defined HAVE_USLEEP
>    usleep(millis * 1000);
> +# else
> +  dunno how to SleepForMillis
> +#endif
>  }
>
>  void Abort() {
> diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk
> index c6921ea..5ce1567 100644
> --- a/make/platform/clang_linux.mk
> +++ b/make/platform/clang_linux.mk
> @@ -74,6 +74,185 @@ Arch.dfsan-x86_64 := x86_64
>  Arch.lsan-x86_64 := x86_64
>  endif
>
> +# TryCompile2 compiler source flags
> +# Returns exit code of running a compiler invocation.
> +# Same as TryCompile but in outer scope, don't want to touch the other one
> +TryCompile2 = \
> +  $(shell \
> +    cflags=""; \
> +    for flag in $(3); do \
> +      cflags="$$cflags $$flag"; \
> +    done; \
> +    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
> +    echo $$?)
> +
> +# our conftest.c
> +ct_c = $(ProjSrcRoot)/make/platform/clang_linux_test_libc.c
> +
> +HAVE_DLVSYM := 1
> +HAVE_NETROM_NETROM_H := 1
> +HAVE_GLOB_H := 1
> +HAVE_NANOSLEEP := 1
> +HAVE_GLOB_T_GL_CLOSEDIR := 1
> +HAVE_GLOB_T_GL_FLAGS := 1
> +HAVE_GLOB_T_GL_LSTAT := 1
> +HAVE_GLOB_T_GL_OPENDIR := 1
> +HAVE_GLOB_T_GL_READDIR := 1
> +HAVE_GLOB_T_GL_STAT := 1
> +HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 0
> +HAVE_SYS_USTAT_H := 1
> +HAVE_USLEEP := 1
> +HAVE_UTIME_H := 1
> +HAVE_WORDEXP_H := 1
> +SIZEOF_STRUCT_STATFS64 := 120
> +SIZEOF_SIGSET_T := 128
> +STRUCT_SIGACTION_SA_FLAGS_TYPE := int
> +
> +#ifneq ($(findstring -uclibc,$(CompilerTargetTriple)),)
> +# does not work, cross-compilation seems to be non-working?
> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_UCLIBC -DL_AC_CHECK_HEADER="<stdio.h>",),0)
> +  HAVE_DLVSYM :=
> +  HAVE_NETROM_NETROM_H :=
> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned long
> +ifneq ($(filter alpha%,$(CompilerTargetTriple)),)
> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
> +endif
> +ifneq ($(filter mips%,$(CompilerTargetTriple)),)
> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
> +endif
> +  HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 1
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/ustat.h>",),0)
> +  HAVE_SYS_USTAT_H :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<utime.h>",),0)
> +  HAVE_UTIME_H :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<wordexp.h>",),0)
> +  HAVE_WORDEXP_H :=
> +endif
> +glob_h := -DL_AC_CHECK_HEADER="<glob.h>"
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN $(glob_h),),0)
> +  HAVE_GLOB_H :=
> +endif
> +# check for struct glob members (check for GNU extensions)
> +glob_h += -DL_AC_STRUCT="glob_t"
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_flags,),0)
> +  HAVE_GLOB_T_GL_FLAGS :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_closedir,),0)
> +  HAVE_GLOB_T_GL_CLOSEDIR :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_readdir,),0)
> +  HAVE_GLOB_T_GL_READDIR :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_opendir,),0)
> +  HAVE_GLOB_T_GL_OPENDIR :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_lstat,),0)
> +  HAVE_GLOB_T_GL_LSTAT :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_stat,),0)
> +  HAVE_GLOB_T_GL_STAT :=
> +endif
> +# check misc functions
> +# for __stub_* on glibc and uClibc including features.h is enough
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=nanosleep -DL_AC_CHECK_FUNC_stub="defined __stub_nanosleep || defined __stub___nanosleep",),0)
> +  HAVE_NANOSLEEP :=
> +endif
> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=usleep -DL_AC_CHECK_FUNC_stub="defined __stub_usleep || defined __stub___usleep",),0)
> +  HAVE_USLEEP :=
> +endif
> +
> +# AC_CHECK_SIZEOF, in make
> +define ac_check_sizeof
> +$(shell \
> +if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; \
> +then \
> +  ac_lo=0 ac_mid=0; \
> +  while :; \
> +  do \
> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
> +    ac_hi=$$ac_mid; \
> +    break; \
> +  else \
> +    ac_lo=$$(( $$ac_mid + 1 )); \
> +    if test $$ac_lo -le $$ac_mid; then ac_lo= ac_hi=; break; fi; \
> +    ac_mid=$$(( 2 * $$ac_mid + 1 )); \
> +  fi; \
> +  done; \
> +else \
> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LT=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
> +    ac_hi=-1 ac_mid=-1; \
> +    while :; \
> +    do \
> +    if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
> +      ac_lo=$$ac_mid; \
> +      break; \
> +    else \
> +      ac_hi=$$(( ($$ac_mid) - 1 )); \
> +      if test $$ac_mid -le $$ac_hi; then ac_lo= ac_hi=; break; fi; \
> +      ac_mid=$$(( 2 * $$ac_mid )); \
> +    fi; \
> +    done; \
> +  else \
> +    ac_lo= ac_hi=; \
> +  fi; \
> +fi; \
> +while test "x$$ac_lo" != "x$$ac_hi"; \
> +do \
> +  ac_mid=$$(( ($$ac_hi - $$ac_lo) / 2 + $$ac_lo )); \
> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
> +    ac_hi=$$ac_mid; \
> +  else \
> +    ac_lo=$$(( ($$ac_mid) + 1 )); \
> +  fi; \
> +done; \
> +echo $$(( $$ac_lo + 0 )); \
> +)
> +endef
> +
> +# determine sizeof sigset_t
> +SIZEOF_SIGSET_T := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<signal.h>" -DL_AC_SIZEOF="sigset_t")
> +
> +# determine sizeof struct statfs64
> +SIZEOF_STRUCT_STATFS64 := 0
> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/statfs.h>",),0)
> +SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/statfs.h>" -DL_AC_SIZEOF="struct statfs64")
> +else
> + ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/vfs.h>",),0)
> + SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/vfs.h>" -DL_AC_SIZEOF="struct statfs64")
> + endif
> +endif
> +# end of -uclibc handling
> +endif
> +
> +define add_config_h_cppflag
> +ifeq ($($(1)),)
> +CONFIG_H_CPPFLAGS += -U$(1)
> +else
> +CONFIG_H_CPPFLAGS += '-D$(1)=$($(1))'
> +endif
> +endef
> +
> +CONFIG_H_CPPFLAGS :=
> +$(eval $(call add_config_h_cppflag,HAVE_DLVSYM))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_H))
> +$(eval $(call add_config_h_cppflag,HAVE_NANOSLEEP))
> +$(eval $(call add_config_h_cppflag,HAVE_NETROM_NETROM_H))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_CLOSEDIR))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_FLAGS))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_LSTAT))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_OPENDIR))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_READDIR))
> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_STAT))
> +$(eval $(call add_config_h_cppflag,HAVE_STRUCT_SIGACTION_SA_MASK_LAST))
> +$(eval $(call add_config_h_cppflag,HAVE_SYS_USTAT_H))
> +$(eval $(call add_config_h_cppflag,HAVE_USLEEP))
> +$(eval $(call add_config_h_cppflag,HAVE_UTIME_H))
> +$(eval $(call add_config_h_cppflag,HAVE_WORDEXP_H))
> +$(eval $(call add_config_h_cppflag,SIZEOF_STRUCT_STATFS64))
> +$(eval $(call add_config_h_cppflag,SIZEOF_SIGSET_T))
> +$(eval $(call add_config_h_cppflag,STRUCT_SIGACTION_SA_FLAGS_TYPE))
>  endif
>
>  ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
> @@ -87,6 +266,7 @@ endif
>
>  CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
>  SANITIZER_CFLAGS := -fPIE -fno-builtin -gline-tables-only
> +CFLAGS += $(CONFIG_H_CPPFLAGS)
>
>  CFLAGS.full-i386 := $(CFLAGS) -m32
>  CFLAGS.full-x86_64 := $(CFLAGS) -m64
> diff --git a/make/platform/clang_linux_test_libc.c b/make/platform/clang_linux_test_libc.c
> new file mode 100644
> index 0000000..2f9bba8
> --- /dev/null
> +++ b/make/platform/clang_linux_test_libc.c
> @@ -0,0 +1,68 @@
> +/* This file is used to check for libc characteristics and features */
> +#ifdef L_features_h
> +# include <features.h>
> +#endif
> +
> +#ifdef L_AC_CHECK_HEADER
> +/* compile-time check for availability of a header */
> +# include L_AC_CHECK_HEADER
> +#endif
> +
> +#ifdef L_AC_CHECK_UCLIBC
> +# ifndef __UCLIBC__
> +choke me /* not uClibc */
> +# endif
> +#endif
> +
> +#ifdef L_MAIN
> +/* provide a dummy main for the linker */
> +int main()
> +{
> +  return 0;
> +}
> +#endif
> +
> +#ifdef L_AC_CHECK_STRUCT_MEMBER
> +/* compile-time check for presence of struct member */
> +int main()
> +{
> +  static L_AC_STRUCT ac_aggr;
> +  if (ac_aggr.L_AC_CHECK_STRUCT_MEMBER)
> +    return 0;
> +  return 0;
> +}
> +#endif
> +
> +#ifdef L_AC_CHECK_FUNC
> +/* check if function (or macro) is available */
> +# ifdef __cplusplus
> +extern "C"
> +# endif
> +# if L_AC_CHECK_FUNC_stub
> +choke me /* function 'L_AC_CHECK_FUNC' stubbed out! */
> +# endif
> +char L_AC_CHECK_FUNC ();
> +int main ()
> +{
> +       return L_AC_CHECK_FUNC ();
> +}
> +#endif
> +
> +#ifdef L_AC_SIZEOF
> +/* Determine sizeof expression */
> +int main ()
> +{
> +# define s (long int) (sizeof (L_AC_SIZEOF))
> +# if defined L_AC_SIZEOF_GE
> +  static int test_array [1 - 2 * !((s) >= L_AC_SIZEOF_GE)];
> +# elif defined L_AC_SIZEOF_LE
> +  static int test_array [1 - 2 * !((s) <= L_AC_SIZEOF_LE)];
> +# elif defined L_AC_SIZEOF_LT
> +  static int test_array [1 - 2 * !((s) <  L_AC_SIZEOF_LT)];
> +# else
> +#  error no such comparison operator
> +# endif
> +  test_array [0] = 0;
> +  return 0;
> +}
> +#endif
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 14:28               ` Konstantin Serebryany
@ 2014-04-17 14:29                 ` Bernhard Reutner-Fischer
  2014-04-17 15:17                   ` Konstantin Serebryany
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 14:29 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

On 17 April 2014 16:07, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Hi,
>
> If you are trying to modify the libsanitizer files, please read here:
> https://code.google.com/p/address-sanitizer/wiki/HowToContribute

I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
please install it there, i do not have write access to the LLVM nor
compiler-rt trees.
TIA,
>
> --kcc
>
> On Thu, Apr 17, 2014 at 5:49 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
>> Conditionalize usage of dlvsym(), nanosleep(), usleep();
>> Conditionalize layout of struct sigaction and type of it's member
>> sa_flags.
>> Conditionalize glob_t members gl_closedir, gl_readdir, gl_opendir,
>> gl_flags, gl_lstat, gl_stat.
>> Check for availability of glob.h for use with above members.
>> Check for availability of netrom/netrom.h, sys/ustat.h (for obsolete
>> ustat() function), utime.h (for obsolete utime() function), wordexp.h.
>> Determine size of sigset_t instead of hardcoding it.
>> Determine size of struct statfs64, if available.
>>
>> Leave defaults to match what glibc expects but probe them for uClibc.
>>
>> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
>> ---
>>  CMakeLists.txt                                     |  58 +++++++
>>  cmake/Modules/CompilerRTUtils.cmake                |  15 ++
>>  cmake/Modules/FunctionExistsNotStub.cmake          |  56 +++++++
>>  lib/interception/interception_linux.cc             |   2 +
>>  lib/interception/interception_linux.h              |   9 ++
>>  .../sanitizer_common_interceptors.inc              | 101 +++++++++++-
>>  .../sanitizer_platform_limits_posix.cc             |  44 ++++-
>>  .../sanitizer_platform_limits_posix.h              |  27 +++-
>>  lib/sanitizer_common/sanitizer_posix_libcdep.cc    |   9 ++
>>  make/platform/clang_linux.mk                       | 180 +++++++++++++++++++++
>>  make/platform/clang_linux_test_libc.c              |  68 ++++++++
>>  11 files changed, 561 insertions(+), 8 deletions(-)
>>  create mode 100644 cmake/Modules/FunctionExistsNotStub.cmake
>>  create mode 100644 make/platform/clang_linux_test_libc.c
>>
>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>> index e1a7a1f..af8073e 100644
>> --- a/CMakeLists.txt
>> +++ b/CMakeLists.txt
>> @@ -330,6 +330,64 @@ if(APPLE)
>>      -isysroot ${IOSSIM_SDK_DIR})
>>  endif()
>>
>> +set(ct_c ${COMPILER_RT_SOURCE_DIR}/make/platform/clang_linux_test_libc.c)
>> +check_include_file(sys/ustat.h HAVE_SYS_USTAT_H)
>> +check_include_file(utime.h HAVE_UTIME_H)
>> +check_include_file(wordexp.h HAVE_WORDEXP_H)
>> +check_include_file(glob.h HAVE_GLOB_H)
>> +include(FunctionExistsNotStub)
>> +check_function_exists_not_stub(${ct_c} nanosleep HAVE_NANOSLEEP)
>> +check_function_exists_not_stub(${ct_c} usleep HAVE_USLEEP)
>> +include(CheckTypeSize)
>> +# check for sizeof sigset_t
>> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
>> +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} signal.h)
>> +check_type_size("sigset_t" SIZEOF_SIGSET_T BUILTIN_TYPES_ONLY)
>> +if(EXISTS HAVE_SIZEOF_SIGSET_T)
>> +  set(SIZEOF_SIGSET_T ${HAVE_SIZEOF_SIGSET_T})
>> +endif()
>> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
>> +# check for sizeof struct statfs64
>> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
>> +check_include_file(sys/statfs.h HAVE_SYS_STATFS_H)
>> +check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
>> +if(HAVE_SYS_STATFS_H)
>> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/statfs.h)
>> +endif()
>> +if(HAVE_SYS_VFS_H)
>> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/vfs.h)
>> +endif()
>> +# Have to pass _LARGEFILE64_SOURCE otherwise there is no struct statfs64.
>> +# We forcefully enable LFS to retain glibc legacy behaviour herein.
>> +set(oCMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
>> +set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE)
>> +check_type_size("struct statfs64" SIZEOF_STRUCT_STATFS64)
>> +if(EXISTS HAVE_SIZEOF_STRUCT_STATFS64)
>> +  set(SIZEOF_STRUCT_STATFS64 ${HAVE_SIZEOF_STRUCT_STATFS64})
>> +else()
>> +  set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
>> +endif()
>> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
>> +# do not set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
>> +# it back here either way.
>> +include(CheckStructHasMember)
>> +check_struct_has_member(glob_t gl_flags glob.h HAVE_GLOB_T_GL_FLAGS)
>> +check_struct_has_member(glob_t gl_closedir glob.h HAVE_GLOB_T_GL_CLOSEDIR)
>> +check_struct_has_member(glob_t gl_readdir glob.h HAVE_GLOB_T_GL_READDIR)
>> +check_struct_has_member(glob_t gl_opendir glob.h HAVE_GLOB_T_GL_OPENDIR)
>> +check_struct_has_member(glob_t gl_lstat glob.h HAVE_GLOB_T_GL_LSTAT)
>> +check_struct_has_member(glob_t gl_stat glob.h HAVE_GLOB_T_GL_STAT)
>> +
>> +# folks seem to have an aversion to configure_file? So be it..
>> +foreach(x HAVE_SYS_USTAT_H HAVE_UTIME_H HAVE_WORDEXP_H HAVE_GLOB_H
>> +HAVE_NANOSLEEP HAVE_USLEEP SIZEOF_SIGSET_T SIZEOF_STRUCT_STATFS64
>> +HAVE_GLOB_T_GL_FLAGS HAVE_GLOB_T_GL_CLOSEDIR
>> +HAVE_GLOB_T_GL_READDIR HAVE_GLOB_T_GL_OPENDIR
>> +HAVE_GLOB_T_GL_LSTAT HAVE_GLOB_T_GL_STAT)
>> +def_undef_string(${x} SANITIZER_COMMON_CFLAGS)
>> +endforeach()
>> +
>> +
>>  # Architectures supported by Sanitizer runtimes. Specific sanitizers may
>>  # support only subset of these (e.g. TSan works on x86_64 only).
>>  filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
>> diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
>> index e22e775..3a0beec 100644
>> --- a/cmake/Modules/CompilerRTUtils.cmake
>> +++ b/cmake/Modules/CompilerRTUtils.cmake
>> @@ -59,3 +59,18 @@ macro(append_no_rtti_flag list)
>>    append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
>>    append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
>>  endmacro()
>> +
>> +# Appends -Dvalue=${value}/-Uvalue to all strings in ARGN
>> +macro(def_undef_string condition)
>> +  if("${${condition}}" STREQUAL "")
>> +    foreach(str ${ARGN})
>> +      set(${str} "${${str}} -U${condition}")
>> +    endforeach()
>> +  else()
>> +    foreach(str ${ARGN})
>> +      set(${str} "${${str}} '-D${condition}=${${condition}}'")
>> +    endforeach()
>> +  endif()
>> +endmacro()
>> +
>> +
>> diff --git a/cmake/Modules/FunctionExistsNotStub.cmake b/cmake/Modules/FunctionExistsNotStub.cmake
>> new file mode 100644
>> index 0000000..9f944dd
>> --- /dev/null
>> +++ b/cmake/Modules/FunctionExistsNotStub.cmake
>> @@ -0,0 +1,56 @@
>> +INCLUDE(CheckFunctionExists)
>> +
>> +# The following variables may be set before calling this macro to
>> +# modify the way the check is run:
>> +#
>> +#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
>> +#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
>> +#  CMAKE_REQUIRED_INCLUDES = list of include directories
>> +
>> +macro(CHECK_FUNCTION_EXISTS_NOT_STUB CSRC FUNCTION VARIABLE)
>> +  if(NOT DEFINED CHECKED_STUB_${VARIABLE})
>> +    set(CHECKED_STUB_${VARIABLE} "done" CACHE INTERNAL "checked stub of ${FUNCTION}")
>> +    CHECK_FUNCTION_EXISTS("${FUNCTION}" "${VARIABLE}")
>> +    if(DEFINED ${VARIABLE})
>> +      if(NOT CMAKE_REQUIRED_QUIET)
>> +        message(STATUS "Looking for stubbed out ${FUNCTION}")
>> +      endif()
>> +      if(CMAKE_REQUIRED_INCLUDES)
>> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES
>> +          "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
>> +      else()
>> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES)
>> +      endif()
>> +      set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS ${CMAKE_REQUIRED_FLAGS})
>> +      try_compile(${VARIABLE}
>> +        ${CMAKE_BINARY_DIR}
>> +        "${CSRC}"
>> +        COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
>> +        CMAKE_FLAGS
>> +        "-DCOMPILE_DEFINITIONS:STRING=-DL_features_h -DL_AC_CHECK_FUNC=${FUNCTION} -DL_AC_CHECK_FUNC_stub='defined __stub_${FUNCTION} || defined __stub___${FUNCTION}'"
>> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS}"
>> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES}"
>> +        OUTPUT_VARIABLE OUTPUT
>> +      )
>> +    endif()
>> +    if(${VARIABLE})
>> +      set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
>> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
>> +        "Determining if function ${FUNCTION} is a stub "
>> +        "passed with the following output:\n"
>> +        "${OUTPUT}\n\n")
>> +      if(NOT CMAKE_REQUIRED_QUIET)
>> +        message(STATUS "Looking for stubbed out ${FUNCTION} - no stub")
>> +      endif()
>> +    else()
>> +      set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
>> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
>> +        "Determining if function ${FUNCTION} is a stub "
>> +        "failed with the following output:\n"
>> +        "${OUTPUT}\n\n")
>> +      if(NOT CMAKE_REQUIRED_QUIET)
>> +        message(STATUS "Looking for stubbed out ${FUNCTION} - stub found")
>> +      endif()
>> +    endif()
>> +  endif()
>> +endmacro()
>> diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
>> index 6e908ac..c9b4a6e 100644
>> --- a/lib/interception/interception_linux.cc
>> +++ b/lib/interception/interception_linux.cc
>> @@ -24,11 +24,13 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>>    return real == wrapper;
>>  }
>>
>> +#ifdef HAVE_DLVSYM
>>  #if !defined(__ANDROID__)  // android does not have dlvsym
>>  void *GetFuncAddrVer(const char *func_name, const char *ver) {
>>    return dlvsym(RTLD_NEXT, func_name, ver);
>>  }
>>  #endif  // !defined(__ANDROID__)
>> +#endif // HAVE_DLVSYM
>>
>>  }  // namespace __interception
>>
>> diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
>> index d3f774b..4802fe5 100644
>> --- a/lib/interception/interception_linux.h
>> +++ b/lib/interception/interception_linux.h
>> @@ -25,7 +25,9 @@ namespace __interception {
>>  // returns true if a function with the given name was found.
>>  bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>>      uptr real, uptr wrapper);
>> +# ifdef HAVE_DLVSYM
>>  void *GetFuncAddrVer(const char *func_name, const char *ver);
>> +# endif /* HAVE_DLVSYM */
>>  }  // namespace __interception
>>
>>  #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)                          \
>> @@ -43,5 +45,12 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
>>       INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>>  #endif  // !defined(__ANDROID__)
>>
>> +#ifndef HAVE_DLVSYM
>> +/* Undo marketing crap above. Probe functionality, use result to decide.  */
>> +# undef INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD
>> +# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
>> +            INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>> +#endif
>> +
>>  #endif  // INTERCEPTION_LINUX_H
>>  #endif  // __linux__ || __FreeBSD__
>> diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
>> index 0d076a0..0a767d4 100644
>> --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
>> +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
>> @@ -1273,33 +1273,43 @@ static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
>>
>>  static THREADLOCAL __sanitizer_glob_t *pglob_copy;
>>
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>  static void wrapped_gl_closedir(void *dir) {
>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>    IndirectExternCall(pglob_copy->gl_closedir)(dir);
>>  }
>> +#endif
>>
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>  static void *wrapped_gl_readdir(void *dir) {
>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>    return IndirectExternCall(pglob_copy->gl_readdir)(dir);
>>  }
>> +#endif
>>
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>  static void *wrapped_gl_opendir(const char *s) {
>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>    return IndirectExternCall(pglob_copy->gl_opendir)(s);
>>  }
>> +#endif
>>
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>  static int wrapped_gl_lstat(const char *s, void *st) {
>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>    return IndirectExternCall(pglob_copy->gl_lstat)(s, st);
>>  }
>> +#endif
>>
>> +#ifdef HAVE_GLOB_T_GL_STAT
>>  static int wrapped_gl_stat(const char *s, void *st) {
>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>    return IndirectExternCall(pglob_copy->gl_stat)(s, st);
>>  }
>> +#endif
>>
>>  INTERCEPTOR(int, glob, const char *pattern, int flags,
>>              int (*errfunc)(const char *epath, int eerrno),
>> @@ -1307,24 +1317,64 @@ INTERCEPTOR(int, glob, const char *pattern, int flags,
>>    void *ctx;
>>    COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
>>    __sanitizer_glob_t glob_copy = {
>> -      0,                  0,                   0,
>> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
>> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
>> +       0,
>> +       0,
>> +       0
>> +#ifdef HAVE_GLOB_T_GL_FLAGS
>> +       ,0
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>> +       ,wrapped_gl_closedir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>> +       ,wrapped_gl_readdir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>> +       ,wrapped_gl_opendir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>> +       ,wrapped_gl_lstat
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>> +       ,wrapped_gl_stat
>> +#endif
>> +  };
>> +
>>    if (flags & glob_altdirfunc) {
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>> +#endif
>>      pglob_copy = &glob_copy;
>>    }
>>    int res = REAL(glob)(pattern, flags, errfunc, pglob);
>>    if (flags & glob_altdirfunc) {
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>> +#endif
>>    }
>>    pglob_copy = 0;
>>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
>> @@ -1337,24 +1387,63 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
>>    void *ctx;
>>    COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
>>    __sanitizer_glob_t glob_copy = {
>> -      0,                  0,                   0,
>> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
>> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
>> +       0,
>> +       0,
>> +       0
>> +#ifdef HAVE_GLOB_T_GL_FLAGS
>> +       ,0
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>> +       ,wrapped_gl_closedir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>> +       ,wrapped_gl_readdir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>> +       ,wrapped_gl_opendir
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>> +       ,wrapped_gl_lstat
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>> +       ,wrapped_gl_stat
>> +#endif
>> +  };
>>    if (flags & glob_altdirfunc) {
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>> +#endif
>>      pglob_copy = &glob_copy;
>>    }
>>    int res = REAL(glob64)(pattern, flags, errfunc, pglob);
>>    if (flags & glob_altdirfunc) {
>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>> +#endif
>> +#ifdef HAVE_GLOB_T_GL_STAT
>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>> +#endif
>>    }
>>    pglob_copy = 0;
>>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
>> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>> index 9ae4870..645777f 100644
>> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>> @@ -103,14 +103,18 @@
>>  #endif
>>
>>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
>> +# ifdef HAVE_UTIME_H
>>  # include <utime.h>
>> +# endif
>>  # include <sys/ptrace.h>
>>  #endif
>>
>>  #if !SANITIZER_ANDROID
>>  #include <ifaddrs.h>
>>  #include <sys/ucontext.h>
>> +# ifdef HAVE_WORDEXP_H
>>  #include <wordexp.h>
>> +# endif
>>  #endif
>>
>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
>> @@ -119,7 +123,9 @@
>>  #include <net/if_ppp.h>
>>  #include <netax25/ax25.h>
>>  #include <netipx/ipx.h>
>> +# ifdef HAVE_NETROM_NETROM_H
>>  #include <netrom/netrom.h>
>> +# endif
>>  #include <rpc/xdr.h>
>>  #include <scsi/scsi.h>
>>  #include <sys/mtio.h>
>> @@ -128,7 +134,9 @@
>>  #include <sys/statvfs.h>
>>  #include <sys/timex.h>
>>  #include <sys/user.h>
>> +# ifdef HAVE_SYS_USTAT_H
>>  #include <sys/ustat.h>
>> +# endif
>>  #include <linux/cyclades.h>
>>  #include <linux/if_eql.h>
>>  #include <linux/if_plip.h>
>> @@ -215,12 +223,16 @@ namespace __sanitizer {
>>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
>>    unsigned struct_rlimit_sz = sizeof(struct rlimit);
>>    unsigned struct_timespec_sz = sizeof(struct timespec);
>> +# ifdef HAVE_UTIME_H
>>    unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
>> +# endif
>>    unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
>>  #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
>>
>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
>> +# ifdef HAVE_SYS_USTAT_H
>>    unsigned struct_ustat_sz = sizeof(struct ustat);
>> +# endif
>>    unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
>>    unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
>>  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
>> @@ -266,7 +278,9 @@ namespace __sanitizer {
>>
>>  #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
>>    int glob_nomatch = GLOB_NOMATCH;
>> +# ifdef GLOB_ALTDIRFUNC
>>    int glob_altdirfunc = GLOB_ALTDIRFUNC;
>> +# endif
>>  #endif
>>
>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
>> @@ -370,7 +384,9 @@ namespace __sanitizer {
>>    unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
>>    unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
>>    unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
>> +# ifdef HAVE_NETROM_NETROM_H
>>    unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
>> +# endif
>>    unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
>>    unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
>>    unsigned struct_serial_multiport_struct_sz
>> @@ -805,10 +821,18 @@ namespace __sanitizer {
>>    unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
>>    unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
>>    unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
>> +# ifdef SIOCNRDECOBS
>>    unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
>> +# endif
>> +# ifdef SIOCNRGETPARMS
>>    unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
>> +# endif
>> +# ifdef SIOCNRRTCTL
>>    unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
>> +# endif
>> +# ifdef SIOCNRSETPARMS
>>    unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
>> +# endif
>>    unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
>>    unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
>>    unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
>> @@ -890,12 +914,24 @@ CHECK_TYPE_SIZE(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);
>> +# ifdef HAVE_GLOB_T_GL_FLAGS
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
>> +# endif
>> +# ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
>> +# endif
>> +# ifdef HAVE_GLOB_T_GL_READDIR
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
>> +# endif
>> +# ifdef HAVE_GLOB_T_GL_OPENDIR
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
>> +# endif
>> +# ifdef HAVE_GLOB_T_GL_LSTAT
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
>> +# endif
>> +# ifdef HAVE_GLOB_T_GL_STAT
>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
>> +# endif
>>  #endif
>>
>>  CHECK_TYPE_SIZE(addrinfo);
>> @@ -967,11 +1003,17 @@ CHECK_TYPE_SIZE(sigset_t);
>>  COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
>>  // Can't write checks for sa_handler and sa_sigaction due to them being
>>  // preprocessor macros.
>> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
>> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
>>  #if SANITIZER_LINUX
>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
>>  #endif
>> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>
>>  #if SANITIZER_LINUX
>>  CHECK_TYPE_SIZE(__sysctl_args);
>> @@ -991,7 +1033,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
>>  CHECK_TYPE_SIZE(__kernel_fd_set);
>>  #endif
>>
>> -#if !SANITIZER_ANDROID
>> +#ifdef HAVE_WORDEXP_H
>>  CHECK_TYPE_SIZE(wordexp_t);
>>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
>>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
>> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>> index a780ee2..04c6a96 100644
>> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>> @@ -478,7 +478,8 @@ namespace __sanitizer {
>>  #elif SANITIZER_LINUX
>>    struct __sanitizer_sigset_t {
>>      // The size is determined by looking at sizeof of real sigset_t on linux.
>> -    uptr val[128 / sizeof(uptr)];
>> +    /* .. except this should be * sizeof(uptr), not '/', no? */
>> +    uptr val[SIZEOF_SIGSET_T / sizeof(uptr)];
>>    };
>>  #elif SANITIZER_FREEBSD
>>    struct __sanitizer_sigset_t {
>> @@ -487,6 +488,17 @@ namespace __sanitizer {
>>    };
>>  #endif
>>
>> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>> +  struct __sanitizer_sigaction {
>> +    union {
>> +      void (*sigaction)(int sig, void *siginfo, void *uctx);
>> +      void (*handler)(int sig);
>> +    };
>> +    STRUCT_SIGACTION_SA_FLAGS_TYPE sa_flags;
>> +    void (*sa_restorer)();
>> +    __sanitizer_sigset_t sa_mask;
>> +  };
>> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>    // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
>>    struct __sanitizer_sigaction {
>>      union {
>> @@ -504,6 +516,7 @@ namespace __sanitizer {
>>      void (*sa_restorer)();
>>  #endif
>>    };
>> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>
>>  #if SANITIZER_FREEBSD
>>    typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
>> @@ -588,13 +601,25 @@ namespace __sanitizer {
>>      uptr gl_pathc;
>>      char **gl_pathv;
>>      uptr gl_offs;
>> +#  ifdef HAVE_GLOB_T_GL_FLAGS
>>      int gl_flags;
>> +#  endif
>>
>> +#  ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>      void (*gl_closedir)(void *dirp);
>> +#  endif
>> +#  ifdef HAVE_GLOB_T_GL_READDIR
>>      void *(*gl_readdir)(void *dirp);
>> +#  endif
>> +#  ifdef HAVE_GLOB_T_GL_OPENDIR
>>      void *(*gl_opendir)(const char *);
>> +#  endif
>> +#  ifdef HAVE_GLOB_T_GL_LSTAT
>>      int (*gl_lstat)(const char *, void *);
>> +#  endif
>> +#  ifdef HAVE_GLOB_T_GL_STAT
>>      int (*gl_stat)(const char *, void *);
>> +#  endif
>>    };
>>  # elif SANITIZER_FREEBSD
>>    struct __sanitizer_glob_t {
>> diff --git a/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>> index bb6e587..973f698 100644
>> --- a/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>> +++ b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>> @@ -73,7 +73,16 @@ void SleepForSeconds(int seconds) {
>>  }
>>
>>  void SleepForMillis(int millis) {
>> +#ifdef HAVE_NANOSLEEP
>> +  struct timespec ts;
>> +  ts.tv_sec = millis / 1000;
>> +  ts.tv_nsec = (millis % 1000) * 1000000;
>> +  nanosleep(&ts, NULL); /* could as well loop here */
>> +#elif defined HAVE_USLEEP
>>    usleep(millis * 1000);
>> +# else
>> +  dunno how to SleepForMillis
>> +#endif
>>  }
>>
>>  void Abort() {
>> diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk
>> index c6921ea..5ce1567 100644
>> --- a/make/platform/clang_linux.mk
>> +++ b/make/platform/clang_linux.mk
>> @@ -74,6 +74,185 @@ Arch.dfsan-x86_64 := x86_64
>>  Arch.lsan-x86_64 := x86_64
>>  endif
>>
>> +# TryCompile2 compiler source flags
>> +# Returns exit code of running a compiler invocation.
>> +# Same as TryCompile but in outer scope, don't want to touch the other one
>> +TryCompile2 = \
>> +  $(shell \
>> +    cflags=""; \
>> +    for flag in $(3); do \
>> +      cflags="$$cflags $$flag"; \
>> +    done; \
>> +    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
>> +    echo $$?)
>> +
>> +# our conftest.c
>> +ct_c = $(ProjSrcRoot)/make/platform/clang_linux_test_libc.c
>> +
>> +HAVE_DLVSYM := 1
>> +HAVE_NETROM_NETROM_H := 1
>> +HAVE_GLOB_H := 1
>> +HAVE_NANOSLEEP := 1
>> +HAVE_GLOB_T_GL_CLOSEDIR := 1
>> +HAVE_GLOB_T_GL_FLAGS := 1
>> +HAVE_GLOB_T_GL_LSTAT := 1
>> +HAVE_GLOB_T_GL_OPENDIR := 1
>> +HAVE_GLOB_T_GL_READDIR := 1
>> +HAVE_GLOB_T_GL_STAT := 1
>> +HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 0
>> +HAVE_SYS_USTAT_H := 1
>> +HAVE_USLEEP := 1
>> +HAVE_UTIME_H := 1
>> +HAVE_WORDEXP_H := 1
>> +SIZEOF_STRUCT_STATFS64 := 120
>> +SIZEOF_SIGSET_T := 128
>> +STRUCT_SIGACTION_SA_FLAGS_TYPE := int
>> +
>> +#ifneq ($(findstring -uclibc,$(CompilerTargetTriple)),)
>> +# does not work, cross-compilation seems to be non-working?
>> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_UCLIBC -DL_AC_CHECK_HEADER="<stdio.h>",),0)
>> +  HAVE_DLVSYM :=
>> +  HAVE_NETROM_NETROM_H :=
>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned long
>> +ifneq ($(filter alpha%,$(CompilerTargetTriple)),)
>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
>> +endif
>> +ifneq ($(filter mips%,$(CompilerTargetTriple)),)
>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
>> +endif
>> +  HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 1
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/ustat.h>",),0)
>> +  HAVE_SYS_USTAT_H :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<utime.h>",),0)
>> +  HAVE_UTIME_H :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<wordexp.h>",),0)
>> +  HAVE_WORDEXP_H :=
>> +endif
>> +glob_h := -DL_AC_CHECK_HEADER="<glob.h>"
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN $(glob_h),),0)
>> +  HAVE_GLOB_H :=
>> +endif
>> +# check for struct glob members (check for GNU extensions)
>> +glob_h += -DL_AC_STRUCT="glob_t"
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_flags,),0)
>> +  HAVE_GLOB_T_GL_FLAGS :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_closedir,),0)
>> +  HAVE_GLOB_T_GL_CLOSEDIR :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_readdir,),0)
>> +  HAVE_GLOB_T_GL_READDIR :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_opendir,),0)
>> +  HAVE_GLOB_T_GL_OPENDIR :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_lstat,),0)
>> +  HAVE_GLOB_T_GL_LSTAT :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_stat,),0)
>> +  HAVE_GLOB_T_GL_STAT :=
>> +endif
>> +# check misc functions
>> +# for __stub_* on glibc and uClibc including features.h is enough
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=nanosleep -DL_AC_CHECK_FUNC_stub="defined __stub_nanosleep || defined __stub___nanosleep",),0)
>> +  HAVE_NANOSLEEP :=
>> +endif
>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=usleep -DL_AC_CHECK_FUNC_stub="defined __stub_usleep || defined __stub___usleep",),0)
>> +  HAVE_USLEEP :=
>> +endif
>> +
>> +# AC_CHECK_SIZEOF, in make
>> +define ac_check_sizeof
>> +$(shell \
>> +if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; \
>> +then \
>> +  ac_lo=0 ac_mid=0; \
>> +  while :; \
>> +  do \
>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>> +    ac_hi=$$ac_mid; \
>> +    break; \
>> +  else \
>> +    ac_lo=$$(( $$ac_mid + 1 )); \
>> +    if test $$ac_lo -le $$ac_mid; then ac_lo= ac_hi=; break; fi; \
>> +    ac_mid=$$(( 2 * $$ac_mid + 1 )); \
>> +  fi; \
>> +  done; \
>> +else \
>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LT=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>> +    ac_hi=-1 ac_mid=-1; \
>> +    while :; \
>> +    do \
>> +    if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>> +      ac_lo=$$ac_mid; \
>> +      break; \
>> +    else \
>> +      ac_hi=$$(( ($$ac_mid) - 1 )); \
>> +      if test $$ac_mid -le $$ac_hi; then ac_lo= ac_hi=; break; fi; \
>> +      ac_mid=$$(( 2 * $$ac_mid )); \
>> +    fi; \
>> +    done; \
>> +  else \
>> +    ac_lo= ac_hi=; \
>> +  fi; \
>> +fi; \
>> +while test "x$$ac_lo" != "x$$ac_hi"; \
>> +do \
>> +  ac_mid=$$(( ($$ac_hi - $$ac_lo) / 2 + $$ac_lo )); \
>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>> +    ac_hi=$$ac_mid; \
>> +  else \
>> +    ac_lo=$$(( ($$ac_mid) + 1 )); \
>> +  fi; \
>> +done; \
>> +echo $$(( $$ac_lo + 0 )); \
>> +)
>> +endef
>> +
>> +# determine sizeof sigset_t
>> +SIZEOF_SIGSET_T := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<signal.h>" -DL_AC_SIZEOF="sigset_t")
>> +
>> +# determine sizeof struct statfs64
>> +SIZEOF_STRUCT_STATFS64 := 0
>> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/statfs.h>",),0)
>> +SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/statfs.h>" -DL_AC_SIZEOF="struct statfs64")
>> +else
>> + ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/vfs.h>",),0)
>> + SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/vfs.h>" -DL_AC_SIZEOF="struct statfs64")
>> + endif
>> +endif
>> +# end of -uclibc handling
>> +endif
>> +
>> +define add_config_h_cppflag
>> +ifeq ($($(1)),)
>> +CONFIG_H_CPPFLAGS += -U$(1)
>> +else
>> +CONFIG_H_CPPFLAGS += '-D$(1)=$($(1))'
>> +endif
>> +endef
>> +
>> +CONFIG_H_CPPFLAGS :=
>> +$(eval $(call add_config_h_cppflag,HAVE_DLVSYM))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_H))
>> +$(eval $(call add_config_h_cppflag,HAVE_NANOSLEEP))
>> +$(eval $(call add_config_h_cppflag,HAVE_NETROM_NETROM_H))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_CLOSEDIR))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_FLAGS))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_LSTAT))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_OPENDIR))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_READDIR))
>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_STAT))
>> +$(eval $(call add_config_h_cppflag,HAVE_STRUCT_SIGACTION_SA_MASK_LAST))
>> +$(eval $(call add_config_h_cppflag,HAVE_SYS_USTAT_H))
>> +$(eval $(call add_config_h_cppflag,HAVE_USLEEP))
>> +$(eval $(call add_config_h_cppflag,HAVE_UTIME_H))
>> +$(eval $(call add_config_h_cppflag,HAVE_WORDEXP_H))
>> +$(eval $(call add_config_h_cppflag,SIZEOF_STRUCT_STATFS64))
>> +$(eval $(call add_config_h_cppflag,SIZEOF_SIGSET_T))
>> +$(eval $(call add_config_h_cppflag,STRUCT_SIGACTION_SA_FLAGS_TYPE))
>>  endif
>>
>>  ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
>> @@ -87,6 +266,7 @@ endif
>>
>>  CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
>>  SANITIZER_CFLAGS := -fPIE -fno-builtin -gline-tables-only
>> +CFLAGS += $(CONFIG_H_CPPFLAGS)
>>
>>  CFLAGS.full-i386 := $(CFLAGS) -m32
>>  CFLAGS.full-x86_64 := $(CFLAGS) -m64
>> diff --git a/make/platform/clang_linux_test_libc.c b/make/platform/clang_linux_test_libc.c
>> new file mode 100644
>> index 0000000..2f9bba8
>> --- /dev/null
>> +++ b/make/platform/clang_linux_test_libc.c
>> @@ -0,0 +1,68 @@
>> +/* This file is used to check for libc characteristics and features */
>> +#ifdef L_features_h
>> +# include <features.h>
>> +#endif
>> +
>> +#ifdef L_AC_CHECK_HEADER
>> +/* compile-time check for availability of a header */
>> +# include L_AC_CHECK_HEADER
>> +#endif
>> +
>> +#ifdef L_AC_CHECK_UCLIBC
>> +# ifndef __UCLIBC__
>> +choke me /* not uClibc */
>> +# endif
>> +#endif
>> +
>> +#ifdef L_MAIN
>> +/* provide a dummy main for the linker */
>> +int main()
>> +{
>> +  return 0;
>> +}
>> +#endif
>> +
>> +#ifdef L_AC_CHECK_STRUCT_MEMBER
>> +/* compile-time check for presence of struct member */
>> +int main()
>> +{
>> +  static L_AC_STRUCT ac_aggr;
>> +  if (ac_aggr.L_AC_CHECK_STRUCT_MEMBER)
>> +    return 0;
>> +  return 0;
>> +}
>> +#endif
>> +
>> +#ifdef L_AC_CHECK_FUNC
>> +/* check if function (or macro) is available */
>> +# ifdef __cplusplus
>> +extern "C"
>> +# endif
>> +# if L_AC_CHECK_FUNC_stub
>> +choke me /* function 'L_AC_CHECK_FUNC' stubbed out! */
>> +# endif
>> +char L_AC_CHECK_FUNC ();
>> +int main ()
>> +{
>> +       return L_AC_CHECK_FUNC ();
>> +}
>> +#endif
>> +
>> +#ifdef L_AC_SIZEOF
>> +/* Determine sizeof expression */
>> +int main ()
>> +{
>> +# define s (long int) (sizeof (L_AC_SIZEOF))
>> +# if defined L_AC_SIZEOF_GE
>> +  static int test_array [1 - 2 * !((s) >= L_AC_SIZEOF_GE)];
>> +# elif defined L_AC_SIZEOF_LE
>> +  static int test_array [1 - 2 * !((s) <= L_AC_SIZEOF_LE)];
>> +# elif defined L_AC_SIZEOF_LT
>> +  static int test_array [1 - 2 * !((s) <  L_AC_SIZEOF_LT)];
>> +# else
>> +#  error no such comparison operator
>> +# endif
>> +  test_array [0] = 0;
>> +  return 0;
>> +}
>> +#endif
>> --
>> 1.9.1
>>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 14:29                 ` Bernhard Reutner-Fischer
@ 2014-04-17 15:17                   ` Konstantin Serebryany
  2014-04-17 16:47                     ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Konstantin Serebryany @ 2014-04-17 15:17 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 17 April 2014 16:07, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> Hi,
>>
>> If you are trying to modify the libsanitizer files, please read here:
>> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
>
> I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
> please install it there, i do not have write access to the LLVM nor
> compiler-rt trees.

I can commit your patch to llvm tree only after you follow the process
described on that page.
Sorry, this is a hard rule.

--kcc

> TIA,
>>
>> --kcc
>>
>> On Thu, Apr 17, 2014 at 5:49 PM, Bernhard Reutner-Fischer
>> <rep.dot.nop@gmail.com> wrote:
>>> Conditionalize usage of dlvsym(), nanosleep(), usleep();
>>> Conditionalize layout of struct sigaction and type of it's member
>>> sa_flags.
>>> Conditionalize glob_t members gl_closedir, gl_readdir, gl_opendir,
>>> gl_flags, gl_lstat, gl_stat.
>>> Check for availability of glob.h for use with above members.
>>> Check for availability of netrom/netrom.h, sys/ustat.h (for obsolete
>>> ustat() function), utime.h (for obsolete utime() function), wordexp.h.
>>> Determine size of sigset_t instead of hardcoding it.
>>> Determine size of struct statfs64, if available.
>>>
>>> Leave defaults to match what glibc expects but probe them for uClibc.
>>>
>>> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
>>> ---
>>>  CMakeLists.txt                                     |  58 +++++++
>>>  cmake/Modules/CompilerRTUtils.cmake                |  15 ++
>>>  cmake/Modules/FunctionExistsNotStub.cmake          |  56 +++++++
>>>  lib/interception/interception_linux.cc             |   2 +
>>>  lib/interception/interception_linux.h              |   9 ++
>>>  .../sanitizer_common_interceptors.inc              | 101 +++++++++++-
>>>  .../sanitizer_platform_limits_posix.cc             |  44 ++++-
>>>  .../sanitizer_platform_limits_posix.h              |  27 +++-
>>>  lib/sanitizer_common/sanitizer_posix_libcdep.cc    |   9 ++
>>>  make/platform/clang_linux.mk                       | 180 +++++++++++++++++++++
>>>  make/platform/clang_linux_test_libc.c              |  68 ++++++++
>>>  11 files changed, 561 insertions(+), 8 deletions(-)
>>>  create mode 100644 cmake/Modules/FunctionExistsNotStub.cmake
>>>  create mode 100644 make/platform/clang_linux_test_libc.c
>>>
>>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>>> index e1a7a1f..af8073e 100644
>>> --- a/CMakeLists.txt
>>> +++ b/CMakeLists.txt
>>> @@ -330,6 +330,64 @@ if(APPLE)
>>>      -isysroot ${IOSSIM_SDK_DIR})
>>>  endif()
>>>
>>> +set(ct_c ${COMPILER_RT_SOURCE_DIR}/make/platform/clang_linux_test_libc.c)
>>> +check_include_file(sys/ustat.h HAVE_SYS_USTAT_H)
>>> +check_include_file(utime.h HAVE_UTIME_H)
>>> +check_include_file(wordexp.h HAVE_WORDEXP_H)
>>> +check_include_file(glob.h HAVE_GLOB_H)
>>> +include(FunctionExistsNotStub)
>>> +check_function_exists_not_stub(${ct_c} nanosleep HAVE_NANOSLEEP)
>>> +check_function_exists_not_stub(${ct_c} usleep HAVE_USLEEP)
>>> +include(CheckTypeSize)
>>> +# check for sizeof sigset_t
>>> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
>>> +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} signal.h)
>>> +check_type_size("sigset_t" SIZEOF_SIGSET_T BUILTIN_TYPES_ONLY)
>>> +if(EXISTS HAVE_SIZEOF_SIGSET_T)
>>> +  set(SIZEOF_SIGSET_T ${HAVE_SIZEOF_SIGSET_T})
>>> +endif()
>>> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
>>> +# check for sizeof struct statfs64
>>> +set(oCMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
>>> +check_include_file(sys/statfs.h HAVE_SYS_STATFS_H)
>>> +check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
>>> +if(HAVE_SYS_STATFS_H)
>>> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/statfs.h)
>>> +endif()
>>> +if(HAVE_SYS_VFS_H)
>>> +  set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/vfs.h)
>>> +endif()
>>> +# Have to pass _LARGEFILE64_SOURCE otherwise there is no struct statfs64.
>>> +# We forcefully enable LFS to retain glibc legacy behaviour herein.
>>> +set(oCMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
>>> +set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE)
>>> +check_type_size("struct statfs64" SIZEOF_STRUCT_STATFS64)
>>> +if(EXISTS HAVE_SIZEOF_STRUCT_STATFS64)
>>> +  set(SIZEOF_STRUCT_STATFS64 ${HAVE_SIZEOF_STRUCT_STATFS64})
>>> +else()
>>> +  set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
>>> +endif()
>>> +set(CMAKE_EXTRA_INCLUDE_FILES "${oCMAKE_EXTRA_INCLUDE_FILES}")
>>> +# do not set(CMAKE_REQUIRED_DEFINITIONS ${oCMAKE_REQUIRED_DEFINITIONS})
>>> +# it back here either way.
>>> +include(CheckStructHasMember)
>>> +check_struct_has_member(glob_t gl_flags glob.h HAVE_GLOB_T_GL_FLAGS)
>>> +check_struct_has_member(glob_t gl_closedir glob.h HAVE_GLOB_T_GL_CLOSEDIR)
>>> +check_struct_has_member(glob_t gl_readdir glob.h HAVE_GLOB_T_GL_READDIR)
>>> +check_struct_has_member(glob_t gl_opendir glob.h HAVE_GLOB_T_GL_OPENDIR)
>>> +check_struct_has_member(glob_t gl_lstat glob.h HAVE_GLOB_T_GL_LSTAT)
>>> +check_struct_has_member(glob_t gl_stat glob.h HAVE_GLOB_T_GL_STAT)
>>> +
>>> +# folks seem to have an aversion to configure_file? So be it..
>>> +foreach(x HAVE_SYS_USTAT_H HAVE_UTIME_H HAVE_WORDEXP_H HAVE_GLOB_H
>>> +HAVE_NANOSLEEP HAVE_USLEEP SIZEOF_SIGSET_T SIZEOF_STRUCT_STATFS64
>>> +HAVE_GLOB_T_GL_FLAGS HAVE_GLOB_T_GL_CLOSEDIR
>>> +HAVE_GLOB_T_GL_READDIR HAVE_GLOB_T_GL_OPENDIR
>>> +HAVE_GLOB_T_GL_LSTAT HAVE_GLOB_T_GL_STAT)
>>> +def_undef_string(${x} SANITIZER_COMMON_CFLAGS)
>>> +endforeach()
>>> +
>>> +
>>>  # Architectures supported by Sanitizer runtimes. Specific sanitizers may
>>>  # support only subset of these (e.g. TSan works on x86_64 only).
>>>  filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
>>> diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
>>> index e22e775..3a0beec 100644
>>> --- a/cmake/Modules/CompilerRTUtils.cmake
>>> +++ b/cmake/Modules/CompilerRTUtils.cmake
>>> @@ -59,3 +59,18 @@ macro(append_no_rtti_flag list)
>>>    append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
>>>    append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
>>>  endmacro()
>>> +
>>> +# Appends -Dvalue=${value}/-Uvalue to all strings in ARGN
>>> +macro(def_undef_string condition)
>>> +  if("${${condition}}" STREQUAL "")
>>> +    foreach(str ${ARGN})
>>> +      set(${str} "${${str}} -U${condition}")
>>> +    endforeach()
>>> +  else()
>>> +    foreach(str ${ARGN})
>>> +      set(${str} "${${str}} '-D${condition}=${${condition}}'")
>>> +    endforeach()
>>> +  endif()
>>> +endmacro()
>>> +
>>> +
>>> diff --git a/cmake/Modules/FunctionExistsNotStub.cmake b/cmake/Modules/FunctionExistsNotStub.cmake
>>> new file mode 100644
>>> index 0000000..9f944dd
>>> --- /dev/null
>>> +++ b/cmake/Modules/FunctionExistsNotStub.cmake
>>> @@ -0,0 +1,56 @@
>>> +INCLUDE(CheckFunctionExists)
>>> +
>>> +# The following variables may be set before calling this macro to
>>> +# modify the way the check is run:
>>> +#
>>> +#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
>>> +#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
>>> +#  CMAKE_REQUIRED_INCLUDES = list of include directories
>>> +
>>> +macro(CHECK_FUNCTION_EXISTS_NOT_STUB CSRC FUNCTION VARIABLE)
>>> +  if(NOT DEFINED CHECKED_STUB_${VARIABLE})
>>> +    set(CHECKED_STUB_${VARIABLE} "done" CACHE INTERNAL "checked stub of ${FUNCTION}")
>>> +    CHECK_FUNCTION_EXISTS("${FUNCTION}" "${VARIABLE}")
>>> +    if(DEFINED ${VARIABLE})
>>> +      if(NOT CMAKE_REQUIRED_QUIET)
>>> +        message(STATUS "Looking for stubbed out ${FUNCTION}")
>>> +      endif()
>>> +      if(CMAKE_REQUIRED_INCLUDES)
>>> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES
>>> +          "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
>>> +      else()
>>> +        set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES)
>>> +      endif()
>>> +      set(MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS ${CMAKE_REQUIRED_FLAGS})
>>> +      try_compile(${VARIABLE}
>>> +        ${CMAKE_BINARY_DIR}
>>> +        "${CSRC}"
>>> +        COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
>>> +        CMAKE_FLAGS
>>> +        "-DCOMPILE_DEFINITIONS:STRING=-DL_features_h -DL_AC_CHECK_FUNC=${FUNCTION} -DL_AC_CHECK_FUNC_stub='defined __stub_${FUNCTION} || defined __stub___${FUNCTION}'"
>>> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_FLAGS}"
>>> +        "${MACRO_CHECK_FUNCTION_EXISTS_NOT_STUB_INCLUDES}"
>>> +        OUTPUT_VARIABLE OUTPUT
>>> +      )
>>> +    endif()
>>> +    if(${VARIABLE})
>>> +      set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
>>> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
>>> +        "Determining if function ${FUNCTION} is a stub "
>>> +        "passed with the following output:\n"
>>> +        "${OUTPUT}\n\n")
>>> +      if(NOT CMAKE_REQUIRED_QUIET)
>>> +        message(STATUS "Looking for stubbed out ${FUNCTION} - no stub")
>>> +      endif()
>>> +    else()
>>> +      set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
>>> +      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
>>> +        "Determining if function ${FUNCTION} is a stub "
>>> +        "failed with the following output:\n"
>>> +        "${OUTPUT}\n\n")
>>> +      if(NOT CMAKE_REQUIRED_QUIET)
>>> +        message(STATUS "Looking for stubbed out ${FUNCTION} - stub found")
>>> +      endif()
>>> +    endif()
>>> +  endif()
>>> +endmacro()
>>> diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
>>> index 6e908ac..c9b4a6e 100644
>>> --- a/lib/interception/interception_linux.cc
>>> +++ b/lib/interception/interception_linux.cc
>>> @@ -24,11 +24,13 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>>>    return real == wrapper;
>>>  }
>>>
>>> +#ifdef HAVE_DLVSYM
>>>  #if !defined(__ANDROID__)  // android does not have dlvsym
>>>  void *GetFuncAddrVer(const char *func_name, const char *ver) {
>>>    return dlvsym(RTLD_NEXT, func_name, ver);
>>>  }
>>>  #endif  // !defined(__ANDROID__)
>>> +#endif // HAVE_DLVSYM
>>>
>>>  }  // namespace __interception
>>>
>>> diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
>>> index d3f774b..4802fe5 100644
>>> --- a/lib/interception/interception_linux.h
>>> +++ b/lib/interception/interception_linux.h
>>> @@ -25,7 +25,9 @@ namespace __interception {
>>>  // returns true if a function with the given name was found.
>>>  bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
>>>      uptr real, uptr wrapper);
>>> +# ifdef HAVE_DLVSYM
>>>  void *GetFuncAddrVer(const char *func_name, const char *ver);
>>> +# endif /* HAVE_DLVSYM */
>>>  }  // namespace __interception
>>>
>>>  #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)                          \
>>> @@ -43,5 +45,12 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
>>>       INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>>>  #endif  // !defined(__ANDROID__)
>>>
>>> +#ifndef HAVE_DLVSYM
>>> +/* Undo marketing crap above. Probe functionality, use result to decide.  */
>>> +# undef INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD
>>> +# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
>>> +            INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>>> +#endif
>>> +
>>>  #endif  // INTERCEPTION_LINUX_H
>>>  #endif  // __linux__ || __FreeBSD__
>>> diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
>>> index 0d076a0..0a767d4 100644
>>> --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
>>> +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
>>> @@ -1273,33 +1273,43 @@ static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
>>>
>>>  static THREADLOCAL __sanitizer_glob_t *pglob_copy;
>>>
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>  static void wrapped_gl_closedir(void *dir) {
>>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>>    IndirectExternCall(pglob_copy->gl_closedir)(dir);
>>>  }
>>> +#endif
>>>
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>>  static void *wrapped_gl_readdir(void *dir) {
>>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>>    return IndirectExternCall(pglob_copy->gl_readdir)(dir);
>>>  }
>>> +#endif
>>>
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>>  static void *wrapped_gl_opendir(const char *s) {
>>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(1);
>>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>>    return IndirectExternCall(pglob_copy->gl_opendir)(s);
>>>  }
>>> +#endif
>>>
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>>  static int wrapped_gl_lstat(const char *s, void *st) {
>>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>>    return IndirectExternCall(pglob_copy->gl_lstat)(s, st);
>>>  }
>>> +#endif
>>>
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>>  static int wrapped_gl_stat(const char *s, void *st) {
>>>    COMMON_INTERCEPTOR_UNPOISON_PARAM(2);
>>>    COMMON_INTERCEPTOR_INITIALIZE_RANGE(s, REAL(strlen)(s) + 1);
>>>    return IndirectExternCall(pglob_copy->gl_stat)(s, st);
>>>  }
>>> +#endif
>>>
>>>  INTERCEPTOR(int, glob, const char *pattern, int flags,
>>>              int (*errfunc)(const char *epath, int eerrno),
>>> @@ -1307,24 +1317,64 @@ INTERCEPTOR(int, glob, const char *pattern, int flags,
>>>    void *ctx;
>>>    COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
>>>    __sanitizer_glob_t glob_copy = {
>>> -      0,                  0,                   0,
>>> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
>>> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
>>> +       0,
>>> +       0,
>>> +       0
>>> +#ifdef HAVE_GLOB_T_GL_FLAGS
>>> +       ,0
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>> +       ,wrapped_gl_closedir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>> +       ,wrapped_gl_readdir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>> +       ,wrapped_gl_opendir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>> +       ,wrapped_gl_lstat
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>> +       ,wrapped_gl_stat
>>> +#endif
>>> +  };
>>> +
>>>    if (flags & glob_altdirfunc) {
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>>> +#endif
>>>      pglob_copy = &glob_copy;
>>>    }
>>>    int res = REAL(glob)(pattern, flags, errfunc, pglob);
>>>    if (flags & glob_altdirfunc) {
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>>> +#endif
>>>    }
>>>    pglob_copy = 0;
>>>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
>>> @@ -1337,24 +1387,63 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
>>>    void *ctx;
>>>    COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
>>>    __sanitizer_glob_t glob_copy = {
>>> -      0,                  0,                   0,
>>> -      0,                  wrapped_gl_closedir, wrapped_gl_readdir,
>>> -      wrapped_gl_opendir, wrapped_gl_lstat,    wrapped_gl_stat};
>>> +       0,
>>> +       0,
>>> +       0
>>> +#ifdef HAVE_GLOB_T_GL_FLAGS
>>> +       ,0
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>> +       ,wrapped_gl_closedir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>> +       ,wrapped_gl_readdir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>> +       ,wrapped_gl_opendir
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>> +       ,wrapped_gl_lstat
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>> +       ,wrapped_gl_stat
>>> +#endif
>>> +  };
>>>    if (flags & glob_altdirfunc) {
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>>> +#endif
>>>      pglob_copy = &glob_copy;
>>>    }
>>>    int res = REAL(glob64)(pattern, flags, errfunc, pglob);
>>>    if (flags & glob_altdirfunc) {
>>> +#ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>      Swap(pglob->gl_closedir, glob_copy.gl_closedir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_READDIR
>>>      Swap(pglob->gl_readdir, glob_copy.gl_readdir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_OPENDIR
>>>      Swap(pglob->gl_opendir, glob_copy.gl_opendir);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_LSTAT
>>>      Swap(pglob->gl_lstat, glob_copy.gl_lstat);
>>> +#endif
>>> +#ifdef HAVE_GLOB_T_GL_STAT
>>>      Swap(pglob->gl_stat, glob_copy.gl_stat);
>>> +#endif
>>>    }
>>>    pglob_copy = 0;
>>>    if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob);
>>> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>>> index 9ae4870..645777f 100644
>>> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>>> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>>> @@ -103,14 +103,18 @@
>>>  #endif
>>>
>>>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
>>> +# ifdef HAVE_UTIME_H
>>>  # include <utime.h>
>>> +# endif
>>>  # include <sys/ptrace.h>
>>>  #endif
>>>
>>>  #if !SANITIZER_ANDROID
>>>  #include <ifaddrs.h>
>>>  #include <sys/ucontext.h>
>>> +# ifdef HAVE_WORDEXP_H
>>>  #include <wordexp.h>
>>> +# endif
>>>  #endif
>>>
>>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
>>> @@ -119,7 +123,9 @@
>>>  #include <net/if_ppp.h>
>>>  #include <netax25/ax25.h>
>>>  #include <netipx/ipx.h>
>>> +# ifdef HAVE_NETROM_NETROM_H
>>>  #include <netrom/netrom.h>
>>> +# endif
>>>  #include <rpc/xdr.h>
>>>  #include <scsi/scsi.h>
>>>  #include <sys/mtio.h>
>>> @@ -128,7 +134,9 @@
>>>  #include <sys/statvfs.h>
>>>  #include <sys/timex.h>
>>>  #include <sys/user.h>
>>> +# ifdef HAVE_SYS_USTAT_H
>>>  #include <sys/ustat.h>
>>> +# endif
>>>  #include <linux/cyclades.h>
>>>  #include <linux/if_eql.h>
>>>  #include <linux/if_plip.h>
>>> @@ -215,12 +223,16 @@ namespace __sanitizer {
>>>  #if SANITIZER_LINUX || SANITIZER_FREEBSD
>>>    unsigned struct_rlimit_sz = sizeof(struct rlimit);
>>>    unsigned struct_timespec_sz = sizeof(struct timespec);
>>> +# ifdef HAVE_UTIME_H
>>>    unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
>>> +# endif
>>>    unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
>>>  #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
>>>
>>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID
>>> +# ifdef HAVE_SYS_USTAT_H
>>>    unsigned struct_ustat_sz = sizeof(struct ustat);
>>> +# endif
>>>    unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
>>>    unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
>>>  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
>>> @@ -266,7 +278,9 @@ namespace __sanitizer {
>>>
>>>  #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
>>>    int glob_nomatch = GLOB_NOMATCH;
>>> +# ifdef GLOB_ALTDIRFUNC
>>>    int glob_altdirfunc = GLOB_ALTDIRFUNC;
>>> +# endif
>>>  #endif
>>>
>>>  #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
>>> @@ -370,7 +384,9 @@ namespace __sanitizer {
>>>    unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
>>>    unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
>>>    unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
>>> +# ifdef HAVE_NETROM_NETROM_H
>>>    unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
>>> +# endif
>>>    unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
>>>    unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
>>>    unsigned struct_serial_multiport_struct_sz
>>> @@ -805,10 +821,18 @@ namespace __sanitizer {
>>>    unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
>>>    unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
>>>    unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
>>> +# ifdef SIOCNRDECOBS
>>>    unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
>>> +# endif
>>> +# ifdef SIOCNRGETPARMS
>>>    unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
>>> +# endif
>>> +# ifdef SIOCNRRTCTL
>>>    unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
>>> +# endif
>>> +# ifdef SIOCNRSETPARMS
>>>    unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
>>> +# endif
>>>    unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
>>>    unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
>>>    unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
>>> @@ -890,12 +914,24 @@ CHECK_TYPE_SIZE(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);
>>> +# ifdef HAVE_GLOB_T_GL_FLAGS
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
>>> +# endif
>>> +# ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
>>> +# endif
>>> +# ifdef HAVE_GLOB_T_GL_READDIR
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
>>> +# endif
>>> +# ifdef HAVE_GLOB_T_GL_OPENDIR
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
>>> +# endif
>>> +# ifdef HAVE_GLOB_T_GL_LSTAT
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
>>> +# endif
>>> +# ifdef HAVE_GLOB_T_GL_STAT
>>>  CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
>>> +# endif
>>>  #endif
>>>
>>>  CHECK_TYPE_SIZE(addrinfo);
>>> @@ -967,11 +1003,17 @@ CHECK_TYPE_SIZE(sigset_t);
>>>  COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
>>>  // Can't write checks for sa_handler and sa_sigaction due to them being
>>>  // preprocessor macros.
>>> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
>>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
>>> +CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
>>> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
>>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
>>>  #if SANITIZER_LINUX
>>>  CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
>>>  #endif
>>> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>>
>>>  #if SANITIZER_LINUX
>>>  CHECK_TYPE_SIZE(__sysctl_args);
>>> @@ -991,7 +1033,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
>>>  CHECK_TYPE_SIZE(__kernel_fd_set);
>>>  #endif
>>>
>>> -#if !SANITIZER_ANDROID
>>> +#ifdef HAVE_WORDEXP_H
>>>  CHECK_TYPE_SIZE(wordexp_t);
>>>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
>>>  CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
>>> diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>>> index a780ee2..04c6a96 100644
>>> --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>>> +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>>> @@ -478,7 +478,8 @@ namespace __sanitizer {
>>>  #elif SANITIZER_LINUX
>>>    struct __sanitizer_sigset_t {
>>>      // The size is determined by looking at sizeof of real sigset_t on linux.
>>> -    uptr val[128 / sizeof(uptr)];
>>> +    /* .. except this should be * sizeof(uptr), not '/', no? */
>>> +    uptr val[SIZEOF_SIGSET_T / sizeof(uptr)];
>>>    };
>>>  #elif SANITIZER_FREEBSD
>>>    struct __sanitizer_sigset_t {
>>> @@ -487,6 +488,17 @@ namespace __sanitizer {
>>>    };
>>>  #endif
>>>
>>> +#if HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>> +  struct __sanitizer_sigaction {
>>> +    union {
>>> +      void (*sigaction)(int sig, void *siginfo, void *uctx);
>>> +      void (*handler)(int sig);
>>> +    };
>>> +    STRUCT_SIGACTION_SA_FLAGS_TYPE sa_flags;
>>> +    void (*sa_restorer)();
>>> +    __sanitizer_sigset_t sa_mask;
>>> +  };
>>> +#else // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>>    // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
>>>    struct __sanitizer_sigaction {
>>>      union {
>>> @@ -504,6 +516,7 @@ namespace __sanitizer {
>>>      void (*sa_restorer)();
>>>  #endif
>>>    };
>>> +#endif // HAVE_STRUCT_SIGACTION_SA_MASK_LAST
>>>
>>>  #if SANITIZER_FREEBSD
>>>    typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
>>> @@ -588,13 +601,25 @@ namespace __sanitizer {
>>>      uptr gl_pathc;
>>>      char **gl_pathv;
>>>      uptr gl_offs;
>>> +#  ifdef HAVE_GLOB_T_GL_FLAGS
>>>      int gl_flags;
>>> +#  endif
>>>
>>> +#  ifdef HAVE_GLOB_T_GL_CLOSEDIR
>>>      void (*gl_closedir)(void *dirp);
>>> +#  endif
>>> +#  ifdef HAVE_GLOB_T_GL_READDIR
>>>      void *(*gl_readdir)(void *dirp);
>>> +#  endif
>>> +#  ifdef HAVE_GLOB_T_GL_OPENDIR
>>>      void *(*gl_opendir)(const char *);
>>> +#  endif
>>> +#  ifdef HAVE_GLOB_T_GL_LSTAT
>>>      int (*gl_lstat)(const char *, void *);
>>> +#  endif
>>> +#  ifdef HAVE_GLOB_T_GL_STAT
>>>      int (*gl_stat)(const char *, void *);
>>> +#  endif
>>>    };
>>>  # elif SANITIZER_FREEBSD
>>>    struct __sanitizer_glob_t {
>>> diff --git a/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>>> index bb6e587..973f698 100644
>>> --- a/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>>> +++ b/lib/sanitizer_common/sanitizer_posix_libcdep.cc
>>> @@ -73,7 +73,16 @@ void SleepForSeconds(int seconds) {
>>>  }
>>>
>>>  void SleepForMillis(int millis) {
>>> +#ifdef HAVE_NANOSLEEP
>>> +  struct timespec ts;
>>> +  ts.tv_sec = millis / 1000;
>>> +  ts.tv_nsec = (millis % 1000) * 1000000;
>>> +  nanosleep(&ts, NULL); /* could as well loop here */
>>> +#elif defined HAVE_USLEEP
>>>    usleep(millis * 1000);
>>> +# else
>>> +  dunno how to SleepForMillis
>>> +#endif
>>>  }
>>>
>>>  void Abort() {
>>> diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk
>>> index c6921ea..5ce1567 100644
>>> --- a/make/platform/clang_linux.mk
>>> +++ b/make/platform/clang_linux.mk
>>> @@ -74,6 +74,185 @@ Arch.dfsan-x86_64 := x86_64
>>>  Arch.lsan-x86_64 := x86_64
>>>  endif
>>>
>>> +# TryCompile2 compiler source flags
>>> +# Returns exit code of running a compiler invocation.
>>> +# Same as TryCompile but in outer scope, don't want to touch the other one
>>> +TryCompile2 = \
>>> +  $(shell \
>>> +    cflags=""; \
>>> +    for flag in $(3); do \
>>> +      cflags="$$cflags $$flag"; \
>>> +    done; \
>>> +    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
>>> +    echo $$?)
>>> +
>>> +# our conftest.c
>>> +ct_c = $(ProjSrcRoot)/make/platform/clang_linux_test_libc.c
>>> +
>>> +HAVE_DLVSYM := 1
>>> +HAVE_NETROM_NETROM_H := 1
>>> +HAVE_GLOB_H := 1
>>> +HAVE_NANOSLEEP := 1
>>> +HAVE_GLOB_T_GL_CLOSEDIR := 1
>>> +HAVE_GLOB_T_GL_FLAGS := 1
>>> +HAVE_GLOB_T_GL_LSTAT := 1
>>> +HAVE_GLOB_T_GL_OPENDIR := 1
>>> +HAVE_GLOB_T_GL_READDIR := 1
>>> +HAVE_GLOB_T_GL_STAT := 1
>>> +HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 0
>>> +HAVE_SYS_USTAT_H := 1
>>> +HAVE_USLEEP := 1
>>> +HAVE_UTIME_H := 1
>>> +HAVE_WORDEXP_H := 1
>>> +SIZEOF_STRUCT_STATFS64 := 120
>>> +SIZEOF_SIGSET_T := 128
>>> +STRUCT_SIGACTION_SA_FLAGS_TYPE := int
>>> +
>>> +#ifneq ($(findstring -uclibc,$(CompilerTargetTriple)),)
>>> +# does not work, cross-compilation seems to be non-working?
>>> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_UCLIBC -DL_AC_CHECK_HEADER="<stdio.h>",),0)
>>> +  HAVE_DLVSYM :=
>>> +  HAVE_NETROM_NETROM_H :=
>>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned long
>>> +ifneq ($(filter alpha%,$(CompilerTargetTriple)),)
>>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
>>> +endif
>>> +ifneq ($(filter mips%,$(CompilerTargetTriple)),)
>>> +  STRUCT_SIGACTION_SA_FLAGS_TYPE := unsigned
>>> +endif
>>> +  HAVE_STRUCT_SIGACTION_SA_MASK_LAST := 1
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/ustat.h>",),0)
>>> +  HAVE_SYS_USTAT_H :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<utime.h>",),0)
>>> +  HAVE_UTIME_H :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<wordexp.h>",),0)
>>> +  HAVE_WORDEXP_H :=
>>> +endif
>>> +glob_h := -DL_AC_CHECK_HEADER="<glob.h>"
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN $(glob_h),),0)
>>> +  HAVE_GLOB_H :=
>>> +endif
>>> +# check for struct glob members (check for GNU extensions)
>>> +glob_h += -DL_AC_STRUCT="glob_t"
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_flags,),0)
>>> +  HAVE_GLOB_T_GL_FLAGS :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_closedir,),0)
>>> +  HAVE_GLOB_T_GL_CLOSEDIR :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_readdir,),0)
>>> +  HAVE_GLOB_T_GL_READDIR :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_opendir,),0)
>>> +  HAVE_GLOB_T_GL_OPENDIR :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_lstat,),0)
>>> +  HAVE_GLOB_T_GL_LSTAT :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) $(glob_h) -DL_AC_CHECK_STRUCT_MEMBER=gl_stat,),0)
>>> +  HAVE_GLOB_T_GL_STAT :=
>>> +endif
>>> +# check misc functions
>>> +# for __stub_* on glibc and uClibc including features.h is enough
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=nanosleep -DL_AC_CHECK_FUNC_stub="defined __stub_nanosleep || defined __stub___nanosleep",),0)
>>> +  HAVE_NANOSLEEP :=
>>> +endif
>>> +ifneq ($(call TryCompile2,$(CC),$(ct_c) -DL_features_h -DL_AC_CHECK_FUNC=usleep -DL_AC_CHECK_FUNC_stub="defined __stub_usleep || defined __stub___usleep",),0)
>>> +  HAVE_USLEEP :=
>>> +endif
>>> +
>>> +# AC_CHECK_SIZEOF, in make
>>> +define ac_check_sizeof
>>> +$(shell \
>>> +if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; \
>>> +then \
>>> +  ac_lo=0 ac_mid=0; \
>>> +  while :; \
>>> +  do \
>>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>>> +    ac_hi=$$ac_mid; \
>>> +    break; \
>>> +  else \
>>> +    ac_lo=$$(( $$ac_mid + 1 )); \
>>> +    if test $$ac_lo -le $$ac_mid; then ac_lo= ac_hi=; break; fi; \
>>> +    ac_mid=$$(( 2 * $$ac_mid + 1 )); \
>>> +  fi; \
>>> +  done; \
>>> +else \
>>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LT=0 -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>>> +    ac_hi=-1 ac_mid=-1; \
>>> +    while :; \
>>> +    do \
>>> +    if test $$($(CC) $(1) -DL_AC_SIZEOF_GE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>>> +      ac_lo=$$ac_mid; \
>>> +      break; \
>>> +    else \
>>> +      ac_hi=$$(( ($$ac_mid) - 1 )); \
>>> +      if test $$ac_mid -le $$ac_hi; then ac_lo= ac_hi=; break; fi; \
>>> +      ac_mid=$$(( 2 * $$ac_mid )); \
>>> +    fi; \
>>> +    done; \
>>> +  else \
>>> +    ac_lo= ac_hi=; \
>>> +  fi; \
>>> +fi; \
>>> +while test "x$$ac_lo" != "x$$ac_hi"; \
>>> +do \
>>> +  ac_mid=$$(( ($$ac_hi - $$ac_lo) / 2 + $$ac_lo )); \
>>> +  if test $$($(CC) $(1) -DL_AC_SIZEOF_LE=$$ac_mid -o /dev/null > /dev/null 2> /dev/null; echo $$?) -eq 0; then \
>>> +    ac_hi=$$ac_mid; \
>>> +  else \
>>> +    ac_lo=$$(( ($$ac_mid) + 1 )); \
>>> +  fi; \
>>> +done; \
>>> +echo $$(( $$ac_lo + 0 )); \
>>> +)
>>> +endef
>>> +
>>> +# determine sizeof sigset_t
>>> +SIZEOF_SIGSET_T := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<signal.h>" -DL_AC_SIZEOF="sigset_t")
>>> +
>>> +# determine sizeof struct statfs64
>>> +SIZEOF_STRUCT_STATFS64 := 0
>>> +ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/statfs.h>",),0)
>>> +SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/statfs.h>" -DL_AC_SIZEOF="struct statfs64")
>>> +else
>>> + ifeq ($(call TryCompile2,$(CC),$(ct_c) -DL_MAIN -DL_AC_CHECK_HEADER="<sys/vfs.h>",),0)
>>> + SIZEOF_STRUCT_STATFS64 := $(call ac_check_sizeof,$(ct_c) -DL_AC_CHECK_HEADER="<sys/vfs.h>" -DL_AC_SIZEOF="struct statfs64")
>>> + endif
>>> +endif
>>> +# end of -uclibc handling
>>> +endif
>>> +
>>> +define add_config_h_cppflag
>>> +ifeq ($($(1)),)
>>> +CONFIG_H_CPPFLAGS += -U$(1)
>>> +else
>>> +CONFIG_H_CPPFLAGS += '-D$(1)=$($(1))'
>>> +endif
>>> +endef
>>> +
>>> +CONFIG_H_CPPFLAGS :=
>>> +$(eval $(call add_config_h_cppflag,HAVE_DLVSYM))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_H))
>>> +$(eval $(call add_config_h_cppflag,HAVE_NANOSLEEP))
>>> +$(eval $(call add_config_h_cppflag,HAVE_NETROM_NETROM_H))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_CLOSEDIR))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_FLAGS))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_LSTAT))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_OPENDIR))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_READDIR))
>>> +$(eval $(call add_config_h_cppflag,HAVE_GLOB_T_GL_STAT))
>>> +$(eval $(call add_config_h_cppflag,HAVE_STRUCT_SIGACTION_SA_MASK_LAST))
>>> +$(eval $(call add_config_h_cppflag,HAVE_SYS_USTAT_H))
>>> +$(eval $(call add_config_h_cppflag,HAVE_USLEEP))
>>> +$(eval $(call add_config_h_cppflag,HAVE_UTIME_H))
>>> +$(eval $(call add_config_h_cppflag,HAVE_WORDEXP_H))
>>> +$(eval $(call add_config_h_cppflag,SIZEOF_STRUCT_STATFS64))
>>> +$(eval $(call add_config_h_cppflag,SIZEOF_SIGSET_T))
>>> +$(eval $(call add_config_h_cppflag,STRUCT_SIGACTION_SA_FLAGS_TYPE))
>>>  endif
>>>
>>>  ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
>>> @@ -87,6 +266,7 @@ endif
>>>
>>>  CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
>>>  SANITIZER_CFLAGS := -fPIE -fno-builtin -gline-tables-only
>>> +CFLAGS += $(CONFIG_H_CPPFLAGS)
>>>
>>>  CFLAGS.full-i386 := $(CFLAGS) -m32
>>>  CFLAGS.full-x86_64 := $(CFLAGS) -m64
>>> diff --git a/make/platform/clang_linux_test_libc.c b/make/platform/clang_linux_test_libc.c
>>> new file mode 100644
>>> index 0000000..2f9bba8
>>> --- /dev/null
>>> +++ b/make/platform/clang_linux_test_libc.c
>>> @@ -0,0 +1,68 @@
>>> +/* This file is used to check for libc characteristics and features */
>>> +#ifdef L_features_h
>>> +# include <features.h>
>>> +#endif
>>> +
>>> +#ifdef L_AC_CHECK_HEADER
>>> +/* compile-time check for availability of a header */
>>> +# include L_AC_CHECK_HEADER
>>> +#endif
>>> +
>>> +#ifdef L_AC_CHECK_UCLIBC
>>> +# ifndef __UCLIBC__
>>> +choke me /* not uClibc */
>>> +# endif
>>> +#endif
>>> +
>>> +#ifdef L_MAIN
>>> +/* provide a dummy main for the linker */
>>> +int main()
>>> +{
>>> +  return 0;
>>> +}
>>> +#endif
>>> +
>>> +#ifdef L_AC_CHECK_STRUCT_MEMBER
>>> +/* compile-time check for presence of struct member */
>>> +int main()
>>> +{
>>> +  static L_AC_STRUCT ac_aggr;
>>> +  if (ac_aggr.L_AC_CHECK_STRUCT_MEMBER)
>>> +    return 0;
>>> +  return 0;
>>> +}
>>> +#endif
>>> +
>>> +#ifdef L_AC_CHECK_FUNC
>>> +/* check if function (or macro) is available */
>>> +# ifdef __cplusplus
>>> +extern "C"
>>> +# endif
>>> +# if L_AC_CHECK_FUNC_stub
>>> +choke me /* function 'L_AC_CHECK_FUNC' stubbed out! */
>>> +# endif
>>> +char L_AC_CHECK_FUNC ();
>>> +int main ()
>>> +{
>>> +       return L_AC_CHECK_FUNC ();
>>> +}
>>> +#endif
>>> +
>>> +#ifdef L_AC_SIZEOF
>>> +/* Determine sizeof expression */
>>> +int main ()
>>> +{
>>> +# define s (long int) (sizeof (L_AC_SIZEOF))
>>> +# if defined L_AC_SIZEOF_GE
>>> +  static int test_array [1 - 2 * !((s) >= L_AC_SIZEOF_GE)];
>>> +# elif defined L_AC_SIZEOF_LE
>>> +  static int test_array [1 - 2 * !((s) <= L_AC_SIZEOF_LE)];
>>> +# elif defined L_AC_SIZEOF_LT
>>> +  static int test_array [1 - 2 * !((s) <  L_AC_SIZEOF_LT)];
>>> +# else
>>> +#  error no such comparison operator
>>> +# endif
>>> +  test_array [0] = 0;
>>> +  return 0;
>>> +}
>>> +#endif
>>> --
>>> 1.9.1
>>>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 15:17                   ` Konstantin Serebryany
@ 2014-04-17 16:47                     ` Bernhard Reutner-Fischer
  2014-04-17 17:06                       ` Konstantin Serebryany
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-17 16:47 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

On 17 April 2014 16:51:23 Konstantin Serebryany 
<konstantin.s.serebryany@gmail.com> wrote:

> On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
> > On 17 April 2014 16:07, Konstantin Serebryany
> > <konstantin.s.serebryany@gmail.com> wrote:
> >> Hi,
> >>
> >> If you are trying to modify the libsanitizer files, please read here:
> >> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
> >
> > I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
> > please install it there, i do not have write access to the LLVM nor
> > compiler-rt trees.
>
> I can commit your patch to llvm tree only after you follow the process
> described on that page.
> Sorry, this is a hard rule.

What part of the process do you think I did not follow?

I made a patch for compiler-rt, sent it to llvm-commits@cs.uiuc.edu then 
provided the corresponding GCC parts, along a backport of the new bits that 
I expect to be overwritten once you do a new merge, leaving just the GCC 
configuy bits. This is how I read the wiki page you cite.

Please tell me what you expect me to do differently?

Thanks,
>
> --kcc


Sent with AquaMail for Android
http://www.aqua-mail.com


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 16:47                     ` Bernhard Reutner-Fischer
@ 2014-04-17 17:06                       ` Konstantin Serebryany
  2014-04-23  8:50                         ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Konstantin Serebryany @ 2014-04-17 17:06 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

On Thu, Apr 17, 2014 at 8:45 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 17 April 2014 16:51:23 Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>
>> On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
>> <rep.dot.nop@gmail.com> wrote:
>> > On 17 April 2014 16:07, Konstantin Serebryany
>> > <konstantin.s.serebryany@gmail.com> wrote:
>> >> Hi,
>> >>
>> >> If you are trying to modify the libsanitizer files, please read here:
>> >> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
>> >
>> > I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
>> > please install it there, i do not have write access to the LLVM nor
>> > compiler-rt trees.
>>
>> I can commit your patch to llvm tree only after you follow the process
>> described on that page.
>> Sorry, this is a hard rule.
>
>
> What part of the process do you think I did not follow?
>
> I made a patch for compiler-rt, sent it to llvm-commits@cs.uiuc.edu then
> provided the corresponding GCC parts, along a backport of the new bits that
> I expect to be overwritten once you do a new merge, leaving just the GCC
> configuy bits. This is how I read the wiki page you cite.
>
> Please tell me what you expect me to do differently?

First, I did not notice that you've sent it to llvm-commits because it
was also sent to the gcc list (unusual thing to happen)
and got filtered into the gcc part of my mail. Sorry.
But second, the patch is far from trivial and you should not expect us
to commit it w/o a careful review,
so here comes another part of the wiki: "For non-trivial patches
please use Phabricator -- this will help us reply faster."

--kcc


>
> Thanks,
>>
>>
>> --kcc
>
>
>
> Sent with AquaMail for Android
> http://www.aqua-mail.com
>
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-17 17:06                       ` Konstantin Serebryany
@ 2014-04-23  8:50                         ` Bernhard Reutner-Fischer
  2014-04-23  8:59                           ` Konstantin Serebryany
  0 siblings, 1 reply; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2014-04-23  8:50 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

On 17 April 2014 19:01, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> On Thu, Apr 17, 2014 at 8:45 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
>> On 17 April 2014 16:51:23 Konstantin Serebryany
>> <konstantin.s.serebryany@gmail.com> wrote:
>>
>>> On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
>>> <rep.dot.nop@gmail.com> wrote:
>>> > On 17 April 2014 16:07, Konstantin Serebryany
>>> > <konstantin.s.serebryany@gmail.com> wrote:
>>> >> Hi,
>>> >>
>>> >> If you are trying to modify the libsanitizer files, please read here:
>>> >> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
>>> >
>>> > I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
>>> > please install it there, i do not have write access to the LLVM nor
>>> > compiler-rt trees.
>>>
>>> I can commit your patch to llvm tree only after you follow the process
>>> described on that page.
>>> Sorry, this is a hard rule.
>>
>>
>> What part of the process do you think I did not follow?
>>
>> I made a patch for compiler-rt, sent it to llvm-commits@cs.uiuc.edu then
>> provided the corresponding GCC parts, along a backport of the new bits that
>> I expect to be overwritten once you do a new merge, leaving just the GCC
>> configuy bits. This is how I read the wiki page you cite.
>>
>> Please tell me what you expect me to do differently?
>
> First, I did not notice that you've sent it to llvm-commits because it
> was also sent to the gcc list (unusual thing to happen)
> and got filtered into the gcc part of my mail. Sorry.
> But second, the patch is far from trivial and you should not expect us
> to commit it w/o a careful review,
> so here comes another part of the wiki: "For non-trivial patches
> please use Phabricator -- this will help us reply faster."

http://reviews.llvm.org/D3464

thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-23  8:50                         ` Bernhard Reutner-Fischer
@ 2014-04-23  8:59                           ` Konstantin Serebryany
  2018-09-21  8:33                             ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 39+ messages in thread
From: Konstantin Serebryany @ 2014-04-23  8:59 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, llvm-commits

Thanks. Let's move the discussion there.

On Wed, Apr 23, 2014 at 12:46 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 17 April 2014 19:01, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> On Thu, Apr 17, 2014 at 8:45 PM, Bernhard Reutner-Fischer
>> <rep.dot.nop@gmail.com> wrote:
>>> On 17 April 2014 16:51:23 Konstantin Serebryany
>>> <konstantin.s.serebryany@gmail.com> wrote:
>>>
>>>> On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
>>>> <rep.dot.nop@gmail.com> wrote:
>>>> > On 17 April 2014 16:07, Konstantin Serebryany
>>>> > <konstantin.s.serebryany@gmail.com> wrote:
>>>> >> Hi,
>>>> >>
>>>> >> If you are trying to modify the libsanitizer files, please read here:
>>>> >> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
>>>> >
>>>> > I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
>>>> > please install it there, i do not have write access to the LLVM nor
>>>> > compiler-rt trees.
>>>>
>>>> I can commit your patch to llvm tree only after you follow the process
>>>> described on that page.
>>>> Sorry, this is a hard rule.
>>>
>>>
>>> What part of the process do you think I did not follow?
>>>
>>> I made a patch for compiler-rt, sent it to llvm-commits@cs.uiuc.edu then
>>> provided the corresponding GCC parts, along a backport of the new bits that
>>> I expect to be overwritten once you do a new merge, leaving just the GCC
>>> configuy bits. This is how I read the wiki page you cite.
>>>
>>> Please tell me what you expect me to do differently?
>>
>> First, I did not notice that you've sent it to llvm-commits because it
>> was also sent to the gcc list (unusual thing to happen)
>> and got filtered into the gcc part of my mail. Sorry.
>> But second, the patch is far from trivial and you should not expect us
>> to commit it w/o a careful review,
>> so here comes another part of the wiki: "For non-trivial patches
>> please use Phabricator -- this will help us reply faster."
>
> http://reviews.llvm.org/D3464
>
> thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc
  2014-04-23  8:59                           ` Konstantin Serebryany
@ 2018-09-21  8:33                             ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 39+ messages in thread
From: Bernhard Reutner-Fischer @ 2018-09-21  8:33 UTC (permalink / raw)
  To: Konstantin Serebryany
  Cc: Jakub Jelinek, GCC Patches, Dodji Seketeli, Kostya Serebryany,
	Dmitry Vyukov, Commit Messages and Patches for LLVM, Yuri Gribov

On Wed, 23 Apr 2014 at 10:58, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
>
> Thanks. Let's move the discussion there.

4-early ping..
Thanks to Yuri for his remark there.
Just asking if any of you folks had more comments?

thanks,
>
> On Wed, Apr 23, 2014 at 12:46 PM, Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
> > On 17 April 2014 19:01, Konstantin Serebryany
> > <konstantin.s.serebryany@gmail.com> wrote:
> >> On Thu, Apr 17, 2014 at 8:45 PM, Bernhard Reutner-Fischer
> >> <rep.dot.nop@gmail.com> wrote:
> >>> On 17 April 2014 16:51:23 Konstantin Serebryany
> >>> <konstantin.s.serebryany@gmail.com> wrote:
> >>>
> >>>> On Thu, Apr 17, 2014 at 6:27 PM, Bernhard Reutner-Fischer
> >>>> <rep.dot.nop@gmail.com> wrote:
> >>>> > On 17 April 2014 16:07, Konstantin Serebryany
> >>>> > <konstantin.s.serebryany@gmail.com> wrote:
> >>>> >> Hi,
> >>>> >>
> >>>> >> If you are trying to modify the libsanitizer files, please read here:
> >>>> >> https://code.google.com/p/address-sanitizer/wiki/HowToContribute
> >>>> >
> >>>> > I read that, thanks. Patch 3/3 is for current compiler-rt git repo,
> >>>> > please install it there, i do not have write access to the LLVM nor
> >>>> > compiler-rt trees.
> >>>>
> >>>> I can commit your patch to llvm tree only after you follow the process
> >>>> described on that page.
> >>>> Sorry, this is a hard rule.
> >>>
> >>>
> >>> What part of the process do you think I did not follow?
> >>>
> >>> I made a patch for compiler-rt, sent it to llvm-commits@cs.uiuc.edu then
> >>> provided the corresponding GCC parts, along a backport of the new bits that
> >>> I expect to be overwritten once you do a new merge, leaving just the GCC
> >>> configuy bits. This is how I read the wiki page you cite.
> >>>
> >>> Please tell me what you expect me to do differently?
> >>
> >> First, I did not notice that you've sent it to llvm-commits because it
> >> was also sent to the gcc list (unusual thing to happen)
> >> and got filtered into the gcc part of my mail. Sorry.
> >> But second, the patch is far from trivial and you should not expect us
> >> to commit it w/o a careful review,
> >> so here comes another part of the wiki: "For non-trivial patches
> >> please use Phabricator -- this will help us reply faster."
> >
> > http://reviews.llvm.org/D3464
> >
> > thanks,

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2018-09-21  8:27 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-04 23:08 [PATCH 0/3] assorted patches for uClibc support Bernhard Reutner-Fischer
2013-04-04 23:18 ` [PATCH 1/3] libgcc: check for fenv.h in dfp configure check Bernhard Reutner-Fischer
2013-04-05  6:26   ` Ian Lance Taylor
2013-11-08 10:30     ` Bernhard Reutner-Fischer
2013-04-04 23:32 ` [PATCH 2/3] libstdc++-v3: ::tmpnam depends on uClibc SUSV4_LEGACY Bernhard Reutner-Fischer
2013-04-05  3:57   ` Gabriel Dos Reis
2013-04-05 10:23     ` Rainer Orth
2013-04-05 10:38       ` Gabriel Dos Reis
2013-04-05 10:53         ` Rainer Orth
2013-04-05 11:22           ` Gabriel Dos Reis
2013-04-05 12:34             ` Bernhard Reutner-Fischer
2013-04-11 12:37               ` Bernhard Reutner-Fischer
2013-04-11 12:46                 ` Paolo Carlini
2013-11-08 10:38                   ` Bernhard Reutner-Fischer
2013-11-11 11:43                     ` Jonathan Wakely
2013-11-13 10:20                       ` Bernhard Reutner-Fischer
2013-11-13 20:42                         ` Jonathan Wakely
2013-12-20 12:16                           ` Bernhard Reutner-Fischer
2014-04-08 21:10                             ` Bernhard Reutner-Fischer
2014-04-14 10:09                           ` Bernhard Reutner-Fischer
2014-04-14 10:23                             ` Jonathan Wakely
2013-04-05  0:25 ` [PATCH 3/3] libsanitizer: add LFS guards Bernhard Reutner-Fischer
     [not found]   ` <CAGQ9bdy6o_pbZx-xn2TmkNoj0iGCCV2wj_rfhN5e-XKjo0Jz=g@mail.gmail.com>
2013-04-05  8:29     ` Konstantin Serebryany
2013-04-05  8:32   ` Jakub Jelinek
2013-04-05  9:02     ` Konstantin Serebryany
2013-04-05 12:07       ` Bernhard Reutner-Fischer
2013-04-05 13:06         ` Jakub Jelinek
2014-04-17 14:01           ` [PATCH 0/3] libsanitizer libc conditionals Bernhard Reutner-Fischer
2014-04-17 14:01             ` [PATCH 3/3] [LLVM] [sanitizer] add conditionals for libc Bernhard Reutner-Fischer
2014-04-17 14:28               ` Konstantin Serebryany
2014-04-17 14:29                 ` Bernhard Reutner-Fischer
2014-04-17 15:17                   ` Konstantin Serebryany
2014-04-17 16:47                     ` Bernhard Reutner-Fischer
2014-04-17 17:06                       ` Konstantin Serebryany
2014-04-23  8:50                         ` Bernhard Reutner-Fischer
2014-04-23  8:59                           ` Konstantin Serebryany
2018-09-21  8:33                             ` Bernhard Reutner-Fischer
2014-04-17 14:01             ` [PATCH 1/3] libsanitizer: Fix !statfs64 builds Bernhard Reutner-Fischer
2014-04-17 14:08             ` [PATCH 2/3] libsanitizer: add conditionals for libc Bernhard Reutner-Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).