From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1668434477; bh=I77XF+AAqMreYDa1ExLj/dZthETri2dmvEV6/LvlLb4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=b4De3Vlo+PBWBg6il44E2Nx4ZBgnwM4ywzGpcACB09GNYdIbFKjWDU5g88gk0KdQi lI89mFfxY7rABpfNFjXUp9OFKrbJ8dfipYeda1ZYUG77iG+2agK1YSXl5/wL5koaWX ANRKCait8bugL20SZR2uXi5/XDR3AlluaG0Nohy0= 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> From: Simon Marchi In-Reply-To: <8b99d666e78ba5b9d32c7889a2161c70b3da88df.1666258361.git.research_trasio@irq.a4lg.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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