unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Emilio Cobos Álvarez" <emilio@crisal.io>
To: libc-alpha@sourceware.org
Cc: "Emilio Cobos Álvarez" <emilio@crisal.io>
Subject: [PATCH] libc: Don't use a custom wrapper macro around __has_include.
Date: Tue, 12 Nov 2019 19:31:15 +0100	[thread overview]
Message-ID: <20191112183115.2048865-1-emilio@crisal.io> (raw)

This causes issues when using clang with -frewrite-includes to e.g., submit the
translation unit to a distributed compiler.

In my case, I was building Firefox using sccache.

See https://bugs.llvm.org/show_bug.cgi?id=43982 for a reduced test-case since I
initially thought this was a clang bug.

Apparently doing this is invalid C++ per:

 * http://eel.is/c++draft/cpp.cond#7.sentence-2

(See https://bugs.llvm.org/show_bug.cgi?id=37990)

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
---
 misc/sys/cdefs.h                     |  8 --------
 sysdeps/unix/sysv/linux/bits/statx.h | 14 ++++++++------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index abcb0d5e3c..467dbd9547 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -412,14 +412,6 @@
 # define __glibc_has_attribute(attr)	0
 #endif
 
-#ifdef __has_include
-/* Do not use a function-like macro, so that __has_include can inhibit
-   macro expansion.  */
-# define __glibc_has_include __has_include
-#else
-# define __glibc_has_include(header)	0
-#endif
-
 #if (!defined _Noreturn \
      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
      &&  !__GNUC_PREREQ (4,7))
diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h
index ff3f2e8973..14d5992226 100644
--- a/sysdeps/unix/sysv/linux/bits/statx.h
+++ b/sysdeps/unix/sysv/linux/bits/statx.h
@@ -26,12 +26,14 @@
 
 /* Use "" to work around incorrect macro expansion of the
    __has_include argument (GCC PR 80005).  */
-#if __glibc_has_include ("linux/stat.h")
-# include "linux/stat.h"
-# ifdef STATX_TYPE
-#  define __statx_timestamp_defined 1
-#  define __statx_defined 1
-# endif
+#ifdef __has_include
+#  if __has_include("linux/stat.h")
+#   include "linux/stat.h"
+#   ifdef STATX_TYPE
+#    define __statx_timestamp_defined 1
+#    define __statx_defined 1
+#   endif
+#  endif
 #endif
 
 #include <bits/statx-generic.h>
-- 
2.24.0


             reply	other threads:[~2019-11-12 18:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 18:31 Emilio Cobos Álvarez [this message]
2019-11-21 13:00 ` [PATCH] libc: Don't use a custom wrapper macro around __has_include Florian Weimer
2019-11-21 13:21   ` [PATCH v2] " Emilio Cobos Álvarez
2019-11-21 13:28   ` [PATCH] " Emilio Cobos Álvarez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191112183115.2048865-1-emilio@crisal.io \
    --to=emilio@crisal.io \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).