d8307d
commit bfa864e1645e140da2e1aae3cf0d0ba0674f6eb5
d8307d
Author: Emilio Cobos Álvarez <emilio@crisal.io>
d8307d
Date:   Tue Nov 12 19:18:32 2019 +0100
d8307d
d8307d
    Don't use a custom wrapper macro around __has_include (bug 25189).
d8307d
    
d8307d
    This causes issues when using clang with -frewrite-includes to e.g.,
d8307d
    submit the translation unit to a distributed compiler.
d8307d
    
d8307d
    In my case, I was building Firefox using sccache.
d8307d
    
d8307d
    See [1] for a reduced test-case since I initially thought this was a
d8307d
    clang bug, and [2] for more context.
d8307d
    
d8307d
    Apparently doing this is invalid C++ per [cpp.cond], which mentions [3]:
d8307d
    
d8307d
    > The #ifdef and #ifndef directives, and the defined conditional
d8307d
    > inclusion operator, shall treat __has_include and __has_cpp_attribute
d8307d
    > as if they were the names of defined macros.  The identifiers
d8307d
    > __has_include and __has_cpp_attribute shall not appear in any context
d8307d
    > not mentioned in this subclause.
d8307d
    
d8307d
    [1]: https://bugs.llvm.org/show_bug.cgi?id=43982
d8307d
    [2]: https://bugs.llvm.org/show_bug.cgi?id=37990
d8307d
    [3]: http://eel.is/c++draft/cpp.cond#7.sentence-2
d8307d
    
d8307d
    Change-Id: Id4b8ee19176a9e4624b533087ba870c418f27e60
d8307d
d8307d
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
d8307d
index 9e840e602f815d86..3f6fe3cc8563b493 100644
d8307d
--- a/misc/sys/cdefs.h
d8307d
+++ b/misc/sys/cdefs.h
d8307d
@@ -412,14 +412,6 @@
d8307d
 # define __glibc_has_attribute(attr)	0
d8307d
 #endif
d8307d
 
d8307d
-#ifdef __has_include
d8307d
-/* Do not use a function-like macro, so that __has_include can inhibit
d8307d
-   macro expansion.  */
d8307d
-# define __glibc_has_include __has_include
d8307d
-#else
d8307d
-# define __glibc_has_include(header)	0
d8307d
-#endif
d8307d
-
d8307d
 #if (!defined _Noreturn \
d8307d
      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
d8307d
      &&  !__GNUC_PREREQ (4,7))
d8307d
diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h
d8307d
index 206878723fd37881..aaccfdc2dc03a1dc 100644
d8307d
--- a/sysdeps/unix/sysv/linux/bits/statx.h
d8307d
+++ b/sysdeps/unix/sysv/linux/bits/statx.h
d8307d
@@ -26,11 +26,13 @@
d8307d
 
d8307d
 /* Use "" to work around incorrect macro expansion of the
d8307d
    __has_include argument (GCC PR 80005).  */
d8307d
-#if __glibc_has_include ("linux/stat.h")
d8307d
-# include "linux/stat.h"
d8307d
-# ifdef STATX_TYPE
d8307d
-#  define __statx_timestamp_defined 1
d8307d
-#  define __statx_defined 1
d8307d
+#ifdef __has_include
d8307d
+# if __has_include ("linux/stat.h")
d8307d
+#  include "linux/stat.h"
d8307d
+#  ifdef STATX_TYPE
d8307d
+#   define __statx_timestamp_defined 1
d8307d
+#   define __statx_defined 1
d8307d
+#  endif
d8307d
 # endif
d8307d
 #endif
d8307d