From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5F9711F5AE for ; Sun, 6 Jun 2021 22:51:11 +0000 (UTC) Received: from localhost ([::1]:45594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq1bq-00016p-2j for normalperson@yhbt.net; Sun, 06 Jun 2021 18:51:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq1bm-00016S-QK for bug-gnulib@gnu.org; Sun, 06 Jun 2021 18:51:06 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.24]:24674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq1bj-0001jb-5u for bug-gnulib@gnu.org; Sun, 06 Jun 2021 18:51:06 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1623019860; cv=none; d=strato.com; s=strato-dkim-0002; b=iGDIFCV69lZzSow+ueg054XUCEGGF0bw+Nmu6gucAxvh8t/7JeOYMtaHeHhyQNnYLk zimwGCiHBoiAww2zvkUkmnpuLvY7UFacgWO/+UD9n6PwQByjb+FhghhA5grSfJ0PkHkd Ift5BAljmbhpN/WHSuYrLoTAuyEHI3mg3Kwse8LROglXMiGmAxnjQGPrH81AmniCV/C3 WROt/WkRlsC+vBQc2ocaI02+ouE5MtcvNAeK8JpIfS7uvoYkTHmcsmtpNNLB234M0VGQ GwK6cwA99w5A7yr+m1WTz26mZfK/f4vM/IW4i41biJqzcziAafmWopOS4burvNzYJDVR 1/Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623019860; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=MZzpbaT1stjMC6KkhVtRrUIRVRo2kvnASbuv5JMeJrY=; b=aH68+uO1YdZ6+GhVWcGPbByc6ktnQSwnGOJsLPinaG8Ofkq+VswRmaM6PxBvVqDoZg tDtE5+gkJFG6jjQGkXMBW4glaCZ32frH6YhXDHTSmHOudf1vdZXzUky+wnBlN4DbuF6w Tl2H+zApXZJpv7NVF7X2zZVFbNHzB+QiuAUrkQADNUXccIlgR80/5iNXT5wsSaIv6jIN Pj9Z/1sbbEAz/2FPqWTwvurVgVq+PSL9XqhujoKBp5qNQWZDpAhM3pjNxMkd3O/Ud9Ax f8CSTHaQC7sZveR6UruAr5ERkJLpZOKCSbkhrjwqGzexjl6aJunaijB15TitJYUeRIej FkOQ== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1623019860; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=MZzpbaT1stjMC6KkhVtRrUIRVRo2kvnASbuv5JMeJrY=; b=nMmzvw06NVOKV0ZBi8TiN/KPbopUVoeaQ8bb/6jEDjzO/idulrkkXbYaoAPtFtpEOt 9CGKRYd6iS6p+MyQvzw5C+DKWJxkXulsuidIEVqGLBDseh3ZXX5e44u4jBRJusmelmYQ XFbq1w4jeSa6DW8WJIhXbjv9NaEJ9+INfYVxIJ3nz7x+5D7aRKKY56Dpt/ni+eBP83Gz 8qj3KNp+hl9cqQqS7dAR15URU5s06xuJAyXL7GTsufD41eANQOA3BKZpqIlijB12qaww 9Is0c6sX+bPx7Fou5N+tLa/4J8Vdveqh9F5+t7wnS73zSvJlnSdOn3ivdp/Npv4bnZ8g lnYA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf3z5NW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.27.2 DYNA|AUTH) with ESMTPSA id q0869dx56Mp0JjA (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Mon, 7 Jun 2021 00:51:00 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: glob-h: Avoid conflict with preprocessor macros owned by the system Date: Mon, 07 Jun 2021 00:50:59 +0200 Message-ID: <2616713.192FMcs1Co@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=85.215.255.24; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Building a testdir created with ./gnulib-tool --create-testdir --dir=../testdir --with-c++-tests \ --without-privileged-tests --single-configure \ dynarray glob scratch_buffer on DragonFly BSD 6.0, I see this error: In file included from ../../gltests/../gllib/libc-config.h:158, from ../gllib/glob.h:581, from ../../gltests/test-glob-h-c++.cc:22: /usr/include/machine/endian.h:152:17: error: duplicate 'inline' static __inline __always_inline __uint64_t ^~~~~~~~~~~~~~~ /usr/include/machine/endian.h:162:17: error: duplicate 'inline' static __inline __always_inline __uint32_t ^~~~~~~~~~~~~~~ /usr/include/machine/endian.h:172:17: error: duplicate 'inline' static __inline __always_inline __uint16_t ^~~~~~~~~~~~~~~ What happens here is a conflict between the definition of '__always_inline' in gnulib's (included from glob.h -> libc-config.h -> cdefs.h) and the definition of '__always_inline' in DragonFly's . In C++ it is invalid to write static __inline __inline ... some_function (...) { ... } The DragonFly headers are consistent: They define #define __always_inline __attribute__((__always_inline__)) and use it like this in : static __inline __always_inline __uint64_t __bswap64 ... Gnulib's definition of __always_inline is tailored for glibc sources, which do static __always_inline bool ... Therefore it defines it as #define __always_inline __inline __attribute__ ((__always_inline__)) But gnulib's *overrides* the system's definition. And it is visible after any of these header files has been included: lib/dynarray.h lib/glob.in.h lib/scratch_buffer.h After one of these files has been included, the application can include any system include file, and these system include files will typically rely on the system's definition of __* macros from . It's a different thing to include for the compilation of a Gnulib .c file than to expose it through a .h file that the application can include. In the first case, the Gnulib .c file includes a small set of system's .h files, and therefore we can hope to have resolved the possible conflicts in a reasonable amount of time. In the second case, there is an uncountable number of conflicts; so, this problem will haunt us for years if we don't fix it. My fix here is to process the glob-libc.h file so that it does not rely on __* macros (that belong to the system's namespace), only on Gnulib macros, which we haven't seen conflict with system headers in 17 years. When glob-libc.h changes (following merges from glibc), the processing steps in modules/glob-h might need changes, but they will typically be small and straightforward. 2021-06-06 Bruno Haible glob-h: Avoid conflict with preprocessor macros owned by the system. This fixes a compilation error on DragonFly BSD 6.0. * lib/glob.in.h: Don't include . Don't define __USE_GNU. Include glob-libc.gl.h instead of glob-libc.h. * modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from glob-libc.h. * lib/libc-config.h: Add comment. diff --git a/lib/glob.in.h b/lib/glob.in.h index 4952666..dbc5b63 100644 --- a/lib/glob.in.h +++ b/lib/glob.in.h @@ -70,10 +70,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); /* Preparations for including the standard GNU C Library header. */ -# ifndef __attribute_maybe_unused__ -# include -# endif - # include /* On some systems, such as AIX 5.1, does a "#define stat stat64". @@ -81,10 +77,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); rely on 'struct stat'. */ # include -# ifndef __USE_GNU -# define __USE_GNU 1 -# endif - # if @REPLACE_GLOB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define glob rpl_glob @@ -102,7 +94,7 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int); /* Now the standard GNU C Library header should work. */ -# include "glob-libc.h" +# include "glob-libc.gl.h" #endif diff --git a/lib/libc-config.h b/lib/libc-config.h index fabca2f..f68749f 100644 --- a/lib/libc-config.h +++ b/lib/libc-config.h @@ -28,7 +28,10 @@ When compiled as part of glibc this is a no-op; when compiled as part of Gnulib this includes Gnulib's and defines macros - that glibc library code would normally assume. */ + that glibc library code would normally assume. + + Note: This header file MUST NOT be included by public header files + of Gnulib. */ #include diff --git a/modules/glob-h b/modules/glob-h index 40df48f..0b71fd2 100644 --- a/modules/glob-h +++ b/modules/glob-h @@ -51,6 +51,23 @@ glob.h: $(top_builddir)/config.status endif MOSTLYCLEANFILES += glob.h glob.h-t +BUILT_SOURCES += glob-libc.gl.h + +glob-libc.gl.h: glob-libc.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e '/__BEGIN_DECLS/{ s/__BEGIN_DECLS/#ifdef __cplusplus%extern "C" {%#endif/; y/%/\n/; }' \ + -e '/__END_DECLS/{ s/__END_DECLS/#ifdef __cplusplus%}%#endif/; y/%/\n/; }' \ + -e 's|__THROW||g' \ + -e 's|defined __USE_MISC|1|' \ + -e 's|ifdef __USE_GNU|if 1|' \ + -e 's|ifdef __USE_LARGEFILE64|if 0|' \ + < $(srcdir)/glob-libc.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += glob-libc.gl.h glob-libc.gl.h-t + + Include: