From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id H3RHJENKcmMIUxgAWB0awg (envelope-from ) for ; Mon, 14 Nov 2022 09:01:39 -0500 Received: by simark.ca (Postfix, from userid 112) id 83E741E124; Mon, 14 Nov 2022 09:01:39 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SZ5Lnpb5; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 303761E0D3 for ; Mon, 14 Nov 2022 09:01:39 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4EB203832369 for ; Mon, 14 Nov 2022 14:01:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EB203832369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668434498; bh=5JefS5tYaFG6M1HtPDCPzRjLjhKLCyowI3STccWx9h0=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=SZ5Lnpb5DfMNsmyLn0Y8fNQY7tyfiVNQy7hu6Si/YOPEmmCtpfchgHDANfQIf+TPj Q/HQVmEVjbK2NT61W0rVXQcZEEHhLZm4fR8PQFh6KP4SvH5bOb7KT8r6lw8ZZY8FAm 163ke+ZZB8tGeisF21tPioRHBlOs+dbS1hEW3tAA= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id EA6063858C60 for ; Mon, 14 Nov 2022 14:01:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA6063858C60 Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4DD691E0D3; Mon, 14 Nov 2022 09:01:16 -0500 (EST) Message-ID: <404b261a-d1b1-a710-1a5b-f365581811de@simark.ca> Date: Mon, 14 Nov 2022 09:01:16 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 01/40] gdb/unittests: PR28413, suppress warnings generated by Gnulib Content-Language: en-US To: Tsukasa OI , Andrew Burgess , Mike Frysinger , Nick Clifton Cc: gdb-patches@sourceware.org References: <8b99d666e78ba5b9d32c7889a2161c70b3da88df.1666258361.git.research_trasio@irq.a4lg.com> In-Reply-To: <8b99d666e78ba5b9d32c7889a2161c70b3da88df.1666258361.git.research_trasio@irq.a4lg.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 10/20/22 05:32, Tsukasa OI via Gdb-patches wrote: > Gnulib generates a warning if the system version of certain functions > are used (to redirect the developer to use Gnulib version). It caused a > compiler error when... > > - Compiled with Clang > - -Werror is specified (by default) > - C++ standard used by Clang is before C++17 (by default as of 15.0.0) > when this unit test is activated. > > This issue is raised as PR28413. > > However, previous proposal to fix this issue (a "fix" to Gnulib): > > was rejected because it ruins the intent of Gnulib warnings. > > So, we need a Binutils/GDB-side solution. > > This commit tries to address this issue on the GDB side. We have > "include/diagnostics.h" to disable certain warnings only when necessary. > > This commit suppresses the Gnulib warnings by surrounding entire #include > block with DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS to disable Gnulib- > generated warnings on all standard C++ header files. > --- > gdb/unittests/string_view-selftests.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c > index 2d7261d18d3..441d533b54e 100644 > --- a/gdb/unittests/string_view-selftests.c > +++ b/gdb/unittests/string_view-selftests.c > @@ -23,6 +23,11 @@ > > #define GNULIB_NAMESPACE gnulib > > +#include "diagnostics.h" > + > +DIAGNOSTIC_PUSH > +DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS > + > #include "defs.h" > #include "gdbsupport/selftest.h" > #include "gdbsupport/gdb_string_view.h" > @@ -34,6 +39,8 @@ > #include > #include > > +DIAGNOSTIC_POP > + > /* libstdc++'s testsuite uses VERIFY. */ > #define VERIFY SELF_CHECK > I think this is fine, so I went ahead and pushed it, after adding a little comment. I tried to look at an alternative way of fixing it, by making include/libiberty.h using GNULIB_NAMESPACE::free instead of free when GNULIB_NAMESPACE is defined. However, we then trip on: CXX unittests/string_view-selftests.o In file included from /home/smarchi/src/binutils-gdb/gdb/unittests/string_view-selftests.c:26: In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:28: In file included from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:204: In file included from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/ptid.h:36: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/string:40: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/char_traits.h:40: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/postypes.h:40: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/cwchar:231:12: error: The symbol ::wmemchr refers to the system function. Use gnulib::wmemchr instead. [-Werror,-Wuser-defined-warnings] { return wmemchr(const_cast(__p), __c, __n); } ^ And we can't fix that the same way... Simon