* [PATCH 0/1] gold: Suppress "unused" variable warning on Clang
@ 2022-09-26 10:35 Tsukasa OI
2022-09-26 10:35 ` [PATCH 1/1] " Tsukasa OI
0 siblings, 1 reply; 3+ messages in thread
From: Tsukasa OI @ 2022-09-26 10:35 UTC (permalink / raw)
To: Tsukasa OI, Ian Lance Taylor, Cary Coutant; +Cc: binutils
Hello,
[Background]
When we build Binutils and GDB with Clang, it causes a build failure due to
warnings generated by Clang and the default -Werror configuration.
I MOSTLY managed to make ALL ARCHITECTURE ENABLED Binutils and GDB
-Werror-free on Clang 15.0.0 (note that this does not necessarily mean
warning-free) and this patchset is a part of it (GNU gold).
- It still requires -Wno-implicit-function-declaration
on the LatticeMicro32 and M32R simulators. Except them, all Binutils /
GDB components can be built with Clang by default with my tree.
Full Clang 15.0.0 -Werror-free branch in development is available at:
<https://github.com/a4lg/binutils-gdb/tree/clang-nowarn-dev>
Tested configuration:
- Ubuntu 22.04.1 LTS (x86_64)
- LLVM / Clang 15.0.0 (built from source)
- Configuration examples:
$srcdir/configure \
--enable-targets=all \
--enable-multilib --enable-ld --enable-gold --enable-nls \
CC=clang CXX=clang++ CCLD=clang CXXLD=clang++ \
CFLAGS=' -O2 -g -Wno-implicit-function-declaration' \
CXXFLAGS='-O2 -g -Wno-implicit-function-declaration'
$srcdir/configure \
--target=riscv64-unknown-linux-gnu \
--enable-multilib --enable-ld --enable-gold --enable-nls \
CC=clang CXX=clang++ CCLD=clang CXXLD=clang++ \
CFLAGS='-O2 -g' CXXFLAGS='-O2 -g'
[About this Patch]
Clang generates a warning if there is a variable that is set but not used
otherwise ("-Wunused-but-set-variable"). On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).
Because the cause of this error is in the Bison-generated code
($(binutils)/gold/yyscript.y -> $(srcdir)/gold/yyscript.c),
this commit suppresses this warning ("-Wunused-but-set-variable") by placing
DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE macro at the end of user
prologue on yyscript.y.
Thanks,
Tsukasa
Tsukasa OI (1):
gold: Suppress "unused" variable warning on Clang
gold/yyscript.y | 3 +++
1 file changed, 3 insertions(+)
base-commit: c21736aed1d4877e090df60362413669dbdc391d
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] gold: Suppress "unused" variable warning on Clang
2022-09-26 10:35 [PATCH 0/1] gold: Suppress "unused" variable warning on Clang Tsukasa OI
@ 2022-09-26 10:35 ` Tsukasa OI
2022-09-27 1:05 ` Alan Modra
0 siblings, 1 reply; 3+ messages in thread
From: Tsukasa OI @ 2022-09-26 10:35 UTC (permalink / raw)
To: Tsukasa OI, Ian Lance Taylor, Cary Coutant; +Cc: binutils
Clang generates a warning if there is a variable that is set but not used
otherwise ("-Wunused-but-set-variable"). On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).
Because the cause of this error is in the Bison-generated code
($(srcdir)/gold/yyscript.y -> $(builddir)/gold/yyscript.c),
this commit suppresses this warning ("-Wunused-but-set-variable") by placing
DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE macro at the end of user
prologue on yyscript.y.
gold/ChangeLog:
* yyscript.y: Suppress -Wunused-but-set-variable warning on
the Bison-generated code.
---
gold/yyscript.y | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gold/yyscript.y b/gold/yyscript.y
index 909786f0ddd..fe8f6812712 100644
--- a/gold/yyscript.y
+++ b/gold/yyscript.y
@@ -26,6 +26,7 @@
%{
#include "config.h"
+#include "diagnostics.h"
#include <stddef.h>
#include <stdint.h>
@@ -34,6 +35,8 @@
#include "script-c.h"
+DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
+
%}
/* We need to use a pure parser because we might be multi-threaded.
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] gold: Suppress "unused" variable warning on Clang
2022-09-26 10:35 ` [PATCH 1/1] " Tsukasa OI
@ 2022-09-27 1:05 ` Alan Modra
0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2022-09-27 1:05 UTC (permalink / raw)
To: Tsukasa OI; +Cc: Ian Lance Taylor, Cary Coutant, binutils
On Mon, Sep 26, 2022 at 10:35:40AM +0000, Tsukasa OI via Binutils wrote:
> * yyscript.y: Suppress -Wunused-but-set-variable warning on
> the Bison-generated code.
Applied, thanks.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-27 1:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26 10:35 [PATCH 0/1] gold: Suppress "unused" variable warning on Clang Tsukasa OI
2022-09-26 10:35 ` [PATCH 1/1] " Tsukasa OI
2022-09-27 1:05 ` Alan Modra
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).