public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] gdb: (includes PR28413), Suppress some general warnings if built with Clang
@ 2022-09-15  3:10 Tsukasa OI
  2022-09-15  3:10 ` [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings Tsukasa OI
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Tsukasa OI @ 2022-09-15  3:10 UTC (permalink / raw)
  To: Tsukasa OI, Pedro Alves, Joel Brobecker, Enze Li; +Cc: gdb-patches, binutils

Hello,

[Common Background: Building GNU Binutils / GDB with Clang 15.0.0]

I'm now testing to build GNU Binutils / GDB with latest Clang (15.0.0) and
found some errors by default (when Binutils / GDB is not configured with
"--disable-werror").

While the best compiler to build GNU Binutils / GDB is GNU GCC, testing
other compilers are helpful to discover underlying problems and modernize
Binutils / GDB, even if building entire Binutils / GDB with the latest Clang
is unrealistic.  To be sure, I'm not going to finish "porting for Clang".
I will take low-hanging fruits and...

1.  make building with Clang easier and/or
2.  fix code issues (or non-issues) discovered as Clang warnings.

I made four patchsets in which, applying them all makes it possible to
build GNU Binutils / GDB with Clang (without help of --disable-werrors) for
many (but not all) targets including i386 and RISC-V with Ubuntu 22.04 LTS
(x86_64) host.  At least, I think they fix all (at minimum, most of) arch-
independent parts which prevents building with the latest version of Clang.

This is the one of them.


[About this Patchset]

This patchset deals with two kinds of warnings but with similar methods.

1.  gdb/unittests: PR28413, suppress custom warnings by Gnulib
    (PATCH 1/4, 3/4)

Gnulib generates a warning ("-Wuser-defined-warnings" on Clang) if the
system version of certain functions are used (to redirect the developer to
use Gnulib version).  However, this behavior is found harmful to
gdb/unittests/string_view-selftests.c, making the build failure.

This issue occurs if:

-   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 error is identified as PR28413.

Warnings about "free" may be resolved by modifying libiberty part but one of
the warnings generated by Gnulib points at the C++ standard library.

So, directly fixing the location which generates the warning is partially
impossible.  In the past, there were a proposal to fix this issue from the
Gnulib side:
<https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00003.html>
but rejected because it ruins the intent of Gnulib warnings.  So, a fix from
the Binutils / GDB side is desired.

2.  gdb: Suppress "unused" variable warning on Clang in Bison-generated code
    (PATCH 2/4, 4/4)

Clang generates a warning on "written but not read thereafter" varibles
("-Wset-but-unused-variable"), making the build failure.

The unique problem here is, the cause is the variable yynerrs in
$(builddir)/gdb/cp-name-parser.c, generated by
$(srcdir)/gdb/cp-name-parser.y.  So, directly fixing the location which
causes the warning is nonfeasible.


In either cases, we can resolve the problem if we use include/diagnostics.h.
This header file defines a set of macros to suppress certain warnings only
when necessary.  In this patchset (PATCH 1-2/4), it adds two "ignore
warning" macros and uses them when necessary (PATCH 3-4/4).

This is mainly a GDB-side fix.  But since it contains changes to shared
part (includes/diagnostics.h), this patchset is also posted to Binutils ML.


Thanks,
Tsukasa




Tsukasa OI (4):
  include: Add macro to ignore -Wuser-defined-warnings
  include: Add macro to ignore -Wunused-but-set-variable
  gdb/unittests: PR28413, suppress warnings generated by Gnulib
  gdb: Suppress "unused" variable warning on Clang

 gdb/cp-name-parser.y                  |  4 ++++
 gdb/unittests/string_view-selftests.c |  5 +++++
 include/diagnostics.h                 | 23 +++++++++++++++++++++++
 3 files changed, 32 insertions(+)


base-commit: fe39ffdc202f04397f31557f17170b40bc42b77a
-- 
2.34.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-11-14 14:02 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  3:10 [PATCH 0/4] gdb: (includes PR28413), Suppress some general warnings if built with Clang Tsukasa OI
2022-09-15  3:10 ` [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings Tsukasa OI
2022-09-20 16:36   ` Nick Clifton
2022-09-22 13:02     ` Enze Li
2022-09-15  3:10 ` [PATCH 2/4] include: Add macro to ignore -Wunused-but-set-variable Tsukasa OI
2022-09-15  3:10 ` [PATCH 3/4] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-09-15  3:10 ` [PATCH 4/4] gdb: Suppress "unused" variable warning on Clang Tsukasa OI
2022-09-22  8:25 ` [PATCH v2 0/4] gdb: (includes PR28413), Suppress some general warnings if built with Clang Tsukasa OI
2022-09-22  8:25   ` [PATCH v2 1/4] include: Add macro to ignore -Wuser-defined-warnings Tsukasa OI
2022-09-22 11:26     ` Nick Clifton
2022-09-22  8:25   ` [PATCH v2 2/4] include: Add macro to ignore -Wunused-but-set-variable Tsukasa OI
2022-09-22 11:27     ` Nick Clifton
2022-09-22  8:25   ` [PATCH v2 3/4] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-10-18 13:44     ` Enze Li
2022-10-18 16:14       ` Tsukasa OI
2022-09-22  8:25   ` [PATCH v2 4/4] gdb: Suppress "unused" variable warning on Clang Tsukasa OI
2022-10-12 17:36     ` Simon Marchi
2022-10-16 13:37       ` Tsukasa OI
2022-10-17 12:35         ` Simon Marchi
2022-10-18 17:11   ` [PATCH v3] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-11-14 14:02     ` Simon Marchi

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).