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