Re: [PATCH] xboard: fix build failure against gcc-10

Tim Mann <[email protected]> Sat, 25 Jan 2020 21:06:31 -0800
Newsgroups gmane.comp.gnu.xboard.devel
Message-ID <CA+2-M12ytDbLD_XfXf4Cp4MOicPfkJ8H94Xr=4Y7FKCuaKgkqA@mail.gmail.com>
--000000000000ef5a89059d03f4a8
Content-Type: text/plain; charset="UTF-8"

Thanks for the report and patch.

On Tue, Jan 21, 2020 at 7:09 PM Sergei Trofimovich <[email protected]>
wrote:

> On gcc-10 (and gcc-9 -fno-common) build fails as:
> ```
>   CCLD     xboard
> ld: book.o:(.bss+0x0): multiple definition of `ics_type';
> backend.o:(.bss+0x0): first defined here
> ld: childio.o:(.bss+0x0): multiple definition of `ics_type';
> backend.o:(.bss+0x0): first defined here
> ld: gamelist.o:(.bss+0x0): multiple definition of `ics_type';
> backend.o:(.bss+0x0): first defined here
> ld: ngamelist.o:(.bss+0x0): multiple definition of `ics_type';
> backend.o:(.bss+0x0): first defined here
> ...
> ```
> gcc-10 will change the default from -fcommon to fno-common:
> https://gcc.gnu.org/PR85678.
>
> The error also happens if CFLAGS=-fno-common passed explicitly.
>
> Signed-off-by: Sergei Trofimovich <[email protected]>
> ---
>  backend.h      | 2 +-
>  evalgraph.h    | 2 +-
>  xaw/xhistory.c | 1 -
>  3 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/backend.h b/backend.h
> index fae2ee63..bd280eae 100644
> --- a/backend.h
> +++ b/backend.h
> @@ -242,7 +242,7 @@ extern GameInfo gameInfo;
>
>  /* ICS vars used with backend.c and zippy.c */
>  enum ICS_TYPE { ICS_GENERIC, ICS_ICC, ICS_FICS, ICS_CHESSNET /* not
> really supported */ };
> -enum ICS_TYPE ics_type;
> +extern enum ICS_TYPE ics_type;
>
>  /* pgntags.c prototypes
>   */
> diff --git a/evalgraph.h b/evalgraph.h
> index f4b4f920..2ab0e3c1 100644
> --- a/evalgraph.h
> +++ b/evalgraph.h
> @@ -34,7 +34,7 @@ typedef enum { PEN_NONE, PEN_BLACK, PEN_DOTTED,
> PEN_BLUEDOTTED, PEN_BOLDWHITE, P
>  #define OPEN   0
>
>  /* Module globals */
> -ChessProgramStats_Move * currPvInfo;
> +extern ChessProgramStats_Move * currPvInfo;
>  extern int currFirst;
>  extern int currLast;
>  extern int currCurrent;
> diff --git a/xaw/xhistory.c b/xaw/xhistory.c
> index 6aa79f26..5b124f42 100644
> --- a/xaw/xhistory.c
> +++ b/xaw/xhistory.c
> @@ -96,7 +96,6 @@ ScrollToCursor (Option *opt, int caretPos)
>
>  // ------------------------------ callbacks --------------------------
>
> -char *historyText;
>  char historyTranslations[] =
>  "<Btn3Down>: select-start() \n \
>  <Btn3Up>: extend-end(PRIMARY) SelectMove() \n";
> --
> 2.25.0
>
>
>

--000000000000ef5a89059d03f4a8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for the report and patch.<br></div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Jan 21, 2020=
 at 7:09 PM Sergei Trofimovich &lt;<a href=3D"mailto:[email protected]">sly=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex">On gcc-10 (and gcc-9 -fno-common) build fails as:<br>
```<br>
=C2=A0 CCLD=C2=A0 =C2=A0 =C2=A0xboard<br>
ld: book.o:(.bss+0x0): multiple definition of `ics_type&#39;; backend.o:(.b=
ss+0x0): first defined here<br>
ld: childio.o:(.bss+0x0): multiple definition of `ics_type&#39;; backend.o:=
(.bss+0x0): first defined here<br>
ld: gamelist.o:(.bss+0x0): multiple definition of `ics_type&#39;; backend.o=
:(.bss+0x0): first defined here<br>
ld: ngamelist.o:(.bss+0x0): multiple definition of `ics_type&#39;; backend.=
o:(.bss+0x0): first defined here<br>
...<br>
```<br>
gcc-10 will change the default from -fcommon to fno-common:<br>
<a href=3D"https://gcc.gnu.org/PR85678" rel=3D"noreferrer" target=3D"_blank=
">https://gcc.gnu.org/PR85678</a>.<br>
<br>
The error also happens if CFLAGS=3D-fno-common passed explicitly.<br>
<br>
Signed-off-by: Sergei Trofimovich &lt;<a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a>&gt;<br>
---<br>
=C2=A0backend.h=C2=A0 =C2=A0 =C2=A0 | 2 +-<br>
=C2=A0evalgraph.h=C2=A0 =C2=A0 | 2 +-<br>
=C2=A0xaw/xhistory.c | 1 -<br>
=C2=A03 files changed, 2 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/backend.h b/backend.h<br>
index fae2ee63..bd280eae 100644<br>
--- a/backend.h<br>
+++ b/backend.h<br>
@@ -242,7 +242,7 @@ extern GameInfo gameInfo;<br>
<br>
=C2=A0/* ICS vars used with backend.c and zippy.c */<br>
=C2=A0enum ICS_TYPE { ICS_GENERIC, ICS_ICC, ICS_FICS, ICS_CHESSNET /* not r=
eally supported */ };<br>
-enum ICS_TYPE ics_type;<br>
+extern enum ICS_TYPE ics_type;<br>
<br>
=C2=A0/* pgntags.c prototypes<br>
=C2=A0 */<br>
diff --git a/evalgraph.h b/evalgraph.h<br>
index f4b4f920..2ab0e3c1 100644<br>
--- a/evalgraph.h<br>
+++ b/evalgraph.h<br>
@@ -34,7 +34,7 @@ typedef enum { PEN_NONE, PEN_BLACK, PEN_DOTTED, PEN_BLUED=
OTTED, PEN_BOLDWHITE, P<br>
=C2=A0#define OPEN=C2=A0 =C2=A00<br>
<br>
=C2=A0/* Module globals */<br>
-ChessProgramStats_Move * currPvInfo;<br>
+extern ChessProgramStats_Move * currPvInfo;<br>
=C2=A0extern int currFirst;<br>
=C2=A0extern int currLast;<br>
=C2=A0extern int currCurrent;<br>
diff --git a/xaw/xhistory.c b/xaw/xhistory.c<br>
index 6aa79f26..5b124f42 100644<br>
--- a/xaw/xhistory.c<br>
+++ b/xaw/xhistory.c<br>
@@ -96,7 +96,6 @@ ScrollToCursor (Option *opt, int caretPos)<br>
<br>
=C2=A0// ------------------------------ callbacks -------------------------=
-<br>
<br>
-char *historyText;<br>
=C2=A0char historyTranslations[] =3D<br>
=C2=A0&quot;&lt;Btn3Down&gt;: select-start() \n \<br>
=C2=A0&lt;Btn3Up&gt;: extend-end(PRIMARY) SelectMove() \n&quot;;<br>
-- <br>
2.25.0<br>
<br>
<br>
</blockquote></div>

--000000000000ef5a89059d03f4a8--