public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/1] bfd, binutils, gas: Mark unused variables
@ 2022-09-15  3:09 Tsukasa OI
  2022-09-15  3:09 ` [PATCH 1/1] " Tsukasa OI
  2022-09-15  4:17 ` [PATCH 0/1] " Tsukasa OI
  0 siblings, 2 replies; 14+ messages in thread
From: Tsukasa OI @ 2022-09-15  3:09 UTC (permalink / raw)
  To: Tsukasa OI, Nick Clifton, Ian Lance Taylor, Nelson Chu; +Cc: 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]

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

We could just remove practically unused variables but instead I chose to
keep it but with ATTRIBUTE_UNUSED.  This is because the most of such
variables may have possible uses in the future.

ATTRIBUTE_UNUSED (__attribute__((unused))) marks a variable *possibly
unused* and suppresses warnings about "written but not read thereafter"
or just "unused" variables.  Note that it only means a variable is "possibly
unused".  Even if a variable with this attribute is "used", it's completely
safe (removing the attribute when a variable is started to be used is
definitely better, though).


Thanks,
Tsukasa




Tsukasa OI (1):
  bfd, binutils, gas: Mark unused variables

 bfd/elf32-lm32.c      |  5 +----
 bfd/elf32-nds32.c     |  4 +---
 bfd/mmo.c             |  7 +------
 binutils/windmc.c     |  5 ++---
 gas/config/tc-riscv.c |  4 +---
 ld/pe-dll.c           | 11 ++++-------
 6 files changed, 10 insertions(+), 26 deletions(-)


base-commit: fe39ffdc202f04397f31557f17170b40bc42b77a
-- 
2.34.1


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

end of thread, other threads:[~2022-09-21  9:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  3:09 [PATCH 0/1] bfd, binutils, gas: Mark unused variables Tsukasa OI
2022-09-15  3:09 ` [PATCH 1/1] " Tsukasa OI
2022-09-15  4:17 ` [PATCH 0/1] " Tsukasa OI
2022-09-15  4:17   ` [PATCH 1/1] " Tsukasa OI
2022-09-15  7:29     ` Jan Beulich
2022-09-15  8:25       ` Tsukasa OI
2022-09-15 23:10         ` Hans-Peter Nilsson
2022-09-15 12:46   ` [PATCH v3 0/1] bfd, binutils, gas: Remove/mark " Tsukasa OI
2022-09-15 12:46     ` [PATCH v3 1/1] " Tsukasa OI
2022-09-15 12:58       ` Jan Beulich
2022-09-20 12:50       ` Nick Clifton
2022-09-21  5:54         ` Tsukasa OI
2022-09-21  6:15           ` Jan Beulich
2022-09-21  9:55           ` Nick Clifton

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