From patchwork Thu Nov 21 13:21:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Emilio_Cobos_=C3=81lvarez?= X-Patchwork-Id: 1198931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107246-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=crisal.io Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="eKWcNKPm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47JgHP5CDFz9sPc for ; Fri, 22 Nov 2019 00:23:29 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=HS/uKSDoCDkxB25ZiwAvzeiQjbvDIKAXl7jKgMHmV0c3IcpiJAjv4 Ky//AjNIM+KnLHR6w/4oW/8uwL/oMwT9U3fEB/g9eH7UvDsqB6FwKPGkIn+ECeo7 +lHeRMoFt7cAQanDfq2CB9a7z+hm9eZdXaDlTw6SliEau2B9QuXVTs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=VeUR+k2zLbx0UclYOIAgLomS7IE=; b=eKWcNKPmq2hLwetuZmFD51n+tWc4 N6Dpp3bZvxwLp3hUtzOGgq/ffil7PLUq492+d4WZrAGnXBGRNPgaFXjgUV5fax7Q y1SkU0qW/4ILU91KPBkh14AJ020rf3v8AeD7rRp6ZH7ZV6rHdvf6zSx/a5J1REJu 68RwXAxXPGS/gD8= Received: (qmail 1264 invoked by alias); 21 Nov 2019 13:23:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1256 invoked by uid 89); 21 Nov 2019 13:23:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=HAuthentication-Results:dis, HAuthentication-Results:sk:mail.em, H*Ad:D*io, HContent-Transfer-Encoding:8bit X-HELO: emiliocobos.net From: =?utf-8?q?Emilio_Cobos_=C3=81lvarez?= Authentication-Results: mail.emiliocobos.net; dmarc=none (p=none dis=none) header.from=crisal.io To: Florian Weimer , libc-alpha@sourceware.org Cc: =?utf-8?q?Emilio_Cobos_=C3=81lvarez?= Subject: [PATCH v2] libc: Don't use a custom wrapper macro around __has_include. Date: Thu, 21 Nov 2019 14:21:01 +0100 Message-Id: <20191121132101.84999-1-emilio@crisal.io> In-Reply-To: <875zjdo045.fsf@oldenburg2.str.redhat.com> References: <875zjdo045.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 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 [1] for a reduced test-case since I initially thought this was a clang bug, and [2] for more context. Apparently doing this is invalid C++ per [cpp.cond], which mentions [3]: > The #ifdef and #ifndef directives, and the defined conditional inclusion > operator, shall treat __has_include and __has_cpp_attribute as if they > were the names of defined macros. The identifiers __has_include and > __has_cpp_attribute shall not appear in any context not mentioned in this > subclause. [1]: https://bugs.llvm.org/show_bug.cgi?id=43982 [2]: https://bugs.llvm.org/show_bug.cgi?id=37990 [3]: http://eel.is/c++draft/cpp.cond#7.sentence-2 --- misc/sys/cdefs.h | 8 -------- sysdeps/unix/sysv/linux/bits/statx.h | 12 +++++++----- 2 files changed, 7 insertions(+), 13 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..2015c8262e 100644 --- a/sysdeps/unix/sysv/linux/bits/statx.h +++ b/sysdeps/unix/sysv/linux/bits/statx.h @@ -26,11 +26,13 @@ /* 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 +#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